An Open-Source Framework for Scaling Generative Recommendation
📄 Technical Report | 🤗 Huggingface | 🤖 Modelscope
MiniOneRec is the first fully open-source generative recommendation framework, which provides an end-to-end workflow spanning SID construction, supervised fine-tuning (SFT), and recommendation-oriented reinforcement learning (RL).
2026-05-13 — We have introduced the new TS-Rec codebase, following the method proposed in Fine-grained Semantics Integration for Large Language Model-based Recommendation. We sincerely thank the contributors for their valuable efforts and support in making this update available.
2026-01-04 — Regarding the potential discrepancies between the reproduced results based on the Instruct model and our reported metrics, please check whether the CC metric in the evaluation log is non-zero (refer to calc.py). If it is non-zero, it indicates that the model is still generating a large number of invalid items, and constrained decoding has not been successful. We suspect this issue may be related to the versions of dependencies such as the transformer library, and we are still investigating the cause to provide a universal solution. In the meantime, you may switch the Instruct model to a base model, such as Qwen2.5-base, to avoid this problem.
2025-12-04 — We update new scripts to support processing the Amazon23 dataset.
2025-12-01 — We fix a bug in data.py that could cause the SID–item alignment task to see the answers in advance. This was because we had previously attempted to use partial trajectories to guide the full SID–item generation and does not affect the model performance.
2025-11-20 — The SID construction method in RQ-Kmeans+ has been updated (first proposed in GPR and this is the first open-source reproduction).
2025-11-19 — We implemented a multi-GPU parallel text-to-embedding method based on Accelerate, which is significantly more efficient than the original version: rq/text2emb/amazon_text2emb.py
2025-11-19 — The SID construction method in constrained-RQ-Kmeans has been updated.
2025-11-07 — Thank you for submitting issues! Based on your feedback, we have released a new implementation. If you encounter any problems while running the code, please update to and consult the latest version first.
2025-11-07 — You can now choose to freeze the LLM parameters during the SFT stage and train only the embeddings for the newly added SID vocabulary.
2025-10-31 — You can now directly download the implementation checkpoints of our MiniOnRec model.
2025-10-31 — The SID construction method in RQ-Kmeans has been updated.
SID Construction: MiniOneRec begins by transforming every product into a compact, semantically meaningful token. It concatenates an item’s title and description, feeds this sentence through a frozen text encoder, and then quantises the resulting embedding with a three-level RQ-VAE.
SFT: With all items rewritten as SIDs, the model is first trained in a supervised fashion. It views the chronologically ordered user history as a token sequence and learns, via next-token prediction, to generate the SID of the next product the user is likely to consume. Crucially, this stage is co-trained with a set of language-alignment objectives that map back and forth between natural language and SID space, allowing the recommender to inherit the world knowledge embedded in large language models while grounding that knowledge in discrete item codes.
Recommendation-Oriented RL: After SFT, MiniOneRec is further polished with a recommendation-oriented RL phase based on GRPO. Multiple candidate recommendations are generated for each prompt, their rewards are normalised within the group to stabilise gradients, and a KL penalty keeps the updated policy close to its reference. Because the action space is a closed list of item SIDs, the system switches to constrained beam search, which guarantees that every beam is unique and valid, greatly improving sampling efficiency and diversity. The reward signal itself blends a binary correctness term with a rank-aware component that penalises high-probability yet incorrect items more heavily, and can be augmented with collaborative-filtering scores. Together, this pipeline enables MiniOneRec to couple dense linguistic knowledge, achieving a high-performance, lightweight generative recommendation system.
| File / Directory | Description |
|---|---|
sft.sh |
Shell script to start the Supervised Fine-Tuning (SFT) stage |
sft.py |
Python implementation of the SFT training loop |
sft_gpr.py |
GPR-inspired SFT with Value-Aware Fine-Tuning (VAFT): implements weighted loss based on simulated item value |
rl.sh |
Shell script to start the Reinforcement Learning (RL) stage |
rl.py |
Python implementation of the RL training loop |
rl_gpr.py |
GPR-inspired RL with Hierarchy Enhanced Policy Optimization (HEPO) |
minionerec_trainer.py |
MiniOneRec trainer — GRPO-based trainer specialized for generative recommendation |
configs/ |
YAML configuration files |
evaluate.sh |
One-click offline Top-K evaluation script |
evaluate.py |
Evaluation utilities for computing HR@K and NDCG@K. |
LogitProcessor.py |
Logit processor for constrained decoding (Python implementation) |
data.py |
Data pipeline for SFT and RL training |
convert_dataset.py |
Converts an RQ-trained dataset to the SFT-then-RL format |
convert_dataset_gpr.py |
GPR-inspired dataset converter: injects simulated heterogeneous tokens (U/E/I/O) to emulate unified input representation |
data/amazon18_data_process.sh |
Shell script to filter and preprocess Amazon18 data into an RQ-ready format |
data/amazon18_data_process.py |
Python implementation of the Amazon18 data preprocessing pipeline |
data/amazon18_data_process_gpr.py |
GPR-inspired Amazon18 preprocessing: extracts heterogeneous features for unified input representation |
data/amazon23_data_process.sh |
Shell script to filter and preprocess Amazon23 data into an RQ-ready format |
data/amazon23_data_process.py |
Python implementation of the Amazon23 data preprocessing pipeline |
rq/text2emb/amazon_text2emb.sh |
Shell script to generate item embeddings (title + description) via emb_model for the Amazon dataset |
rq/text2emb/amazon_text2emb.py |
Python implementation of the above embedding generation |
rq/text2emb/amazon_text2emb_gpr.py |
GPR-inspired text-to-embedding |
rq/generate_indices.py |
Generates the SID file after training an RQ-VAE model |
rq/rqvae.sh |
Shell script to train RQ-VAE on Amazon item embeddings |
rq/rqvae.py |
Python implementation of RQ-VAE training |
rq/rqkmeans_faiss.py |
Python implementation of RQ-Kmeans training based on faiss |
rq/rqkmeans_constrained.py |
Python implementation of Constrained RQ-Kmeans |
rq/rqkmeans_constrained.sh |
Shell script to train constrained RQ-Kmeans constrained on Amazon item embeddings |
rq/rqkmeans_plus.py |
Python implementation of RQ-Kmeans+ |
rq/rqkmeans_plus.sh |
Shell script to train RQ-Kmeans+ constrained on Amazon item embeddings |
rq/generate_indices_plus.py |
Generates the SID file after training an RQ-Kmeans+ model |
rq/generate_indices_plus.sh |
Shell script to generate the SID file after training an RQ-Kmeans+ model |
requirements.txt |
List of Python dependencies |
Use the pre-trained Industrial/Office SIDs we provide for a quick start! Reproduction can be achieved with just 4–8 A100/H100 GPUs.
conda create -n MiniOneRec python=3.11 -y
conda activate MiniOneRec
pip install -r requirements.txt
bash sft.sh
bash rl.sh
bash evaluate.sh
git clone https://github.com/AkaliKong/MiniOneRec.git
cd MiniOneRec
conda create -n MiniOneRec python=3.11 -y
conda activate MiniOneRec
pip install -r requirements.txt
bash data/amazon18_data_process.sh \
--dataset your_dataset_type \ # e.g. Industrial
--user_k 5 \
--item_k 5 \
--st_year 2017 \
--st_month 10 \
--ed_year 2018 \
--ed_month 11 \
--output_path ./data/Amazon18
bash rq/amazon_text2emb.sh \
--dataset your_dataset_type \ # e.g., Industrial
--root your_processed_dataset_path \
--plm_name qwen \
--plm_checkpoint your_emb_model_path
Choose either 3.1.1, 3.1.2, 3.1.3 or 3.1.4.
bash rq/rqvae.sh \
--data_path xxx/data/Industrial_and_Scientific/Industrial_and_Scientific.emb-qwen-td.npy \
--ckpt_dir ./output/Industrial_and_Scientific \
--lr 1e-3 \
--epochs 10000 \
--batch_size 20480
conda install faiss-gpu
python rqkmeans_faiss.py --dataset Industrial_and_Scientific # The RQ-Kmeans method based on semantic embeddings has a relatively high collision rate.
pip install k_means_constrained
pip install polars
bash rqkmeans_constrained.sh
pip install k_means_constrained
pip install polars
bash rqkmeans_constrained.sh
bash rqkmeans_plus.sh
python rq/generate_indices.py
# or
bash rq/generate_indices_plus.sh
python convert_dataset.py \
--dataset_name Industrial_and_Scientific \
--data_dir /path/to/Industrial_and_Scientific \
--output_dir /path/to/ourput_dir \
bash sft.sh \
--base_model your_model_path \
--output_dir your_ourput_dir \
--sid_index_path your_.index.json_path \
--item_meta_path your_.item.json_path
(Optional) For production-scale datasets, considering the cost of reinforceme
$ claude mcp add MiniOneRec \
-- python -m otcore.mcp_server <graph>