Image-Text-to-Text
Transformers
Safetensors
English
French
qwen3_5
reranker
cross-encoder
multimodal
text-ranking
document-reranking
vidore
beir
conversational
🇪🇺 Region: EU
Instructions to use lightonai/LightOn-rerank-LW-4B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use lightonai/LightOn-rerank-LW-4B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="lightonai/LightOn-rerank-LW-4B") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("lightonai/LightOn-rerank-LW-4B") model = AutoModelForMultimodalLM.from_pretrained("lightonai/LightOn-rerank-LW-4B", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use lightonai/LightOn-rerank-LW-4B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "lightonai/LightOn-rerank-LW-4B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "lightonai/LightOn-rerank-LW-4B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/lightonai/LightOn-rerank-LW-4B
- SGLang
How to use lightonai/LightOn-rerank-LW-4B with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "lightonai/LightOn-rerank-LW-4B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "lightonai/LightOn-rerank-LW-4B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "lightonai/LightOn-rerank-LW-4B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "lightonai/LightOn-rerank-LW-4B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use lightonai/LightOn-rerank-LW-4B with Docker Model Runner:
docker model run hf.co/lightonai/LightOn-rerank-LW-4B
Model card edits: hero image, nDCG@10 table headers, BEIR results section, decontaminated wording
Browse files- .gitattributes +1 -0
- README.md +20 -17
- rerank.png +3 -0
.gitattributes
CHANGED
|
@@ -34,3 +34,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
rerank.png filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
|
@@ -40,6 +40,10 @@ tags:
|
|
| 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
|
|
@@ -50,16 +54,16 @@ The models are built on Qwen3.5 vision-language backbones (hybrid linear + full
|
|
| 50 |
|
| 51 |
The family comes in two scoring flavours × three sizes (0.8B / 2B / 4B):
|
| 52 |
|
| 53 |
-
- **PW (pointwise)**
|
| 54 |
-
- **LW (listwise)**
|
| 55 |
|
| 56 |
-
**LightOn-rerank-LW-4B** is the strongest model of the family: on ViDoRe V3 it outperforms the official Qwen3-VL-Reranker-8B (0.6469 vs 0.6423
|
| 57 |
|
| 58 |
## Results
|
| 59 |
|
| 60 |
-
**ViDoRe V3** (visual document reranking, 8 domains × EN/FR queries),
|
| 61 |
|
| 62 |
-
| Model | Params | Scoring | ViDoRe V3 overall @10 |
|
| 63 |
|---|---|---|---|
|
| 64 |
| **LightOn-rerank-LW-4B (this model)** | 4.5B | listwise | **0.6469** |
|
| 65 |
| *Qwen3-VL-Reranker-8B* | *8B* | *pointwise (pooling)* | *0.6423* |
|
|
@@ -71,7 +75,7 @@ The family comes in two scoring flavours × three sizes (0.8B / 2B / 4B):
|
|
| 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](https://huggingface.co/lightonai/LightOn-rerank-PW-0.8B) | 0.85B | pointwise | 0.4820 |
|
| 73 |
|
| 74 |
-
### ViDoRe V3 detail (
|
| 75 |
|
| 76 |
| Domain | EN @5 | EN @10 | FR @5 | FR @10 |
|
| 77 |
|---|---|---|---|---|
|
|
@@ -85,25 +89,25 @@ The family comes in two scoring flavours × three sizes (0.8B / 2B / 4B):
|
|
| 85 |
| physics | 0.4690 | 0.4918 | 0.4554 | 0.4920 |
|
| 86 |
| **mean** | **0.6436** | **0.6569** | **0.6226** | **0.6369** |
|
| 87 |
|
| 88 |
-
Overall @10: **0.6469** (EN 0.6569 / FR 0.6369)
|
| 89 |
|
| 90 |
-
###
|
| 91 |
|
| 92 |
-
|
| 93 |
|
| 94 |
## Model Details
|
| 95 |
|
| 96 |
-
- **Model type:** multimodal cross-encoder reranker
|
| 97 |
- **Base model:** [Qwen/Qwen3.5-4B](https://huggingface.co/Qwen/Qwen3.5-4B) (Qwen3.5 hybrid linear + full attention VLM)
|
| 98 |
- **Parameters:** ≈4.5B (bfloat16, 9.1 GB)
|
| 99 |
-
- **Inputs:** query (text) + candidate document(s)
|
| 100 |
-
- **Fine-tuning:** joint text+vision LoRA (r=32, α=32, rsLoRA
|
| 101 |
- **Data:** gold ranking permutations built from labelled pos/hard-neg structure (no teacher): 107k text groups (NQ, TriviaQA, MSMARCO) + 106k visual query–page groups (ColPali-family hard negatives at ranks [0, 5, 10])
|
| 102 |
- **Languages:** English (training), French (zero-shot transfer)
|
| 103 |
- **Requirements:** `transformers >= 5.4.0` (`qwen3_5` architecture)
|
| 104 |
- **Internal experiment ID:** `exp39`
|
| 105 |
|
| 106 |
-
## Usage
|
| 107 |
|
| 108 |
The model ranks **4 candidates per prompt** by generating a permutation string such as `[2] > [1] > [4] > [3]`. Candidate pools larger than 4 are ranked with a sliding window (window 4, stride 2) moving from the bottom of the list to the top, so the best candidates bubble up to the front. If a generation cannot be parsed, fall back to the input order (observed fallback rate in our evals: ≈0.01%).
|
| 109 |
|
|
@@ -116,7 +120,7 @@ model_id = "lightonai/LightOn-rerank-LW-4B"
|
|
| 116 |
model = AutoModelForImageTextToText.from_pretrained(
|
| 117 |
model_id,
|
| 118 |
dtype=torch.bfloat16,
|
| 119 |
-
attn_implementation="flash_attention_2", # optional
|
| 120 |
device_map="cuda",
|
| 121 |
).eval()
|
| 122 |
processor = AutoProcessor.from_pretrained(model_id)
|
|
@@ -192,12 +196,11 @@ If a window has fewer than 4 candidates, pad it by repeating the last candidate
|
|
| 192 |
|
| 193 |
- **Prepend an empty thinking block to the assistant turn.** Qwen3.5-4B is a thinking model; without the `<think>\n\n</think>\n\n` prefix (already included in the snippets above), reasoning tokens consume the generation budget and the ranking permutation never appears.
|
| 194 |
- Training data is English-only. French works zero-shot (the backbone is multilingual) but is slightly behind English on average.
|
| 195 |
-
-
|
| 196 |
-
- BEIR contamination flag: NQ and MSMARCO are part of the text training data; headline text figures use clean means that exclude them.
|
| 197 |
|
| 198 |
## The LightOn-rerank family
|
| 199 |
|
| 200 |
-
| Model | Backbone | Scoring | ViDoRe V3 @10 |
|
| 201 |
|---|---|---|---|
|
| 202 |
| [LightOn-rerank-PW-0.8B](https://huggingface.co/lightonai/LightOn-rerank-PW-0.8B) | Qwen3.5-0.8B | pointwise | 0.4820 |
|
| 203 |
| [LightOn-rerank-LW-0.8B](https://huggingface.co/lightonai/LightOn-rerank-LW-0.8B) | Qwen3.5-0.8B | listwise | 0.5825 |
|
|
|
|
| 40 |
<a href="https://huggingface.co/lightonai/LightOn-rerank-LW-4B">LW-4B</a>
|
| 41 |
</p>
|
| 42 |
|
| 43 |
+
<div align="center">
|
| 44 |
+
<img src="rerank.png" alt="Reranking: the second stage that puts the best text and image candidates on top" width="560">
|
| 45 |
+
</div>
|
| 46 |
+
|
| 47 |
---
|
| 48 |
|
| 49 |
## About the LightOn-rerank family
|
|
|
|
| 54 |
|
| 55 |
The family comes in two scoring flavours × three sizes (0.8B / 2B / 4B):
|
| 56 |
|
| 57 |
+
- **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 and no generation, so it is simple to serve (vLLM-compatible) and embarrassingly parallel.
|
| 58 |
+
- **LW (listwise)**: generative listwise ranking, where 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.
|
| 59 |
|
| 60 |
+
**LightOn-rerank-LW-4B** is the strongest model of the family: on ViDoRe V3 it outperforms the official Qwen3-VL-Reranker-8B (0.6469 vs 0.6423 nDCG@10) at half the parameter count, winning 14 of 16 domain×language splits against our 2B listwise model, with French gaining even more than English.
|
| 61 |
|
| 62 |
## Results
|
| 63 |
|
| 64 |
+
**ViDoRe V3** (visual document reranking, 8 domains × EN/FR queries), overall 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.
|
| 65 |
|
| 66 |
+
| Model | Params | Scoring | ViDoRe V3 overall nDCG@10 |
|
| 67 |
|---|---|---|---|
|
| 68 |
| **LightOn-rerank-LW-4B (this model)** | 4.5B | listwise | **0.6469** |
|
| 69 |
| *Qwen3-VL-Reranker-8B* | *8B* | *pointwise (pooling)* | *0.6423* |
|
|
|
|
| 75 |
| [LightOn-rerank-LW-0.8B](https://huggingface.co/lightonai/LightOn-rerank-LW-0.8B) | 0.85B | listwise | 0.5825 |
|
| 76 |
| [LightOn-rerank-PW-0.8B](https://huggingface.co/lightonai/LightOn-rerank-PW-0.8B) | 0.85B | pointwise | 0.4820 |
|
| 77 |
|
| 78 |
+
### ViDoRe V3 detail (nDCG, ColQwen2.5 first stage, rerank-100, sliding window 4/2)
|
| 79 |
|
| 80 |
| Domain | EN @5 | EN @10 | FR @5 | FR @10 |
|
| 81 |
|---|---|---|---|---|
|
|
|
|
| 89 |
| physics | 0.4690 | 0.4918 | 0.4554 | 0.4920 |
|
| 90 |
| **mean** | **0.6436** | **0.6569** | **0.6226** | **0.6369** |
|
| 91 |
|
| 92 |
+
Overall nDCG@10: **0.6469** (EN 0.6569 / FR 0.6369), the best result under this protocol, above the official Qwen3-VL-Reranker-8B (0.6423) at half the parameters.
|
| 93 |
|
| 94 |
+
### BEIR results (text reranking)
|
| 95 |
|
| 96 |
+
13 datasets, nDCG@10, BM25 first stage, retrieve 100 / rerank 100, sliding window 4/2. Mean **0.4808**; decontaminated mean (11 datasets, excluding NQ and MSMARCO) **0.4833**. Strongest datasets: fever 0.7928, scifact 0.7660, hotpotqa 0.7304, trec-covid 0.7152. Text gains over the 2B listwise model are modest (+0.003 decontaminated mean on the 8-dataset overlap): the scale-up pays off mainly on visual reranking.
|
| 97 |
|
| 98 |
## Model Details
|
| 99 |
|
| 100 |
+
- **Model type:** multimodal cross-encoder reranker (**generative listwise**: 4 candidates per prompt, ranked by generating a permutation; sliding window (4, stride 2) for larger pools)
|
| 101 |
- **Base model:** [Qwen/Qwen3.5-4B](https://huggingface.co/Qwen/Qwen3.5-4B) (Qwen3.5 hybrid linear + full attention VLM)
|
| 102 |
- **Parameters:** ≈4.5B (bfloat16, 9.1 GB)
|
| 103 |
+
- **Inputs:** query (text) + candidate document(s): text passage **or** page image
|
| 104 |
+
- **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 5e-5, warmup 30%, 1 epoch (419 steps)
|
| 105 |
- **Data:** gold ranking permutations built from labelled pos/hard-neg structure (no teacher): 107k text groups (NQ, TriviaQA, MSMARCO) + 106k visual query–page groups (ColPali-family hard negatives at ranks [0, 5, 10])
|
| 106 |
- **Languages:** English (training), French (zero-shot transfer)
|
| 107 |
- **Requirements:** `transformers >= 5.4.0` (`qwen3_5` architecture)
|
| 108 |
- **Internal experiment ID:** `exp39`
|
| 109 |
|
| 110 |
+
## Usage: generative listwise reranking
|
| 111 |
|
| 112 |
The model ranks **4 candidates per prompt** by generating a permutation string such as `[2] > [1] > [4] > [3]`. Candidate pools larger than 4 are ranked with a sliding window (window 4, stride 2) moving from the bottom of the list to the top, so the best candidates bubble up to the front. If a generation cannot be parsed, fall back to the input order (observed fallback rate in our evals: ≈0.01%).
|
| 113 |
|
|
|
|
| 120 |
model = AutoModelForImageTextToText.from_pretrained(
|
| 121 |
model_id,
|
| 122 |
dtype=torch.bfloat16,
|
| 123 |
+
attn_implementation="flash_attention_2", # optional, remove if flash-attn is not installed
|
| 124 |
device_map="cuda",
|
| 125 |
).eval()
|
| 126 |
processor = AutoProcessor.from_pretrained(model_id)
|
|
|
|
| 196 |
|
| 197 |
- **Prepend an empty thinking block to the assistant turn.** Qwen3.5-4B is a thinking model; without the `<think>\n\n</think>\n\n` prefix (already included in the snippets above), reasoning tokens consume the generation budget and the ranking permutation never appears.
|
| 198 |
- Training data is English-only. French works zero-shot (the backbone is multilingual) but is slightly behind English on average.
|
| 199 |
+
- BEIR contamination flag: NQ and MSMARCO are part of the text training data; headline text figures use decontaminated means that exclude them.
|
|
|
|
| 200 |
|
| 201 |
## The LightOn-rerank family
|
| 202 |
|
| 203 |
+
| Model | Backbone | Scoring | ViDoRe V3 overall nDCG@10 |
|
| 204 |
|---|---|---|---|
|
| 205 |
| [LightOn-rerank-PW-0.8B](https://huggingface.co/lightonai/LightOn-rerank-PW-0.8B) | Qwen3.5-0.8B | pointwise | 0.4820 |
|
| 206 |
| [LightOn-rerank-LW-0.8B](https://huggingface.co/lightonai/LightOn-rerank-LW-0.8B) | Qwen3.5-0.8B | listwise | 0.5825 |
|
rerank.png
ADDED
|
Git LFS Details
|