Skip to content

Tutorial Overview

This section focuses on practical Torch-RecHub usage patterns across different recommendation scenarios. All code snippets in this section assume you are using the sample data included in the repository and running from the repository root.

Code resources

  • Full Python example scripts: examples/
  • Step-by-step tutorials in the docs: docs/en/tutorials/

Tutorial List

TutorialBest forLink
CTR PredictionRanking / click-through rate predictionCTR tutorial
Retrieval ModelsTwo-tower retrieval / vector searchRetrieval tutorial
Multi-Task LearningJoint CTR/CVR modelingMulti-task tutorial

Quick Navigation

CTR Prediction (Ranking)

Best if you want to quickly run through WideDeep / DeepFM / DCN.

python
from torch_rechub.models.ranking import DeepFM
from torch_rechub.trainers import CTRTrainer

model = DeepFM(deep_features=deep_features, fm_features=fm_features, mlp_params={"dims": [256, 128]})
trainer = CTRTrainer(model, device="cuda:0")
trainer.fit(train_dl, val_dl)

View full tutorial →

Retrieval Models

Best if you want to run a two-tower or multi-interest retrieval pipeline such as DSSM / YoutubeDNN / MIND.

python
from torch_rechub.models.matching import DSSM
from torch_rechub.trainers import MatchTrainer

model = DSSM(user_features, item_features)
trainer = MatchTrainer(model, mode=0, device="cuda:0")
trainer.fit(train_dl)

View full tutorial →

Multi-Task Learning

Best if you want to understand the training flow of MMOE / PLE / ESMM on the Ali-CCP sample data.

python
from torch_rechub.models.multi_task import MMOE
from torch_rechub.trainers import MTLTrainer

model = MMOE(
    features,
    task_types=["classification", "classification"],
    n_expert=8,
    expert_params={"dims": [16]},
    tower_params_list=[{"dims": [8]}, {"dims": [8]}],
)
trainer = MTLTrainer(model, task_types=["classification", "classification"], device="cuda:0")
trainer.fit(train_dl, val_dl)

View full tutorial →

Model Tutorials

The model-specific tutorial pages below provide focused walkthroughs, including model setup, trainer usage, and tuning-oriented notes for each family.

Ranking Models

ModelSummaryLink
DeepFMFM + deep network for rankingDeepFM
Wide&DeepMemorization + generalizationWideDeep
DCN / DCNv2Explicit feature crossingDCN
DINTarget-aware attention over user historyDIN
DIENInterest evolution modelingDIEN
BSTTransformer-based sequence rankingBST

Retrieval Models

ModelSummaryLink
DSSMClassic two-tower semantic matchingDSSM
YoutubeDNNYouTube-style deep retrievalYoutubeDNN
MINDMulti-interest retrieval with capsulesMIND

Multi-Task Models

ModelSummaryLink
MMOEMulti-gate mixture-of-expertsMMOE
PLEProgressive layered extractionPLE

Suggested Validation Order

  1. Start with Quick Start to verify that your environment, trainers, and sample datasets are all working.
  2. Then read the CTR tutorial or Retrieval tutorial to understand the full data flow.
  3. Finally, go deeper into model-specific pages for parameter explanations, tuning suggestions, and ONNX / visualization usage.