From Towers to Recommendations
Introduction
Project introduction
From Towers to Recommendations
You have written every piece a retrieval model needs, namely the dot-product score, the in-batch loss, the log q correction, top K retrieval without seen items, and the three retrieval metrics.
In the notebook these pieces train real towers in PyTorch on generated interactions. The data comes from hidden user tastes and a long tail of item popularity, so you can also rank items by the hidden tastes themselves and see the best Recall@20 any model could reach, about 66%.
What you will see
With the plain in-batch loss, the 100 most chosen items get about 5% of all recommendation slots, although they make up about 47% of all choices, and Recall@20 falls to about 8%. Adding log q back to the same model's scores, with no retraining, lifts recall to about 47%, which shows that the sampling bias was the problem. Training with the corrected loss reaches about 48%.
The fix has a cost that you will measure. Coverage of the catalog drops from about 96% to about 72%, and recall on the less popular items stays about the same, near 0.13. A dial at serving time then lets you give up some recall for more variety, so you decide how much room popular items get.
Two towers, one score
1,000 itemsHow the notebook is organized
01
Train and break
Baselines first, then towers trained with the plain in-batch loss.
02
Correct
Explain the missing popular items with log q, then fix the loss.
03
Judge
Coverage, tail recall, a popularity dial, and three more seeds.
Train, break and fix a retriever
Run the whole investigation in the browser, about 40 minutes.