Text embeddings (multilingual search)
multilingual-e5-small
Sentence embeddings in about 100 languages: search, compare and group texts by meaning across languages, with a question in one language finding text in another. 384 numbers per text. MIT.
About this model
multilingual-e5-small turns a sentence or passage into 384 numbers that are close for texts with similar meaning, in about 100 languages and across them: an English question finds the Arabic note that answers it. Use it to search documents, notes or help articles by meaning whatever language they are in, to group similar texts, or to retrieve passages for a chatbot on the device.
It is Microsoft's E5 model: a 12-layer encoder initialized from Multilingual MiniLM, with XLM-RoBERTa's vocabulary of 250,000 tokens (96 of its 118 million parameters), trained on a billion multilingual text pairs and then on labeled retrieval data. The pack holds the whole pipeline: the SentencePiece tokenizer (carried in the pack, so the app passes plain text), the model, the mean of the token embeddings and normalization, so the output is the finished, unit-length embedding.
E5 expects a prefix on every text: "query: " for searches and "passage: " for the documents searched; for similarity between texts of the same kind, "query: " on both. Text up to 512 tokens is read; Slab runs it at the shortest of six lengths (16, 32, 64, 128, 256, 512 tokens) that holds it, and the six share one copy of the weights.
What you can build
- Search notes, documents or help articles in any language with a question in any language
- Retrieve passages for a chatbot on the device, in the user's language
- Find duplicates and group similar messages across languages
- Match product names or support tickets written in several languages
A question in English over notes in nine languages
f16Where can I get a SIM card?
"query: " + the question against 9 travel notes, each in another language and embedded with "passage: ", by cosine similarity, on Metal. Best two: Arabic: "يمكنك شراء شريحة اتصال محلية من أي متجر في المطار بجواز سفرك." (0.809); Japanese: "タクシーではチップは必要ありません。" (0.772). The best match is the Arabic note.
A question in Arabic over notes in nine languages
f16متى يفتح المتحف؟
"query: " + the question against 9 travel notes, each in another language and embedded with "passage: ", by cosine similarity, on Metal. Best two: English: "The museum is open from 9 am to 6 pm every day except Monday." (0.760); Chinese: "酒店的早餐从早上七点供应到十点。" (0.704). The best match is the English note.
A question in Japanese over notes in nine languages
f16空港から市内への電車はどのくらいの頻度で出ていますか?
"query: " + the question against 9 travel notes, each in another language and embedded with "passage: ", by cosine similarity, on Metal. Best two: Hindi: "हवाई अड्डे से शहर तक की ट्रेन हर 15 मिनट में चलती है।" (0.799); Japanese: "タクシーではチップは必要ありません。" (0.763). The best match is the Hindi note.
A question in French over notes in nine languages
f16Faut-il laisser un pourboire au chauffeur de taxi ?
"query: " + the question against 9 travel notes, each in another language and embedded with "passage: ", by cosine similarity, on Metal. Best two: Japanese: "タクシーではチップは必要ありません。" (0.821); Arabic: "يمكنك شراء شريحة اتصال محلية من أي متجر في المطار بجواز سفرك." (0.793). The best match is the Japanese note.
A question in Chinese over notes in nine languages
f16我需要买药,附近有药店吗?
"query: " + the question against 9 travel notes, each in another language and embedded with "passage: ", by cosine similarity, on Metal. Best two: Chinese: "酒店的早餐从早上七点供应到十点。" (0.830); Spanish: "La farmacia más cercana está en la calle Mayor, a cinco minutos a pie." (0.823). The Spanish note comes second, just behind a note in the question's own language; upstream ranks them the same way (see Limits).
A question in Spanish over notes in nine languages
f16¿Dónde puedo cambiar dinero?
"query: " + the question against 9 travel notes, each in another language and embedded with "passage: ", by cosine similarity, on Metal. Best two: French: "Le bureau de change se trouve au niveau des arrivées, à côté de la sortie B." (0.791); Spanish: "La farmacia más cercana está en la calle Mayor, a cinco minutos a pie." (0.785). The best match is the French note.
English and Arabic, the same sentence
f16"The meeting has been moved to Thursday." and "تم نقل الاجتماع إلى يوم الخميس."
Cosine similarity 0.908 on Metal (both with "query: ").
English and Chinese, the same sentence
f16"The meeting has been moved to Thursday." and "会议改到星期四了。"
Cosine similarity 0.847 on Metal (both with "query: ").
English and Swahili, the same sentence
f16"The meeting has been moved to Thursday." and "Mkutano umehamishwa hadi Alhamisi."
Cosine similarity 0.847 on Metal (both with "query: ").
Two unrelated English sentences
f16"The meeting has been moved to Thursday." and "Bananas are rich in potassium."
Cosine similarity 0.718 on Metal (both with "query: ").
Variants & downloads
Choose the build for your appModel files are hosted on Google Drive. Large files may open a confirmation page before downloading.
Small
SlabWeights stored as int8 in blocks of 64, decoded to float when loading. About 45% smaller; embeddings move slightly more, search results the same in our check (see Accuracy).
Platforms: macos · android
multilingual-e5-small-int8.slab
128 MB · Hosted download
SHA-256 checksum
2864ed62c02393b04f236d9c8a6e523e93b151527ec4cd22f36ba0a5b13b6335LICENSE-E5.txt
1 KB
SHA-256 checksum
0e083a96c3401c8bce28dcac95a197c03eecddb3adbd4f7b4ab960065156f9ffConversion details
- command
- hf download intfloat/multilingual-e5-small --revision 614241f622f53c4eeff9890bdc4f31cfecc418b3 --local-dir multilingual-e5-small --include "*.json" --include model.safetensors python -c "import torch; from transformers import AutoModel; torch.set_grad_enabled(False); b = AutoModel.from_pretrained('multilingual-e5-small', attn_implementation='eager', dtype=torch.float32).eval(); E = type('E', (torch.nn.Module,), {'forward': lambda s, input_ids, attention_mask, token_type_ids, position_ids: (lambda mk: torch.nn.functional.normalize((lambda h: (h * mk.unsqueeze(-1)).sum(1) / mk.unsqueeze(-1).sum(1).clamp(min=1e-9))(s.b.encoder(s.b.embeddings(input_ids=input_ids, token_type_ids=token_type_ids, position_ids=position_ids), attention_mask=(1.0 - mk[:, None, None, :]) * -10000.0).last_hidden_state), p=2, dim=1))(attention_mask.to(torch.float32))}); e = E(); e.b = b; z = torch.zeros(1, 16, dtype=torch.long); torch.onnx.export(e, (z, torch.ones(1, 16, dtype=torch.long), z, torch.arange(16).unsqueeze(0)), 'multilingual-e5-small.onnx', input_names=['input_ids', 'attention_mask', 'token_type_ids', 'position_ids'], output_names=['sentence_embedding'], opset_version=17, dynamo=False, dynamic_axes={k: {1: 'length'} for k in ['input_ids', 'attention_mask', 'token_type_ids', 'position_ids']})" for n in 16 32 64 128 256 512; do slab-load convert multilingual-e5-small.onnx me5-$n.slab --input input_ids=1x$n --input attention_mask=1x$n --input token_type_ids=1x$n --input position_ids=1x$n --meta task=embed && slab-load quantize me5-$n.slab me5-$n-int8.slab; done cp me5-16-int8.slab multilingual-e5-small-int8.slab && slab-load buckets multilingual-e5-small-int8.slab me5-32-int8.slab me5-64-int8.slab me5-128-int8.slab me5-256-int8.slab me5-512-int8.slab slab-load tokenizer multilingual-e5-small-int8.slab multilingual-e5-small/tokenizer.json slab-load meta set multilingual-e5-small-int8.slab default_backend.macos=gpu
Integration examples
Python
python
import slab
cfg = slab.Config(cache_dir="/tmp/slab_cache", license=open("license.slablic.txt").read())
model = slab.Session(cfg, "multilingual-e5-small-f16.slab") # carries the tokenizer
def embed(text):
return model.run(slab.Input(text=text)) # already unit length
notes = [
"The museum is open from 9 am to 6 pm every day except Monday.",
"Le bureau de change se trouve au niveau des arrivées, à côté de la sortie B.",
"La farmacia más cercana está en la calle Mayor, a cinco minutos a pie.",
"Kinder unter sechs Jahren fahren in Bussen und Straßenbahnen kostenlos.",
"يمكنك شراء شريحة اتصال محلية من أي متجر في المطار بجواز سفرك.",
]
stored = [embed("passage: " + n) for n in notes] # documents: "passage: "
question = embed("query: Where can I get a SIM card?") # searches: "query: "
best = max(range(len(notes)), key=lambda i: question.cosine_similarity(stored[i]))
print(notes[best])
Device & backend compatibility
Pack default: macos / GPU. About the same as the CPU for short texts (5.4 against 5.0 ms) and far faster for long ones: 8.9 ms for 304 tokens against 247 ms on the CPU.
| Platform | Engine | Status | Precision |
|---|---|---|---|
| apple | CPU CPU | Supported Measured on macOS. | f32 |
| apple | Metal GPU | Supported Measured on macOS. The default. | f32 |
| apple | Apple Neural Engine NPU | Not supported The pack takes token ids (int64), which Slab's Neural Engine path does not accept. | — |
| android | CPU CPU | Supported Measured on a Samsung Galaxy S23 Ultra (Snapdragon 8 Gen 2, Adreno 740), Android 17. | f32 |
| android | Vulkan GPU | Supported Measured on a Samsung Galaxy S23 Ultra (Snapdragon 8 Gen 2, Adreno 740), Android 17. | f32 |
Performance
Results depend on the device, runtime, and test conditions. Each measurement keeps its own context.
Mac with Apple M1 Max
Slab · CPU
macOS 26.6.2
5.1 ms
Measured time · scope below
Input(text="query: how much protein should a female eat") (12 tokens), tokenizing included, median of 100 (runs at 16 tokens). A 304-token text (runs at 512): 246.8 ms median of 30. Peak memory after opening and one run: 661 MB.
Mac with Apple M1 Max
Slab · GPU
macOS 26.6.2
5.3 ms
Measured time · scope below
Input(text="query: how much protein should a female eat") (12 tokens), tokenizing included, median of 100 (runs at 16 tokens). A 304-token text (runs at 512): 9.0 ms median of 30. Peak memory after opening and one run: 719 MB.
Samsung Galaxy S23 Ultra (Snapdragon 8 Gen 2)
Slab · CPU
Android 17
19.0 ms
Measured time · scope below
Input(text="a photo of a dog"), tokenizing included, median of 100. open_ms: opening the session. Peak memory (resident) after the runs: 596 MB. A 234-token text: 568 ms median of 18.
Samsung Galaxy S23 Ultra (Snapdragon 8 Gen 2)
Slab · GPU
Android 17
14.1 ms
Measured time · scope below
Input(text="a photo of a dog"), tokenizing included, median of 100. open_ms: opening the session with the GPU programs already in the cache folder (the first open on a device compiles them, about 0.3 s more). Peak memory (resident) after the runs: 604 MB. A 234-token text: 169 ms median of 30.
Accuracy checks
macos · CPU · int8
sentence-transformers 6.2 with the upstream model in float32 (its own tokenizer, mean pooling and normalization) on 89 texts: the same eight facts in 10 languages (English, French, Spanish, German, Arabic, Chinese, Japanese, Russian, Hindi, Turkish), eight questions in eight of them, and a 600-token text
Cosine similarity to the upstream embedding 0.9999355 on average, 0.9999026 at worst. Searching the 80 facts with each question finds the same top passage as upstream for 8 of 8, and a passage stating the right fact for 8 of 8 (upstream 8).
macos · GPU · int8
sentence-transformers 6.2 with the upstream model in float32 (its own tokenizer, mean pooling and normalization) on 89 texts: the same eight facts in 10 languages (English, French, Spanish, German, Arabic, Chinese, Japanese, Russian, Hindi, Turkish), eight questions in eight of them, and a 600-token text
Cosine similarity to the upstream embedding 0.9999355 on average, 0.9999027 at worst. Searching the 80 facts with each question finds the same top passage as upstream for 8 of 8, and a passage stating the right fact for 8 of 8 (upstream 8).
Before you choose this model
- Every text needs its prefix, "query: " or "passage: "; without it results get worse.
- Similarities sit in a narrow band: unrelated sentences score about 0.7 and translations of each other 0.85 to 0.9 (see Examples). Rank by similarity, or set a threshold from your own texts.
- Text in the question's own language gets a small pull: in our travel example a Chinese question about a pharmacy ranks a Chinese note about breakfast (0.830) just above the Spanish note about the pharmacy (0.823), as upstream does.
- Text beyond 512 tokens is cut: embed long documents in pieces.
- Quality differs by language: best for languages with much training text, weaker for low-resource ones (see the model card).
- Memory: the vocabulary is large; with the pack open and one run the process peaks at about 753 MB on the CPU and 819 MB on the GPU (see Benchmarks).
- Token ids are not accepted by Slab's Neural Engine path: it runs on the GPU or CPU.