Skip to content

Commit

Permalink
Address review feedback
Browse files Browse the repository at this point in the history
- Add T4R to README.
- Wordsmithing in 01 notebook for building a RecSys.
- Flake8_nb fixes in 01 notebook.
- Update example README to include summary of the
  SageMaker notebook.
- Update the README for Building a RecSys.
  - Add the merlin-tensorflow:nightly container and URL
    for NGC to find the release tags.
  - Update the instructions for starting the container.
  • Loading branch information
mikemckiernan committed Dec 5, 2022
1 parent f108304 commit 9ab0d04
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 24 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,17 @@ models to highly-advanced deep learning models. With Merlin Models, you can:
- Assemble connectable building blocks for common RecSys architectures so that
you can create of new models quickly and easily.

**[Transformers4Rec](https://github.com/NVIDIA-Merlin/Transformers4Rec)**
[![PyPI version shields.io](https://img.shields.io/pypi/v/Transformers4Rec.svg)](https://pypi.org/project/Transformers4Rec/)<br>
The Transformers4Rec library provides sequential and session-based recommendation.
The library provides modular building blocks that are compatible with standard PyTorch modules.
You can use the building blocks to design custom architectures such as multiple towers, multiple heads and tasks, and losses.
With Transformers4Rec, you can:

- Build sequential and session-based recommenders from any sequential tabular data.
- Take advantage of the integration with NVTabular for seamless data preprocessing and feature engineering.
- Perform next-item prediction as well as classic binary classification or regression tasks.

**[Merlin Systems](https://github.com/NVIDIA-Merlin/systems)**
[![PyPI version shields.io](https://img.shields.io/pypi/v/merlin-systems.svg)](https://pypi.org/project/merlin-systems/)<br>
Merlin Systems provides tools for combining recommendation models with other
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"id": "405280b0-3d48-43b6-ab95-d29be7a43e9e",
"metadata": {},
"source": [
"The figure below represents a four-stage recommender systems. This is more complex process than only training a single model and deploying it, and it is much more realistic and closer to what's happening in the real-world recommender production systems."
"The figure below represents a four-stage recommender systems. This is a more complex process than only training a single model and deploying it, and it is much more realistic and closer to what's happening in the real-world recommender production systems."
]
},
{
Expand Down Expand Up @@ -115,7 +115,7 @@
"source": [
"**Compatibility:**\n",
"\n",
"These notebooks are developed and tested using our latest `merlin-tensorflow:22.XX` container on [NVIDIA's docker registry](https://catalog.ngc.nvidia.com/containers?filters=&orderBy=dateModifiedDESC&query=merlin)."
"This notebook is developed and tested using the latest `merlin-tensorflow` container from the NVIDIA NGC catalog. To find the tag for the most recently-released container, refer to the [Merlin TensorFlow](https://catalog.ngc.nvidia.com/orgs/nvidia/teams/merlin/containers/merlin-tensorflow) page."
]
},
{
Expand Down Expand Up @@ -152,7 +152,8 @@
"source": [
"import os\n",
"import nvtabular as nvt\n",
"from nvtabular.ops import *\n",
"from nvtabular.ops import Rename, Filter, Dropna, LambdaOp, Categorify, \\\n",
" TagAsUserFeatures, TagAsUserID, TagAsItemFeatures, TagAsItemID, AddMetadata\n",
"\n",
"from merlin.schema.tags import Tags\n",
"\n",
Expand Down Expand Up @@ -265,7 +266,7 @@
"id": "1e7bfb5c-88ed-4cf9-8a17-98c0284adb36",
"metadata": {},
"source": [
"In the NVTabular workflow below, notice that we apply `Dropna()` op at the end. The reason we do that is to remove rows with missing values in the final dataframe after preceding transformations. Although, the synthetic dataset that we generate above and use in this notebook does not have null entries, you might have null entries in your `user_id` and `item_id` columns in your own custom dataset. Therefore while applying `Dropna()` we will not be registering null `user_id_raw` and `item_id_raw` values in the feature store, and will be avoiding potential issues that can occur because of any null entires."
"In the following NVTabular workflow, notice that we apply the `Dropna()` Operator at the end. We add the Operator to remove rows with missing values in the final DataFrame after the preceding transformations. Although, the synthetic dataset that we generate and use in this notebook does not have null entries, you might have null entries in your `user_id` and `item_id` columns in your own custom dataset. Therefore, while applying `Dropna()` we will not be registering null `user_id_raw` and `item_id_raw` values in the feature store, and will be avoiding potential issues that can occur because of any null entries."
]
},
{
Expand Down Expand Up @@ -303,7 +304,7 @@
"\n",
"targets = [\"click\"] >> AddMetadata(tags=[Tags.BINARY_CLASSIFICATION, \"target\"])\n",
"\n",
"outputs = user_id + item_id + item_features + user_features + user_id_raw + item_id_raw + targets\n",
"outputs = user_id + item_id + item_features + user_features + user_id_raw + item_id_raw + targets\n",
"\n",
"# add dropna op to filter rows with nulls\n",
"outputs = outputs >> Dropna()"
Expand Down
57 changes: 39 additions & 18 deletions examples/Building-and-deploying-multi-stage-RecSys/README.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,66 @@
# Deploying a Multi-Stage Recommender System

We created two Jupyter notebooks that demonstrate two different stages of a Recommender Systems.
The goal of the notebooks is to show how to deploy a multi-stage Recommender System and serve recommendations with Triton Inference Server.
We created two Jupyter notebooks that demonstrate two different stages of recommender systems.
The notebooks show how to deploy a multi-stage recommender system and serve recommendations with Triton Inference Server.
The notebooks demonstrate how to use the NVTabular, Merlin Models, and Merlin Systems libraries for feature engineering, training, and then inference.

The two example notebooks are structured as follows:

- [Building the Recommender System](01-Building-Recommender-Systems-with-Merlin.ipynb):
- [Building the Recommender System](01-Building-Recommender-Systems-with-Merlin.ipynb):
- Execute the preprocessing and feature engineering pipeline (ETL) with NVTabular on the GPU/CPU.
- Train a ranking and retrieval model with TensorFlow based on the ETL output.
- Export the saved models, user and item features, and item embeddings.

- [Deploying the Recommender System with Triton](02-Deploying-multi-stage-RecSys-with-Merlin-Systems.ipynb):
- [Deploying the Recommender System with Triton](02-Deploying-multi-stage-RecSys-with-Merlin-Systems.ipynb):
- Set up a Feast feature store for feature storing and a Faiss index for similarity search.
- Build a multi-stage recommender system ensemble pipeline with Merlin Systems operators.
- Perform inference with the Triton Inference Server using the Merlin Systems library.

## Running the Example Notebooks

Merlin docker containers are available on http://ngc.nvidia.com/catalog/containers/ with pre-installed versions. For `Building-and-deploying-multi-stage-RecSys` example notebooks we used `merlin-tensorflow-inference` container that has NVTabular with TensorFlow and Triton Inference support.
Containers with the Merlin libraries are available from the NVIDIA NGC catalog.
To run the sample notebooks, use the `merlin-tensorflow` container.

To run the example notebooks using a container, do the following:

You can use the `nvcr.io/nvidia/merlin/merlin-hugectr:nightly` container.

To run the example notebooks using Docker containers, do the following:

1. Once you pull the inference container, launch it by running the following command:
```
docker run -it --gpus all -p 8000:8000 -p 8001:8001 -p 8002:8002 -p 8888:8888 -v <path to your data>:/workspace/data/ --ipc=host <docker container> /bin/bash
```
The container will open a shell when the run command execution is completed. You can remove the `--gpus all` flag to run the example on CPU.

1. You will have to start JupyterLab on the Docker container. First, install jupyter-lab with the following command if it is missing:
```shell
docker run -it --gpus all -p 8000:8000 -p 8001:8001 -p 8002:8002 -p 8888:8888 \
-v <path to your data>:/workspace/data/ --ipc=host \
nvcr.io/nvidia/merlin/merlin-tensorflow:nightly /bin/bash
```
pip install jupyterlab
```

For more information, see [Installation Guide](https://jupyterlab.readthedocs.io/en/stable/getting_started/installation.html).

2. Start the jupyter-lab server by running the following command:
> In production, instead of using the `nightly` tag, specify a release tag.
> You can find the release tags and more information on the [Merlin TensorFlow](https://catalog.ngc.nvidia.com/orgs/nvidia/teams/merlin/containers/merlin-tensorflow) container page.
You can remove the `--gpus all` flag to run the example on CPU.

The container opens a shell when the run command execution is complete.
Your shell prompt should look similar to the following example:

```text
root@2efa5b50b909:
```

1. Start JupyterLab by running the following command:

```shell
jupyter-lab --allow-root --ip='0.0.0.0' --NotebookApp.token='<password>'
```

3. Open any browser to access the jupyter-lab server using `localhost:8888`.
View the messages in your terminal to identify the URL for JupyterLab.
The messages in your terminal should show lines like the following example:

```text
Or copy and paste one of these URLs:
http://2efa5b50b909:8888/lab?token=9b537d1fda9e4e9cadc673ba2a472e247deee69a6229ff8d
or http://127.0.0.1:8888/lab?token=9b537d1fda9e4e9cadc673ba2a472e247deee69a6229ff8d
```

1. Open a browser and use the `127.0.0.1` URL provided in the messages from JupyterLab.

4. Once in the server, navigate to the ```/Merlin/examples/Building-and-deploying-multi-stage-RecSys/``` directory and execute the example notebooks.
1. After you log in to JupyterLab, navigate to the ```/Merlin/examples/Building-and-deploying-multi-stage-RecSys/``` directory and execute the example notebooks.
17 changes: 16 additions & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# NVIDIA Merlin Example Notebooks

We have a collection of Jupyter example notebooks that are based on different datasets to provide end-to-end examples for NVIDIA Merlin.
We have a collection of Jupyter example notebooks that show how to build an end-to-end recommender system with NVIDIA Merlin.
The notebooks use different datasets to demonstrate different feature engineering workflows that might help you to adapt your data for a recommender system.

These example notebooks demonstrate how to use NVTabular with TensorFlow, PyTorch, [HugeCTR](https://github.com/NVIDIA-Merlin/HugeCTR) and [Merlin Models](https://github.com/NVIDIA-Merlin/models).
Each example provides additional details about the end-to-end workflow, such as includes ETL, training, and inference.

Expand Down Expand Up @@ -39,6 +41,19 @@ These notebooks demonstrate how to scale NVTabular as well as the following:
- Train recommender system models with HugeCTR using multiple GPUs.
- Inference with the Triton Inference Server and Merlin Models for TensorFlow or HugeCTR.

### [Training and Serving with Merlin on AWS SageMaker](./sagemaker-tensorflow/)

The notebook and scripts demonstrate how to use Merlin components like NVTabular, Merlin Models, and Merlin Systems
with Triton Inference Server to build and deploy a sample end-to-end recommender system in AWS SageMaker.

- Use the Amazon SageMaker Python SDK to interact with the SageMaker environment.
- Create a sample NVTabular workflow to prepare data for binary classification.
- Train a DLRMModel with Merlin Models for click and conversion prediction.
- Create a Merlin Systems ensemble for use with Triton Inference Server.
- Build a container and store it in AWS ECR that is based on Merlin and includes the training script.
- Use the Python SDK to run the container and train the model.
- Use the boto3 library locally to make inference requests to Triton Inference Server in the container that is running in the SageMaker environment.

## Running the Example Notebooks

You can run the examples with Docker containers.
Expand Down

0 comments on commit 9ab0d04

Please sign in to comment.