Model Library Overview
Torch-RecHub provides a rich recommendation model library that covers ranking, matching, multi-task learning, and generative recommendation. All models are implemented in PyTorch and are easy to use and extend.
Model Library Structure
The model library is organized by recommendation stage and task type:
- Ranking Models: Used during fine ranking to predict click-through rates or user preference scores for items
- Matching Models: Used during candidate generation to retrieve candidates from a large item collection
- Multi-Task Models: Jointly optimize multiple related tasks to improve generalization
- Generative Recommendation: Uses generative models to produce personalized recommendations
Model Selection Guide
Choosing a Ranking Model
| Model | Suitable Scenario | Characteristics |
|---|---|---|
| WideDeep | Basic ranking tasks | Combines linear and deep models to balance memorization and generalization |
| DeepFM | Scenarios where feature interactions matter | Captures both low-order and high-order feature interactions |
| DCN/DCNv2 | Explicit feature-crossing scenarios | Explicitly learns high-order feature crosses with high computational efficiency |
| DIN | Scenarios with dynamically changing user interests | Uses attention to capture user interests |
| DIEN | Long-sequence interest modeling | Models the dynamic evolution of user interests |
| BST | Scenarios where sequence features matter | Uses a Transformer to model sequence features |
| AutoInt | Automatic feature-interaction learning | Automatically learns feature-interaction patterns |
Choosing a Matching Model
| Model | Suitable Scenario | Characteristics |
|---|---|---|
| DSSM | Text-matching scenarios | Uses a two-tower architecture to map users and items into the same vector space |
| YoutubeDNN | Large-scale recommendation | Deep matching based on user behavior sequences |
| MIND | Multi-interest recommendation | Learns multiple interest representations for each user |
| GRU4Rec/SASRec | Sequential recommendation | Models a user's recent behavior sequence |
| ComirecDR/ComirecSA | Controllable multi-interest recommendation | Allows control over the number of generated interests |
Choosing a Multi-Task Model
| Model | Suitable Scenario | Characteristics |
|---|---|---|
| SharedBottom | Scenarios with strongly related tasks | All tasks share the bottom network |
| MMOE | Scenarios with substantial task conflict | Uses a multi-gate mixture of experts so each task learns a different expert combination |
| PLE | Complex multi-task scenarios | Uses progressive layered extraction to alleviate negative transfer |
| ESMM | Scenarios with sample-selection bias | Uses entire-space modeling to address sample-selection bias |
| AITM | Scenarios with dependencies between tasks | Uses adaptive information transfer to learn task dependencies |
Choosing a Generative Recommendation Model
| Model | Suitable Scenario | Characteristics |
|---|---|---|
| HSTU | Next-item sequential recommendation | Hierarchical sequential transduction units with positional and temporal biases |
| HLLM | Sequential recommendation with precomputed LLM item embeddings | Freezes the item semantic table and trains a user-sequence Transformer |
| RQ-VAE | Item semantic-ID quantization | Compresses continuous item embeddings into multi-level codebook IDs |
| TIGER | Semantic-ID generative retrieval | Uses T5 to generate a valid semantic ID for the next item |
Model Documentation
Ranking Models
Detailed descriptions of ranking-model principles, usage, and parameters.
View Ranking Model Documentation
Matching Models
Detailed descriptions of matching-model principles, usage, and parameters.
View Matching Model Documentation
Multi-Task Models
Detailed descriptions of multi-task-model principles, usage, and parameters.
View Multi-Task Model Documentation
Generative Recommendation Models
Detailed descriptions of generative recommendation-model principles, usage, and parameters.
View Generative Recommendation Model Documentation
Usage Example
# Ranking-model example
from torch_rechub.models.ranking import DeepFM
from torch_rechub.trainers import CTRTrainer
# Create the model
model = DeepFM(deep_features=deep_features, fm_features=fm_features, mlp_params={"dims": [256, 128], "dropout": 0.2})
# Create the trainer
trainer = CTRTrainer(model, optimizer_params={"lr": 0.001}, device="cpu")
# Train the model
trainer.fit(train_dataloader, val_dataloader)
# Matching-model example
from torch_rechub.models.matching import DSSM
from torch_rechub.trainers import MatchTrainer
# Create the model
model = DSSM(user_features=user_features, item_features=item_features, temperature=1.0,
user_params={"dims": [256, 128, 64]}, item_params={"dims": [256, 128, 64]})
# Create the trainer
trainer = MatchTrainer(model, mode=0, device="cpu")
# Train the model
trainer.fit(train_dataloader)Contributing a New Model
If you would like to contribute a new model, see the Contributing Guide and follow the project's coding standards and documentation requirements.
