RE3RANK-Gemma-4-E4B
A RE³Rank reranker built on google/gemma-4-E4B-it. Paper: Re³Rank: Listwise Reranking with Reasoning-Conditioned Retrieval Heads. Code: https://github.com/ryehr/RE3RANK.
Overview of RE³Rank. A first-stage retriever returns candidates for the question from the corpus. The generator writes a reasoning trace from the question and the candidates, and the scorer reads the same input followed by the reasoning trace. Of all attention heads in the scorer, only a few selected RRHeads are used: each candidate is scored by the attention mass that these heads route from the reasoning trace positions to it. The ranking loss ℒrank updates both components and reaches the generator through a straight-through estimator.
RE³Rank reranks the candidates of a first-stage retriever in two steps:
- Generator. The model in thinking mode reads the candidates and the question (system prompt "You are a helpful assistant.", the native reasoning channel forced open) and writes a reasoning trace, as it would to answer the question. It is never told to rerank.
- Scorer. A second copy of the backbone, truncated at its top scoring layer, reads the same prompt followed by the trace. The score of a candidate is the attention mass that the trace tokens put on its tokens through the scoring heads 35-0,29-4 (layer-head), averaged over the trace tokens and the heads.
Generator and scorer were trained jointly.
Files
| path | content |
|---|---|
/ (repository root) | the generator: a Gemma4ForConditionalGeneration checkpoint (bf16) with the tokenizer, chat template and processor config of google/gemma-4-E4B-it |
scorer/scorer.safetensors | the trained scorer (fp32) |
scorer/config.json | base model, scoring heads, and the frozen tables the loader takes from the base model (from_base) |
Only the text decoder of the generator was trained; the vision and audio towers are those of the base model and are not used. model-dropped.safetensors holds the K/V projection and K-norm weights of the KV-shared layers, copied from the base model: transformers does not instantiate them, but vLLM expects them.
The scorer is loaded by re3rank.scorer.load_scorer of the code repository, which builds the truncated
backbone from google/gemma-4-E4B-it and loads scorer/scorer.safetensors on top of it.
Usage
Set up the environment of the code repository (PyTorch, transformers, vLLM), then:
git clone https://github.com/ryehr/RE3RANK && cd RE3RANK && pip install -e .
hf download Ryehr/RE3RANK-Gemma-4-E4B --local-dir re3rank-gemma-4-e4b
# 1. the generator writes one greedy reasoning trace per item (vLLM)
python scripts/eval/generate_traces.py --model re3rank-gemma-4-e4b --tokenizer google/gemma-4-E4B-it \
--data items.json --out traces.json
# 2. the scorer ranks the candidates of every item; --out holds the scores, one per candidate
python scripts/eval/score.py --model google/gemma-4-E4B-it --heads 35-0,29-4 --ckpt re3rank-gemma-4-e4b \
--traces traces.json --data items.json --out scores.json --keep-nogold
items.json is a list of items, each a question with its candidates in first-stage order:
[{"id": "q1", "question": "...",
"paragraphs": [{"title": "...", "paragraph_text": "..."}, "..."]}]
The model was trained and evaluated with 50 candidates per question (the top-50 of
Qwen3-Embedding-8B). A candidate may carry "is_supporting": true/false; with labels, score.py also
prints the recall metrics. The whole nine-set evaluation of the paper runs with
CKPT=Ryehr/RE3RANK-Gemma-4-E4B BASE=google/gemma-4-E4B-it HEADS=35-0,29-4 bash scripts/eval/run_eval.sh
after building the evaluation sets with scripts/data/ (see the repository README).
Results
Macro average over nine sets (HotpotQA, 2WikiMultihopQA, MuSiQue, NQ, PopQA, NarrativeQA, DetectiveQA, LoCoMo, LongMemEval; 9,205 queries), reranking the top-50 candidates of Qwen3-Embedding-8B. Recall is conditional: only queries with a gold candidate among the 50 count, and R@k divides by the number of gold candidates in the pool; NDCG@10 uses binary relevance. In %:
| R@1 | R@3 | R@5 | NDCG@10 |
|---|---|---|---|
| 44.51 | 77.14 | 84.06 | 82.54 |
Training
394 updates of 96 items (about one epoch) over a 38k-question mixture of NarrativeQA, MuSiQue, ConvoMem, QAConv and FriendsQA training questions with their Qwen3-Embedding-8B top-50 candidates; the evaluation questions are not used for training. Traces were sampled at temperature 1.0 with at most 1,024 tokens; 8-bit paged AdamW, learning rate 1e-5 for both models.
License
Apache-2.0, as the base model (license).
Citation
@misc{yan2026re3ranklistwisererankingreasoningconditioned,
title={Re$^3$Rank: Listwise Reranking with Reasoning-Conditioned Retrieval Heads},
author={Ruiyi Yan and Zhuoyuan Mao and Yugo Murawaki and Yiwen Guo},
year={2026},
eprint={2611.02550},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2611.02550},
}