未提供项目描述
项目描述
Merlin Systems
Merlin Systems提供工具,用于将推荐模型与其他生产推荐系统元素(如特征存储、最近邻搜索和探索策略)结合起来,形成端到端推荐管道,这些管道可以使用Triton Inference Server提供。
快速入门
Merlin Systems使用Merlin Operator DAG API,与NVTabular中用于特征工程相同的API,来创建服务集合。要将特征工程工作流程和Tensorflow模型组合到推理管道中
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)
导出您的集合后,您可以引用目录以运行Triton Inference Server的一个实例来托管您的集合。
tritonserver --model-repository=/export_path/
请参阅Merlin示例笔记本,了解如何使用Merlin模型训练和评估排名模型,然后如何在Triton Inference Server上以集合形式提供服务。
对于使用XGBoost和隐式进行模型训练,并使用系统进行服务的场景,您可以访问以下示例。
构建四阶段推荐流程
Merlin系统还可以构建更复杂的托管流程,这些流程集成多个模型和外部工具(如特征存储和最近邻搜索)。
# 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")
有关使用Merlin模型和系统探索building-and-deploying-multi-stage-RecSys
笔记本的示例,请参阅示例笔记本。
安装
Merlin系统需要Triton推理服务器和Tensorflow。最简单的设置是使用Merlin Tensorflow推理Docker容器,其中已预先安装。
使用Pip安装Merlin系统
您可以使用pip
安装Merlin系统。
pip install merlin-systems
从源代码安装Merlin系统
可以通过克隆GitHub存储库并运行setup.py
从源代码安装Merlin系统。
git clone https://github.com/NVIDIA-Merlin/systems.git
cd systems && python setup.py develop
从Docker运行Merlin系统
Merlin系统安装在多个Docker容器中,这些容器可通过NVIDIA GPU Cloud (NGC)目录获取。以下表格列出了包含用于Merlin的Triton推理服务器的容器。
容器名称 | 容器位置 | 功能 |
---|---|---|
merlin-hugectr |
https://catalog.ngc.nvidia.com/orgs/nvidia/teams/merlin/containers/merlin-hugectr | Merlin框架、HugeCTR和Triton推理服务器 |
merlin-tensorflow |
https://catalog.ngc.nvidia.com/orgs/nvidia/teams/merlin/containers/merlin-tensorflow | 仅支持Tensorflow的Merlin框架和Triton推理服务器 |
如果您想添加对GPU加速工作流的支持,您首先需要安装NVIDIA容器工具包,以提供Docker的GPU支持。您可以使用上表中引用的NGC链接获取有关如何启动和运行这些容器的更多信息。
反馈和支持
要报告错误或获取帮助,请打开问题。
项目详情
merlin-systems-23.8.0.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 8fdec782c36b5103b7a72611d7925b453372f2137612f881da2aff104dd50ca1 |
|
MD5 | 11a6181fa0711a7268139bfc57aa4971 |
|
BLAKE2b-256 | 093670192450f63e7fd30913a8098a47e371cac15560654148787f161c30d150 |