Add LETTER model for Semantic ID recommender - #716
Conversation
| test_data = diginetica.load_test() | ||
| print("data loaded") | ||
|
|
||
| item_ids = sorted({tup[2] for tup in train_data + val_data + test_data}) |
There was a problem hiding this comment.
content and cf_embeddings are constructed in sorted item_ids order. Cornac’s global item indices, however, are assigned by first appearance in the interaction data. FeatureModality(..., ids=item_ids) correctly remaps the content vectors, but cf_embeddings is passed directly and is never remapped. With actual SASRec embeddings, the collaborative loss therefore aligns each item’s semantic representation with another item’s CF vector, invalidating tokenizer training and resulting metrics.
can we check if this is correct/intended alignment? Don't want it to be a hack, we might need to make some changes for better design
|
Thanks for catching this. We fixed this in The example intentionally keeps I also verified that the previous experiment pipeline explicitly remapped the |
| Run the focused LETTER tests with: | ||
|
|
||
| ```bash | ||
| python -m pytest tests/cornac/models/letter/test_letter.py -q |
There was a problem hiding this comment.
nit: I don't think we have this test file
…uration from original implementation
|
Just added the example file to reproduce |
Description
This PR integrates
LETTER(Learnable Item Tokenization for Generative Recommendation) intocornacas an extension ofTIGER.LETTERretainsTIGER's RQ-VAE Semantic-ID and T5 generation pipeline, and it aligns the quantized content representation of each item with a fixed item embedding from a separately pretrained collaborative filtering model using anInfoNCE-style contrastive loss. The released recipe uses 32-dimensionalSASRecitem embeddings.Key changes
LETTERas an extension ofTIGERVerification and tuning
The original paper uses
LLaMa-7Binstead of the commonSentence-T5or OpenAI'stext-embedding-large-3, so we verified both stages (codebook and seq2seq) separately.1.86e-9. I.e., the behavior of the tokenizer fromcornacand the original implementation is identical.Setting: Amazon Beauty 2014 5-core, chronological leave-last-out, and
seed=42. The end-to-end run uses Sentence-T5 content embeddings and 32-dimensional item embeddings from a locally trained SASRec. The released Beauty tokenizer recipe usescf_weight=0.1,diversity_weight=1e-4, and 10,000 RQ-VAE epochs.With the authors' IDs, the Cornac generator is within
0.0002to0.0004of all reported paper metrics, so that comparison is close and direct. The end-to-end Sentence-T5 result is not an exact paper reproduction because the authors did not release their tokenizer checkpoint, content embeddings, or SASRec checkpoint; it is included as a fully runnable reference.Comparative context
Within the LETTER paper's experimental pipeline, LETTER-TIGER improves over its TIGER reimplementation by approximately 9–10% across the four reported Beauty metrics. However, that TIGER baseline is weaker than the result reported in the original TIGER paper. LETTER-TIGER remains below the original TIGER result on R@5, N@5, and N@10, while exceeding it on R@10.
This cross-paper comparison is not fully controlled: the original TIGER paper uses Sentence-T5 embeddings, whereas the LETTER paper uses LLaMA-7B content embeddings and a different tokenizer-training recipe. Because the LETTER authors did not release their tokenizer checkpoint, content embeddings, or SASRec checkpoint, the current reproduction validates the released implementation and generator with author-provided IDs, but cannot isolate the recommendation gain attributable to LETTER's collaborative and diversity regularization against a well-reproduced TIGER baseline.
Checklist:
README.md(if you are adding a new model).examples/README.md(if you are adding a new example).