MiniOneRec
Collection
复现OneRec生成式推荐系统,采用Qwen2.5系列大模型 • 4 items • Updated
MiniOneRec 是一个基于生成式架构的推荐系统模型。该模型以 Qwen2.5-0.5B 为底座,通过语义 ID(Semantic ID)技术对物品进行编码,将推荐任务转化为序列生成任务。
基于 Beam Search (num_beams=50) 的测试结果:
| 指标 (Metric) | @1 | @10 | @20 | @50 |
|---|---|---|---|---|
| HR (命中率) | 4.48% | 8.89% | 11.38% | 17.27% |
| NDCG (排序质量) | 4.48% | 6.40% | 7.03% | 8.18% |
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "你的用户名/仓库名"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype="auto", device_map="auto")
# 示例输入
prompt = "### Instruction:\nPredict the next item ID.\n\n### Input:\n<a_1><b_2> -> \n\n### Response:\n"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=128, num_beams=50)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Base model
Qwen/Qwen2.5-0.5B