File size: 12,283 Bytes
6eb054e
 
 
 
 
 
72f6f0e
 
6eb054e
 
 
 
 
 
 
 
 
 
 
69288b1
 
8fd6ce1
69288b1
 
 
 
 
8fd6ce1
6eb054e
 
 
69288b1
 
 
 
8fd6ce1
69288b1
 
6eb054e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
815b2dd
6eb054e
 
9c903f6
6eb054e
 
 
 
815b2dd
6eb054e
 
815b2dd
 
6eb054e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
815b2dd
 
6eb054e
 
 
815b2dd
 
6eb054e
 
 
815b2dd
 
6eb054e
815b2dd
6eb054e
 
815b2dd
 
 
 
 
6eb054e
815b2dd
 
 
 
6eb054e
 
 
 
 
 
 
815b2dd
 
6eb054e
 
 
 
815b2dd
 
6eb054e
 
 
815b2dd
 
6eb054e
 
815b2dd
6eb054e
 
 
 
 
815b2dd
 
6eb054e
 
 
 
72f6f0e
815b2dd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6eb054e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
248ea00
 
 
 
8fd6ce1
248ea00
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
---
license: cc-by-nc-4.0
library_name: transformers
pipeline_tag: feature-extraction
base_model:
- Qwen/Qwen3.5-4B-Base
datasets:
- UCSC-VLAA/OpenEmbed-Data
tags:
- multimodal-embedding
- image-text-retrieval
- visual-document-retrieval
- sentence-transformers
language:
- en
---

# OpenEmbed-4B

<p align="center">
  <a href="https://ucsc-vlaa.github.io/OpenEmbed/"><b>🌐 Project page</b></a> &nbsp;·&nbsp;
  <a href="https://arxiv.org/abs/2612.02432"><b>📄 Paper</b></a> &nbsp;·&nbsp;
  <a href="https://github.com/UCSC-VLAA/OpenEmbed"><b>💻 Code</b></a> &nbsp;·&nbsp;
  <a href="https://huggingface.co/datasets/UCSC-VLAA/OpenEmbed-Data"><b>🗂️ Data</b></a> &nbsp;·&nbsp;
  <a href="https://colab.research.google.com/github/UCSC-VLAA/OpenEmbed/blob/main/examples/retrieval_demo.ipynb"><b>▶️ Colab demo</b></a>
</p>

OpenEmbed is a family of multimodal embedding models at 0.8B, 2B, 4B, and 9B parameters, released with their post-training data, training code, and cached teacher embeddings. As of December 2026, OpenEmbed-4B scores higher on both the image and the visual-document tracks than any model of its size or smaller on the [MMEB-V2 leaderboard](https://huggingface.co/spaces/TIGER-Lab/MMEB-Leaderboard) that releases its training data and training code. One model embeds text, images, visual documents, and image–text combinations into one space. Each input is formatted as a single user turn that ends with an `<embedding>` token, and the L2-normalized final hidden state at that token is the embedding (2,560 dimensions for OpenEmbed-4B).

OpenEmbed-4B is fine-tuned from [Qwen/Qwen3.5-4B-Base](https://huggingface.co/Qwen/Qwen3.5-4B-Base) in two stages. Stage 1 trains LoRA adapters on the language model and the vision tower with a contrastive loss over 109 curated datasets. Stage 2 widens the language-model adapters and adds decoupled distillation from cached embeddings of two open-weight teachers, Qwen3-VL-Embedding-8B and WeMM-Embedding-9B. The adapters are merged into the released weights.

<p align="center"><img src="assets/teaser.png" width="100%" alt="What leading embedding models release, MMEB-V2 image score by model size, and image and document retrieval against embedding APIs"></p>

<sub>(a) What leading embedding models release. (b) MMEB-V2 image score by model size; * reproduced by us. (c) DOCCI text-to-image R@1 and ViDoRe V3 nDCG@10 (8 public sets, English queries); r: reported results, p: recomputed from public per-query results, others measured by us.</sub>

- **Paper:** OpenEmbed: A Family of Frontier Multimodal Embedding Models with Open Data, Code, and Weights ([arXiv:2612.02432](https://arxiv.org/abs/2612.02432))
- **Training data and teacher embeddings:** [UCSC-VLAA/OpenEmbed-Data](https://huggingface.co/datasets/UCSC-VLAA/OpenEmbed-Data)
- **Training and evaluation code:** [UCSC-VLAA/OpenEmbed](https://github.com/UCSC-VLAA/OpenEmbed)
- **Models:** [OpenEmbed-0.8B](https://huggingface.co/UCSC-VLAA/OpenEmbed-0.8B) · [OpenEmbed-2B](https://huggingface.co/UCSC-VLAA/OpenEmbed-2B) · [OpenEmbed-4B](https://huggingface.co/UCSC-VLAA/OpenEmbed-4B) · [OpenEmbed-9B](https://huggingface.co/UCSC-VLAA/OpenEmbed-9B)

## Results

MMEB-V2: 36 image tasks (Hit@1; CLS: classification, VQA: visual question answering, RET: retrieval, GRD: grounding) and 24 visual-document retrieval tasks (VisDoc, nDCG@5). Evaluated with the official Qwen3-VL-Embedding MMEB-V2 evaluation code and the input format described below; the patch that applies this format is part of the code release.

| Model | CLS | VQA | RET | GRD | Image | VisDoc |
|---|---:|---:|---:|---:|---:|---:|
| OpenEmbed-0.8B | 67.9 | 74.2 | 74.2 | 96.5 | 74.9 | 78.5 |
| OpenEmbed-2B | 74.1 | 77.8 | 78.1 | 97.5 | 79.1 | 80.5 |
| **OpenEmbed-4B** | **74.5** | **80.5** | **79.8** | **97.3** | **80.5** | **81.6** |
| OpenEmbed-9B | 75.7 | 81.0 | 80.1 | 97.6 | 81.1 | 82.4 |

## Usage

No remote code is needed. Tested with transformers 5.2.0 and 5.23.0, sentence-transformers 5.7.0 and 6.3.0 (torch 2.8.0), and vLLM 0.34.0.

```bash
pip install torch torchvision "transformers>=5.15.0" "sentence-transformers>=5.7.0"
```

### Input format

OpenEmbed was trained and evaluated with WeMM-Embedding's input format, which the repository's chat template renders:

- Each input is one user turn with no system turn. Images come first, followed by one text item that holds the instruction and the text, joined by a space.
- The tokenizer appends the `<embedding>` token. The embedding is the L2-normalized last hidden state at that token, the last non-padding position (keep the default right padding).
- Images are resized to between 65,536 and 8,388,608 pixels, the bounds of training and evaluation and the processor's defaults. Scores move with the image budget, so keep them.

Instructions used in training and in MMEB-V2:

| Task | Query | Candidate |
|---|---|---|
| Caption → image | `Find me an everyday image that matches the given caption: <caption>` | image + `Represent the given image.` |
| Image → caption | image + `Find an image caption describing the given everyday image.` | caption text |
| Classification | image + `Represent the given image for classification` | class name |
| Visual question answering | image + `Represent the given image with the following question: <question>` | answer text |
| Composed image retrieval | image + `Given an image, find a similar everyday image with the described changes: <modification>` | image + `Represent the given image.` |
| Document page retrieval | `Find a document image that matches the given query. <query>` | page image, no text |

### Transformers

```python
import torch
import torch.nn.functional as F
from PIL import Image
from transformers import AutoModel, AutoProcessor

model_id = "UCSC-VLAA/OpenEmbed-4B"
processor = AutoProcessor.from_pretrained(model_id, use_fast=False)
model = AutoModel.from_pretrained(model_id, dtype=torch.bfloat16).cuda().eval()


def embed(inputs):
    """inputs: dicts with an optional "image" (a PIL.Image) and an optional "text"."""
    texts, images = [], []
    for x in inputs:
        content = [{"type": "image"}] if x.get("image") is not None else []
        if x.get("text") or not content:
            content.append({"type": "text", "text": x.get("text", "")})
        texts.append(processor.apply_chat_template([{"role": "user", "content": content}], tokenize=False))
        if x.get("image") is not None:
            images.append(x["image"])
    batch = processor(text=texts, images=images or None, padding=True, return_tensors="pt").to(model.device)
    model.rope_deltas = None  # transformers < 5.15 would reuse the last image batch's value
    with torch.inference_mode():
        hidden = model(**batch).last_hidden_state
    last = batch["attention_mask"].sum(dim=1) - 1  # the <embedding> token
    rows = torch.arange(hidden.size(0), device=hidden.device)
    return F.normalize(hidden[rows, last].float(), dim=-1)  # shape (len(inputs), 2560)


queries = embed([
    {"text": "Find me an everyday image that matches the given caption: A brown dog running on a beach."},
    {"text": "Find a document image that matches the given query. What was the revenue in 2023?"},
])
candidates = embed([
    {"image": Image.open("dog.jpg"), "text": "Represent the given image."},
    {"image": Image.open("annual_report_page.png")},
])
print(queries @ candidates.T)
```

`use_fast=False` resizes images with PIL, as our evaluation did. The default (torchvision) processor works too and gives embeddings within a cosine of 0.999 of these.

### Sentence Transformers

```python
import torch
from PIL import Image
from sentence_transformers import SentenceTransformer

model = SentenceTransformer("UCSC-VLAA/OpenEmbed-4B", model_kwargs={"dtype": torch.bfloat16})
queries = model.encode([
    "Find me an everyday image that matches the given caption: A brown dog running on a beach.",
    "Find a document image that matches the given query. What was the revenue in 2023?",
])
candidates = model.encode([
    {"image": Image.open("dog.jpg"), "text": "Represent the given image."},
    {"image": Image.open("annual_report_page.png")},
])
print(model.similarity(queries, candidates))
```

Add `processor_kwargs={"use_fast": False}` to resize images exactly as our evaluation did. Use transformers 5.15 or later with Sentence Transformers: older versions keep the position offsets of the last batch with images and can fail on a later batch without images.

### vLLM

```bash
hf download UCSC-VLAA/OpenEmbed-4B --local-dir OpenEmbed-4B
vllm serve OpenEmbed-4B --runner pooling --chat-template OpenEmbed-4B/embedding_chat_template.jinja \
  --limit-mm-per-prompt.video=0
```

```python
import base64
import requests


def image_url(path):
    return "data:image/jpeg;base64," + base64.b64encode(open(path, "rb").read()).decode()


response = requests.post("http://localhost:8000/v1/embeddings", json={
    "model": "OpenEmbed-4B",
    "messages": [{"role": "user", "content": [
        {"type": "image_url", "image_url": {"url": image_url("dog.jpg")}},
        {"type": "text", "text": "Represent the given image."},
    ]}],
    "encoding_format": "float",
})
embedding = response.json()["data"][0]["embedding"]
```

We ran it on a 24 GB card with `--max-model-len 16384` added. `--limit-mm-per-prompt.video=0` leaves out video inputs, which OpenEmbed was not trained on, and the memory vLLM would set aside for them.

### How close each path is to our evaluation

We compared each path with the embeddings of our evaluation (the official evaluation code, transformers 5.2.0) on nine inputs: three texts, three images with text, a document page, and an image above and one below the pixel bounds. The Transformers code above produced the evaluation's token ids and image grids for every input. Lowest cosine similarity per path:

| Path | Lowest cosine |
|---|---:|
| Transformers code above, transformers 5.2.0 | 0.999999 |
| Transformers code above, transformers 5.23.0 | 0.9996 |
| Sentence Transformers 5.7.0 (transformers 5.2.0) | 0.9995 |
| Sentence Transformers 6.3.0 (transformers 5.23.0) | 0.9996 |
| vLLM 0.34.0 | 0.9993 |

The rest comes from the numerics of later library versions and from the default image processor's resizing.

`trust_remote_code=True` still loads WeMM-Embedding's class (`modeling_wemm_embedding.py`, which the evaluation code reads); its `embedding` method computes the same embedding.

## Training

| | |
|---|---|
| Base model | [Qwen/Qwen3.5-4B-Base](https://huggingface.co/Qwen/Qwen3.5-4B-Base) (revision `1001bb4d`) |
| Parameters | 4.54B (bfloat16) |
| Embedding dimension | 2,560 |
| Stage 1 | contrastive learning, LoRA (rank 64) on the language model and the vision tower, 109 curated datasets |
| Stage 2 | language-model LoRA widened to rank 256, decoupled distillation from cached teacher embeddings (Qwen3-VL-Embedding-8B for 51 datasets, WeMM-Embedding-9B for 24) |
| Hardware | TPU v5p, JAX |

Training images were capped at 1,024 visual tokens (1,280 for document pages); evaluation allows up to 8,192. The recipe files of all four sizes are in the code release.

## Limitations

- Encodes text, images, and document pages; not video or audio.
- Trails other models on MIEB's compositionality tasks; the training mixture includes no synthetic text-perturbed negatives.
- Stage 2 distills from open-weight teachers whose own post-training data are not public.
- Much of the training data comes from datasets licensed for non-commercial or research use only, or with no stated license (49% of the 2B model's stage-1 pairs); the weights are released for non-commercial use.

## License

The weights are licensed under [CC BY-NC 4.0](LICENSE). The model code, tokenizer, and processor files come from WeMM-Embedding (Apache-2.0), and the weights are derived from Qwen/Qwen3.5-4B-Base (Apache-2.0); see [NOTICE](NOTICE) and [third_party/](third_party).

## Citation

```bibtex
@article{liu2026openembed,
  title   = {{OpenEmbed}: A Family of Frontier Multimodal Embedding Models with Open Data, Code, and Weights},
  author  = {Liu, Yanqing and Zhang, Letian and Yao, Huaxiu and Zheng, Zeyu and Zhou, Yuyin and Xie, Cihang},
  journal = {arXiv preprint arXiv:2612.02432},
  year    = {2026}
}
```