ameliechatelain commited on
Commit
74d45c4
Β·
verified Β·
1 Parent(s): 06435f0

Add model card

Browse files
Files changed (1) hide show
  1. README.md +205 -0
README.md ADDED
@@ -0,0 +1,205 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - en
5
+ - fr
6
+ base_model:
7
+ - Qwen/Qwen3.5-0.8B
8
+ pipeline_tag: image-text-to-text
9
+ library_name: transformers
10
+ tags:
11
+ - reranker
12
+ - cross-encoder
13
+ - multimodal
14
+ - text-ranking
15
+ - document-reranking
16
+ - vidore
17
+ - beir
18
+ ---
19
+
20
+ <div align="center">
21
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/609bbe2f4932693ca2009d6a/kbQOAarw0eaApow3M9HIl.png" alt="LightOn" width="512">
22
+
23
+ [![Website](https://img.shields.io/badge/LightOn-Website-blue?logo=google-chrome)](https://lighton.ai)
24
+ [![LinkedIn](https://img.shields.io/badge/LightOn-LinkedIn-0A66C2?logo=linkedin)](https://www.linkedin.com/company/lighton/)
25
+ [![X](https://img.shields.io/badge/@LightOnIO-X-black?logo=x)](https://x.com/LightOnIO)
26
+
27
+ πŸ“ Blog post: *coming soon* <!-- TODO: add blog post link -->
28
+
29
+ </div>
30
+
31
+ <h1 align="center">LightOn-rerank-PW-0.8B</h1>
32
+ <h3 align="center">Unified Text + Visual Document Reranker by LightOn</h3>
33
+
34
+ <p align="center">
35
+ <a href="https://huggingface.co/lightonai/LightOn-rerank-PW-0.8B">PW-0.8B</a> |
36
+ <a href="https://huggingface.co/lightonai/LightOn-rerank-LW-0.8B">LW-0.8B</a> |
37
+ <a href="https://huggingface.co/lightonai/LightOn-rerank-PW-2B">PW-2B</a> |
38
+ <a href="https://huggingface.co/lightonai/LightOn-rerank-LW-2B">LW-2B</a> |
39
+ <a href="https://huggingface.co/lightonai/LightOn-rerank-PW-4B">PW-4B</a> |
40
+ <a href="https://huggingface.co/lightonai/LightOn-rerank-LW-4B">LW-4B</a>
41
+ </p>
42
+
43
+ ---
44
+
45
+ ## About the LightOn-rerank family
46
+
47
+ Production retrieval pipelines usually need two rerankers: one for text passages and one for visual documents (PDF pages, slides, scans). **LightOn-rerank** models are *unified* cross-encoder rerankers: a single model scores both text passages and document page images against a query, on top of any first-stage retriever (BM25, dense embeddings, or ColPali-family late-interaction models).
48
+
49
+ The models are built on Qwen3.5 vision-language backbones (hybrid linear + full attention) and jointly fine-tuned on text and visual reranking data with mixed-modality batches (LoRA, merged into the released weights). Training data is English-only; French performance transfers zero-shot from the multilingual backbone.
50
+
51
+ The family comes in two scoring flavours Γ— three sizes (0.8B / 2B / 4B):
52
+
53
+ - **PW (pointwise)** β€” each candidate is scored independently: the model judges whether the document answers the query, and the score is `logit("Yes") βˆ’ logit("No")`. One forward pass per candidate, no generation β€” simple to serve (vLLM-compatible) and embarrassingly parallel.
54
+ - **LW (listwise)** β€” generative listwise ranking: 4 candidates are placed in a single prompt and the model generates a permutation (`[2] > [4] > [1] > [3]`). Larger candidate pools are ranked with a sliding window (window 4, stride 2, bottom-to-top). Cross-document attention makes LW markedly stronger on hard visual reranking, and unlike pointwise scoring it keeps improving with backbone size.
55
+
56
+ **LightOn-rerank-PW-0.8B** is the smallest pointwise member of the family, released primarily as a size/recipe reference point: it shows that independent Yes/No scoring degrades sharply below 2B parameters. If you want a 0.8B reranker, use [LightOn-rerank-LW-0.8B](https://huggingface.co/lightonai/LightOn-rerank-LW-0.8B) instead (+0.10 NDCG@10 on ViDoRe V3 with the same backbone).
57
+
58
+ ## Results
59
+
60
+ **ViDoRe V3** (visual document reranking, 8 domains Γ— EN/FR queries), NDCG@10, ColQwen2.5-v0.2 first stage, retrieve 100 / rerank 100. All models β€” including baselines β€” were re-evaluated under this same two-stage protocol, so numbers are mutually comparable but not comparable to vendor-reported end-to-end results.
61
+
62
+ | Model | Params | Scoring | ViDoRe V3 overall @10 |
63
+ |---|---|---|---|
64
+ | [LightOn-rerank-LW-4B](https://huggingface.co/lightonai/LightOn-rerank-LW-4B) | 4.5B | listwise | 0.6469 |
65
+ | *Qwen3-VL-Reranker-8B* | *8B* | *pointwise (pooling)* | *0.6423* |
66
+ | [LightOn-rerank-LW-2B](https://huggingface.co/lightonai/LightOn-rerank-LW-2B) | 2.2B | listwise | 0.6266 |
67
+ | [LightOn-rerank-PW-2B](https://huggingface.co/lightonai/LightOn-rerank-PW-2B) | 2.2B | pointwise | 0.5987 |
68
+ | [LightOn-rerank-PW-4B](https://huggingface.co/lightonai/LightOn-rerank-PW-4B) | 4.5B | pointwise | 0.5980 |
69
+ | *jina-reranker-m0* | *2.4B* | *pointwise* | *0.5939* |
70
+ | *Qwen3-VL-Reranker-2B* | *2B* | *pointwise (pooling)* | *0.5918* |
71
+ | [LightOn-rerank-LW-0.8B](https://huggingface.co/lightonai/LightOn-rerank-LW-0.8B) | 0.85B | listwise | 0.5825 |
72
+ | **LightOn-rerank-PW-0.8B (this model)** | 0.85B | pointwise | **0.4820** |
73
+
74
+ ### ViDoRe V3 detail (NDCG, ColQwen2.5 first stage, rerank-100)
75
+
76
+ | Domain | EN @5 | EN @10 | FR @5 | FR @10 |
77
+ |---|---|---|---|---|
78
+ | finance_en | 0.5648 | 0.5740 | 0.3023 | 0.3108 |
79
+ | finance_fr | 0.3042 | 0.3228 | 0.2956 | 0.3027 |
80
+ | computer_science | 0.7213 | 0.7396 | 0.5097 | 0.5086 |
81
+ | hr | 0.5543 | 0.5641 | 0.2538 | 0.2612 |
82
+ | energy | 0.6265 | 0.6490 | 0.6233 | 0.6397 |
83
+ | industrial | 0.5427 | 0.5488 | 0.2512 | 0.2599 |
84
+ | pharmaceuticals | 0.6340 | 0.6459 | 0.4627 | 0.4640 |
85
+ | physics | 0.4548 | 0.4784 | 0.4232 | 0.4422 |
86
+ | **mean** | **0.5503** | **0.5653** | **0.3902** | **0.3986** |
87
+
88
+ Overall @10: **0.4820** (EN 0.5653 / FR 0.3986).
89
+
90
+ ## Model Details
91
+
92
+ - **Model type:** multimodal cross-encoder reranker β€” **pointwise**: each candidate is scored independently as `logit("Yes") βˆ’ logit("No")`
93
+ - **Base model:** [Qwen/Qwen3.5-0.8B](https://huggingface.co/Qwen/Qwen3.5-0.8B) (Qwen3.5 hybrid linear + full attention VLM)
94
+ - **Parameters:** β‰ˆ0.85B (bfloat16, 1.7 GB)
95
+ - **Inputs:** query (text) + candidate document(s) β€” text passage **or** page image
96
+ - **Fine-tuning:** joint text+vision LoRA (r=32, Ξ±=32, rsLoRA β€” merged into the released weights), mixed-modality batches (2 text + 2 vision groups per micro-batch), vision loss weight 1.3, lr 1e-4, 1 epoch (465 steps)
97
+ - **Data:** ~120k EN text queries (NQ, TriviaQA, MSMARCO) with mined hard negatives + ~118k visual query–page pairs with ColPali-family hard negatives (`dedup_120k_en_v3` + `ColPali_hard_neg_v2`)
98
+ - **Languages:** English (training), French (zero-shot transfer)
99
+ - **Requirements:** `transformers >= 5.4.0` (`qwen3_5` architecture)
100
+ - **Internal experiment ID:** `qwen08pointwise`
101
+
102
+ ## Usage β€” pointwise reranking
103
+
104
+ Each candidate is scored independently as `logit("Yes") βˆ’ logit("No")` at the first generated position; sort candidates by descending score. The model was trained with a fixed system prompt and user template (`RERANKER_SYSTEM_V2` / `RERANKER_TEXT_V2` / `RERANKER_VISION_V2`) β€” these will be published alongside the blog post and **must** be used verbatim for best results.
105
+
106
+ ```python
107
+ import torch
108
+ from transformers import AutoModelForImageTextToText, AutoProcessor
109
+
110
+ model_id = "lightonai/LightOn-rerank-PW-0.8B"
111
+ model = AutoModelForImageTextToText.from_pretrained(
112
+ model_id,
113
+ dtype=torch.bfloat16,
114
+ attn_implementation="flash_attention_2",
115
+ device_map="cuda",
116
+ ).eval()
117
+ processor = AutoProcessor.from_pretrained(model_id)
118
+ processor.tokenizer.padding_side = "left" # scores are read at the last position
119
+
120
+ YES_TOKEN_ID = 9175 # "Yes"
121
+ NO_TOKEN_ID = 2665 # "No"
122
+
123
+ SYSTEM_PROMPT = ... # RERANKER_SYSTEM_V2 β€” released with the blog post
124
+ USER_TEMPLATE = ... # RERANKER_TEXT_V2, with {query} and {doc} fields
125
+
126
+ query = "What is late interaction in neural information retrieval?"
127
+ documents = [
128
+ "ColBERT computes token-level query-document interactions at search time...",
129
+ "The Eiffel Tower is located on the Champ de Mars in Paris.",
130
+ ]
131
+
132
+ texts = [
133
+ processor.apply_chat_template(
134
+ [
135
+ {"role": "system", "content": SYSTEM_PROMPT},
136
+ {"role": "user", "content": USER_TEMPLATE.format(query=query, doc=doc)},
137
+ ],
138
+ tokenize=False,
139
+ add_generation_prompt=True,
140
+ )
141
+ for doc in documents
142
+ ]
143
+ inputs = processor(
144
+ text=texts, return_tensors="pt", padding=True, truncation=True, max_length=2048
145
+ ).to(model.device)
146
+ with torch.inference_mode():
147
+ logits = model(**inputs).logits[:, -1]
148
+ scores = (logits[:, YES_TOKEN_ID] - logits[:, NO_TOKEN_ID]).tolist()
149
+
150
+ ranked = sorted(zip(scores, documents), reverse=True)
151
+ ```
152
+
153
+ To score a **page image** instead of a text passage, replace the user message with:
154
+
155
+ ```python
156
+ {"role": "user", "content": [
157
+ {"type": "image", "image": page_image}, # PIL.Image
158
+ {"type": "text", "text": VISION_TEMPLATE.format(query=query)}, # RERANKER_VISION_V2
159
+ ]}
160
+ ```
161
+
162
+ and pass `images=[page_image, ...]` to the processor call.
163
+
164
+ ### Serving with vLLM
165
+
166
+ ```bash
167
+ vllm serve lightonai/LightOn-rerank-PW-0.8B --trust-remote-code --max-model-len 16384
168
+ ```
169
+
170
+ ```python
171
+ resp = client.chat.completions.create(
172
+ model="lightonai/LightOn-rerank-PW-0.8B",
173
+ messages=messages, # same system + user messages as above
174
+ max_tokens=1,
175
+ logprobs=True,
176
+ top_logprobs=20,
177
+ temperature=0.0,
178
+ )
179
+ top = resp.choices[0].logprobs.content[0].top_logprobs
180
+ lp = {t.token: t.logprob for t in top}
181
+ score = lp.get("Yes", -100.0) - lp.get("No", -100.0)
182
+ ```
183
+
184
+ Full-page document images can exceed 8k tokens β€” keep `--max-model-len` at 16384 or higher when reranking page images.
185
+
186
+ ## Notes & limitations
187
+
188
+ - At 0.8B, pointwise Yes/No scoring cannot discriminate hard candidates: βˆ’0.10 NDCG@10 vs the listwise sibling on the same backbone, with French hit hardest. Prefer [LightOn-rerank-LW-0.8B](https://huggingface.co/lightonai/LightOn-rerank-LW-0.8B) at this size.
189
+ - Reranking a deeper candidate pool amplifies the weakness: overall @10 drops from 0.5030 (rerank-10) to 0.4820 (rerank-100).
190
+ - Training data is English-only. French works zero-shot (the backbone is multilingual) but is slightly behind English on average.
191
+ - Vision hard negatives were mined with ColPali-family retrievers; the model pairs best with a ColPali-family first stage (e.g. ColQwen2.5) for visual reranking.
192
+ - BEIR contamination flag: NQ and MSMARCO are part of the text training data; headline text figures use clean means that exclude them.
193
+
194
+ ## The LightOn-rerank family
195
+
196
+ | Model | Backbone | Scoring | ViDoRe V3 @10 |
197
+ |---|---|---|---|
198
+ | [LightOn-rerank-PW-0.8B](https://huggingface.co/lightonai/LightOn-rerank-PW-0.8B) | Qwen3.5-0.8B | pointwise | 0.4820 |
199
+ | [LightOn-rerank-LW-0.8B](https://huggingface.co/lightonai/LightOn-rerank-LW-0.8B) | Qwen3.5-0.8B | listwise | 0.5825 |
200
+ | [LightOn-rerank-PW-2B](https://huggingface.co/lightonai/LightOn-rerank-PW-2B) | Qwen3.5-2B | pointwise | 0.5987 |
201
+ | [LightOn-rerank-LW-2B](https://huggingface.co/lightonai/LightOn-rerank-LW-2B) | Qwen3.5-2B | listwise | 0.6266 |
202
+ | [LightOn-rerank-PW-4B](https://huggingface.co/lightonai/LightOn-rerank-PW-4B) | Qwen3.5-4B | pointwise | 0.5980 |
203
+ | [LightOn-rerank-LW-4B](https://huggingface.co/lightonai/LightOn-rerank-LW-4B) | Qwen3.5-4B | listwise | **0.6469** |
204
+
205
+ Rule of thumb: **LW** models are stronger at every size (and the gap grows with size); **PW** models are cheaper to serve and score candidates independently. For the best quality pick [LW-4B](https://huggingface.co/lightonai/LightOn-rerank-LW-4B); for the best quality/cost trade-off pick [LW-2B](https://huggingface.co/lightonai/LightOn-rerank-LW-2B); for maximum throughput on text-heavy workloads pick a PW model.