This guide walks you through cloning the LoRe repository, installing dependencies, extracting reward model embeddings from the Reddit TLDR dataset, and training your first low-rank personalized reward model. The full pipeline takes roughly 30–60 minutes depending on your hardware; embedding extraction requires a CUDA GPU.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/facebookresearch/LoRe/llms.txt
Use this file to discover all available pages before exploring further.
Clone the repository
Clone the LoRe codebase from GitHub:The repository contains one directory per supported dataset (
RedditTLDR/, PRISM/, PersonalLLM/) plus the shared utils.py module at the root. All dataset scripts import from utils.py via a sys.path insertion, so you do not need to install LoRe as a package.Install dependencies
LoRe requires Python 3.8+ and a CUDA-capable GPU (recommended). Install all Python dependencies with:This installs the following pinned packages:
requirements.txt
The embedding extraction step (
prepare.py) loads Skywork/Skywork-Reward-Llama-3.1-8B-v0.2, an ~16 GB model that requires Flash Attention 2. Install it separately if not already present:Prepare the dataset
Move into the This script performs three things:When complete, two pickle files are written to the
RedditTLDR directory and run prepare.py:- Downloads the dataset — loads
openai/summarize_from_feedback(comparisons split) from the Hugging Face Hub using thedatasetslibrary. - Organizes by worker — groups all preference pairs by annotator ID (
worker), extracting the post text, the chosen summary, and the rejected summary for each pair. - Extracts embeddings — loads
Skywork/Skywork-Reward-Llama-3.1-8B-v0.2withattn_implementation="flash_attention_2"and extracts the final hidden-state vector of the last token for each chosen and rejected response.
prepare.py:prepare.py
RedditTLDR/ directory:tldr_embeddings_train.pkl— embeddings for the training splittldr_embeddings_val.pkl— embeddings for the validation split
prepare.py once; subsequent training runs load directly from these files.Train the basis model
With embeddings in place, train the shared reward basis and per-user weights:The script takes the following steps:
Training uses Adam with
-
Loads the pretrained reward head — extracts the final linear layer weights from
Skywork-Reward-Llama-3.1-8B-v0.2as the reference vectorV_final:train_basis.py -
Splits workers into seen and unseen — workers present in both train and validation sets are shuffled with
random.seed(0)and split 50/50. Seen workers are used for joint basis learning; unseen workers are held out for few-shot evaluation. -
Runs the full LoRe pipeline via
run()fromutils.py, sweeping over basis ranks:train_basis.py
K_list controls which ranks are evaluated:| K | Model |
|---|---|
| 0 | Reference model (pretrained reward head, no adaptation) |
| 1 | Standard Bradley-Terry model (single basis vector) |
| 2–6 | Low-rank LoRe with K basis vectors |
learning_rate=0.5 for 1,000 iterations per rank. Few-shot weight fitting for unseen users runs for 500 iterations with learning_rate=0.1.Interpret results
After training completes, Actual values depend on the worker split (seeded with
run() returns four accuracy arrays — one per evaluation setting — across the K values in K_list. The console output from eval_multiple() shows per-setting results at each rank. For each K you will see output of the form:random.seed(0)) and hardware.The four metrics to watch are:- Train accuracy — pairwise preference accuracy on seen users’ training prompts. Increases with K as the model gains capacity.
- Seen user, unseen prompts — generalization of learned user weights to held-out prompts for the same users. Tests whether personalization transfers beyond training data.
- Few-shot train accuracy — accuracy on the few-shot examples used to fit weights for unseen users. Should be high if the basis is expressive enough.
- Unseen user, unseen prompts — the hardest setting: new users with new prompts, adapted from the shared basis using only a handful of examples. This is LoRe’s primary evaluation target.
Next steps
To run the same workflow on PRISM or PersonalLLM, navigate to the corresponding directory and follow the sameprepare.py → train_basis.py sequence. The PRISM pipeline adds a separate embedding generation step (generate-prism-embeddings.py) and supports evaluation on RewardBench 2 via eval_rb2.py.