-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
docs-sched-rebuild
committed
Apr 25, 2024
1 parent
d28c21e
commit 2f6f8af
Showing
1,512 changed files
with
282,462 additions
and
37,315 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
507 changes: 389 additions & 118 deletions
507
main/_modules/merlin/systems/dag/ops/session_filter.html
Large diffs are not rendered by default.
Oops, something went wrong.
507 changes: 389 additions & 118 deletions
507
main/_modules/merlin/systems/dag/ops/softmax_sampling.html
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
507 changes: 389 additions & 118 deletions
507
main/_modules/merlin/systems/dag/ops/unroll_features.html
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
# [Merlin Systems](https://github.com/NVIDIA-Merlin/systems) | ||
|
||
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/merlin-systems) | ||
[![PyPI version shields.io](https://img.shields.io/pypi/v/merlin-systems.svg)](https://pypi.python.org/pypi/merlin-systems/) | ||
![GitHub License](https://img.shields.io/github/license/NVIDIA-Merlin/systems) | ||
[![Documentation](https://img.shields.io/badge/documentation-blue.svg)](https://nvidia-merlin.github.io/systems/stable/README.html) | ||
|
||
Merlin Systems provides tools for combining recommendation models with other elements of production recommender systems like feature stores, nearest neighbor search, and exploration strategies into end-to-end recommendation pipelines that can be served with [Triton Inference Server](https://github.com/triton-inference-server/server). | ||
|
||
## Quickstart | ||
|
||
Merlin Systems uses the Merlin Operator DAG API, the same API used in [NVTabular](https://github.com/NVIDIA-Merlin/NVTabular) for feature engineering, to create serving ensembles. To combine a feature engineering workflow and a Tensorflow model into an inference pipeline: | ||
|
||
```python | ||
import tensorflow as tf | ||
|
||
from merlin.systems.dag import Ensemble | ||
from merlin.systems.dag.ops import PredictTensorflow, TransformWorkflow | ||
from nvtabular.workflow import Workflow | ||
|
||
# Load saved NVTabular workflow and TensorFlow model | ||
workflow = Workflow.load(nvtabular_workflow_path) | ||
model = tf.keras.models.load_model(tf_model_path) | ||
|
||
# Remove target/label columns from feature processing workflowk | ||
workflow = workflow.remove_inputs([<target_columns>]) | ||
|
||
# Define ensemble pipeline | ||
pipeline = ( | ||
workflow.input_schema.column_names >> | ||
TransformWorkflow(workflow) >> | ||
PredictTensorflow(model) | ||
) | ||
|
||
# Export artifacts to disk | ||
ensemble = Ensemble(pipeline, workflow.input_schema) | ||
ensemble.export(export_path) | ||
``` | ||
|
||
After you export your ensemble, you reference the directory to run an instance of Triton Inference Server to host your ensemble. | ||
|
||
```shell | ||
tritonserver --model-repository=/export_path/ | ||
``` | ||
|
||
Refer to the [Merlin Example Notebooks](https://github.com/NVIDIA-Merlin/Merlin/tree/main/examples/ranking) for exploring notebooks that demonstrate | ||
how to train and evaluate a ranking model with Merlin Models and then how to serve it as an ensemble on [Triton Inference Server](https://github.com/triton-inference-server/server). | ||
|
||
For training models with XGBoost and Implicit, and then serving with Systems, you can visit these [examples](https://github.com/NVIDIA-Merlin/Merlin/tree/main/examples/traditional-ml). | ||
|
||
## Building a Four-Stage Recommender Pipeline | ||
|
||
Merlin Systems can also build more complex serving pipelines that integrate multiple models and external tools (like feature stores and nearest neighbor search): | ||
|
||
```python | ||
# Load artifacts for the pipeline | ||
retrieval_model = tf.keras.models.load_model(retrieval_model_path) | ||
ranking_model = tf.keras.models.load_model(ranking_model_path) | ||
feature_store = feast.FeatureStore(feast_repo_path) | ||
|
||
# Define the fields expected in requests | ||
request_schema = Schema([ | ||
ColumnSchema("user_id", dtype=np.int32), | ||
]) | ||
|
||
# Fetch user features, use them to a compute user vector with retrieval model, | ||
# and find candidate items closest to the user vector with nearest neighbor search | ||
user_features = request_schema.column_names >> QueryFeast.from_feature_view( | ||
store=feature_store, view="user_features", column="user_id" | ||
) | ||
|
||
retrieval = ( | ||
user_features | ||
>> PredictTensorflow(retrieval_model_path) | ||
>> QueryFaiss(faiss_index_path, topk=100) | ||
) | ||
|
||
# Filter out candidate items that have already interacted with | ||
# in the current session and fetch item features for the rest | ||
filtering = retrieval["candidate_ids"] >> FilterCandidates( | ||
filter_out=user_features["movie_ids"] | ||
) | ||
|
||
item_features = filtering >> QueryFeast.from_feature_view( | ||
store=feature_store, view="movie_features", column="filtered_ids", | ||
) | ||
|
||
# Join user and item features for the candidates and use them to predict relevance scores | ||
combined_features = item_features >> UnrollFeatures( | ||
"movie_id", user_features, unrolled_prefix="user" | ||
) | ||
|
||
ranking = combined_features >> PredictTensorflow(ranking_model_path) | ||
|
||
# Sort candidate items by relevance score with some randomized exploration | ||
ordering = combined_features["movie_id"] >> SoftmaxSampling( | ||
relevance_col=ranking["output"], topk=10, temperature=20.0 | ||
) | ||
|
||
# Create and export the ensemble | ||
ensemble = Ensemble(ordering, request_schema) | ||
ensemble.export("./ensemble") | ||
``` | ||
|
||
Refer to the [Example Notebooks](https://github.com/NVIDIA-Merlin/Merlin/tree/main/examples/Building-and-deploying-multi-stage-RecSys) for exploring | ||
`building-and-deploying-multi-stage-RecSys` notebooks with Merlin Models and Systems. | ||
|
||
## Installation | ||
|
||
Merlin Systems requires Triton Inference Server and Tensorflow. The simplest setup is to use the [Merlin Tensorflow Inference Docker container](https://catalog.ngc.nvidia.com/orgs/nvidia/teams/merlin/containers/merlin-tensorflow-inference), which has both pre-installed. | ||
|
||
### Installing Merlin Systems Using Pip | ||
|
||
You can install Merlin Systems with `pip`: | ||
|
||
```shell | ||
pip install merlin-systems | ||
``` | ||
|
||
### Installing Merlin Systems from Source | ||
|
||
Merlin Systems can be installed from source by cloning the GitHub repository and running `setup.py` | ||
|
||
```shell | ||
git clone https://github.com/NVIDIA-Merlin/systems.git | ||
cd systems && python setup.py develop | ||
``` | ||
|
||
### Running Merlin Systems from Docker | ||
|
||
Merlin Systems is installed on multiple Docker containers that are available from the NVIDIA GPU Cloud (NGC) catalog. | ||
The following table lists the containers that include Triton Inference Server for use with Merlin. | ||
|
||
| Container Name | Container Location | Functionality | | ||
| ------------------- | -------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | | ||
| `merlin-hugectr` | <https://catalog.ngc.nvidia.com/orgs/nvidia/teams/merlin/containers/merlin-hugectr> | Merlin frameworks, HugeCTR, and Triton Inference Server | | ||
| `merlin-tensorflow` | <https://catalog.ngc.nvidia.com/orgs/nvidia/teams/merlin/containers/merlin-tensorflow> | Merlin frameworks selected for only Tensorflow support and Triton Inference Server | | ||
|
||
If you want to add support for GPU-accelerated workflows, you will first need to install the [NVIDIA Container Toolkit](https://github.com/NVIDIA/nvidia-docker) to provide GPU support for Docker. You can use the NGC links referenced in the table above to obtain more information about how to launch and run these containers. | ||
|
||
## Feedback and Support | ||
|
||
To report bugs or get help, please [open an issue](https://github.com/NVIDIA-Merlin/Systems/issues/new/choose). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
***************** | ||
API Documentation | ||
***************** | ||
|
||
.. currentmodule:: merlin.systems | ||
|
||
|
||
Ensemble Graph Constructors | ||
--------------------------- | ||
|
||
.. currentmodule:: merlin.systems.dag | ||
|
||
.. autosummary:: | ||
:toctree: generated | ||
|
||
Ensemble | ||
|
||
Ensemble Operator Constructors | ||
------------------------------ | ||
|
||
.. currentmodule:: merlin.systems.dag.ops | ||
|
||
.. autosummary:: | ||
:toctree: generated | ||
|
||
workflow.TransformWorkflow | ||
tensorflow.PredictTensorflow | ||
fil.PredictForest | ||
implicit.PredictImplicit | ||
softmax_sampling.SoftmaxSampling | ||
session_filter.FilterCandidates | ||
unroll_features.UnrollFeatures | ||
|
||
.. faiss.QueryFaiss | ||
.. feast.QueryFeast | ||
Conversion Functions for Triton Inference Server | ||
------------------------------------------------ | ||
|
||
.. currentmodule:: merlin.systems.triton | ||
|
||
.. autosummary:: | ||
:toctree: generated | ||
|
||
convert_df_to_triton_input | ||
convert_triton_output_to_df |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
merlin.systems.dag.Ensemble | ||
=========================== | ||
|
||
.. currentmodule:: merlin.systems.dag | ||
|
||
.. autoclass:: Ensemble | ||
|
||
|
||
.. automethod:: __init__ | ||
|
||
|
||
.. rubric:: Methods | ||
|
||
.. autosummary:: | ||
|
||
~Ensemble.__init__ | ||
~Ensemble.export | ||
~Ensemble.load | ||
~Ensemble.save | ||
~Ensemble.transform | ||
|
||
|
||
|
||
|
||
|
||
.. rubric:: Attributes | ||
|
||
.. autosummary:: | ||
|
||
~Ensemble.input_schema | ||
~Ensemble.output_schema | ||
|
||
|
49 changes: 49 additions & 0 deletions
49
main/_sources/generated/merlin.systems.dag.ops.fil.PredictForest.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
merlin.systems.dag.ops.fil.PredictForest | ||
======================================== | ||
|
||
.. currentmodule:: merlin.systems.dag.ops.fil | ||
|
||
.. autoclass:: PredictForest | ||
|
||
|
||
.. automethod:: __init__ | ||
|
||
|
||
.. rubric:: Methods | ||
|
||
.. autosummary:: | ||
|
||
~PredictForest.__init__ | ||
~PredictForest.column_mapping | ||
~PredictForest.compute_column_schema | ||
~PredictForest.compute_input_schema | ||
~PredictForest.compute_output_schema | ||
~PredictForest.compute_selector | ||
~PredictForest.create_node | ||
~PredictForest.export | ||
~PredictForest.load_artifacts | ||
~PredictForest.output_column_names | ||
~PredictForest.save_artifacts | ||
~PredictForest.transform | ||
~PredictForest.validate_schemas | ||
|
||
|
||
|
||
|
||
|
||
.. rubric:: Attributes | ||
|
||
.. autosummary:: | ||
|
||
~PredictForest.dependencies | ||
~PredictForest.dynamic_dtypes | ||
~PredictForest.export_name | ||
~PredictForest.is_subgraph | ||
~PredictForest.label | ||
~PredictForest.output_dtype | ||
~PredictForest.output_properties | ||
~PredictForest.output_tags | ||
~PredictForest.supported_formats | ||
~PredictForest.supports | ||
|
||
|
49 changes: 49 additions & 0 deletions
49
main/_sources/generated/merlin.systems.dag.ops.implicit.PredictImplicit.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
merlin.systems.dag.ops.implicit.PredictImplicit | ||
=============================================== | ||
|
||
.. currentmodule:: merlin.systems.dag.ops.implicit | ||
|
||
.. autoclass:: PredictImplicit | ||
|
||
|
||
.. automethod:: __init__ | ||
|
||
|
||
.. rubric:: Methods | ||
|
||
.. autosummary:: | ||
|
||
~PredictImplicit.__init__ | ||
~PredictImplicit.column_mapping | ||
~PredictImplicit.compute_column_schema | ||
~PredictImplicit.compute_input_schema | ||
~PredictImplicit.compute_output_schema | ||
~PredictImplicit.compute_selector | ||
~PredictImplicit.create_node | ||
~PredictImplicit.export | ||
~PredictImplicit.load_artifacts | ||
~PredictImplicit.output_column_names | ||
~PredictImplicit.save_artifacts | ||
~PredictImplicit.transform | ||
~PredictImplicit.validate_schemas | ||
|
||
|
||
|
||
|
||
|
||
.. rubric:: Attributes | ||
|
||
.. autosummary:: | ||
|
||
~PredictImplicit.dependencies | ||
~PredictImplicit.dynamic_dtypes | ||
~PredictImplicit.export_name | ||
~PredictImplicit.is_subgraph | ||
~PredictImplicit.label | ||
~PredictImplicit.output_dtype | ||
~PredictImplicit.output_properties | ||
~PredictImplicit.output_tags | ||
~PredictImplicit.supported_formats | ||
~PredictImplicit.supports | ||
|
||
|
49 changes: 49 additions & 0 deletions
49
main/_sources/generated/merlin.systems.dag.ops.session_filter.FilterCandidates.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
merlin.systems.dag.ops.session\_filter.FilterCandidates | ||
======================================================= | ||
|
||
.. currentmodule:: merlin.systems.dag.ops.session_filter | ||
|
||
.. autoclass:: FilterCandidates | ||
|
||
|
||
.. automethod:: __init__ | ||
|
||
|
||
.. rubric:: Methods | ||
|
||
.. autosummary:: | ||
|
||
~FilterCandidates.__init__ | ||
~FilterCandidates.column_mapping | ||
~FilterCandidates.compute_column_schema | ||
~FilterCandidates.compute_input_schema | ||
~FilterCandidates.compute_output_schema | ||
~FilterCandidates.compute_selector | ||
~FilterCandidates.create_node | ||
~FilterCandidates.export | ||
~FilterCandidates.load_artifacts | ||
~FilterCandidates.output_column_names | ||
~FilterCandidates.save_artifacts | ||
~FilterCandidates.transform | ||
~FilterCandidates.validate_schemas | ||
|
||
|
||
|
||
|
||
|
||
.. rubric:: Attributes | ||
|
||
.. autosummary:: | ||
|
||
~FilterCandidates.dependencies | ||
~FilterCandidates.dynamic_dtypes | ||
~FilterCandidates.export_name | ||
~FilterCandidates.is_subgraph | ||
~FilterCandidates.label | ||
~FilterCandidates.output_dtype | ||
~FilterCandidates.output_properties | ||
~FilterCandidates.output_tags | ||
~FilterCandidates.supported_formats | ||
~FilterCandidates.supports | ||
|
||
|
Oops, something went wrong.