Skip to content
imaged

Text embeddings (sentence similarity)

all-MiniLM-L6-v2

Small, fast sentence embeddings for semantic search and similarity: 384 numbers per text from a 22-million-parameter model, the most used sentence-transformers model.

Apache-2.0sentence embeddingstext embeddingssemantic searchsentence-transformersminilmbertapache-2.0
Choose a variant

About this model

all-MiniLM-L6-v2 turns a sentence or short paragraph into 384 numbers that are close for texts with similar meaning, whatever the wording: "I forgot my login" lands near "How do I reset my password?". Use it to search documents, FAQs or notes by meaning, to group similar texts, or to find duplicates.

It is a 6-layer MiniLM (22 million parameters) fine-tuned by sentence-transformers on over a billion sentence pairs. The pack holds sentence-transformers' whole pipeline: the BERT 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.

Text up to 256 tokens (about 200 words) is read; Slab runs it at the shortest of five lengths (16, 32, 64, 128, 256 tokens) that holds it, which keeps short texts fast on the CPU.

What you can build

  • Search FAQs, help articles or notes by meaning
  • Find duplicate or near-duplicate texts
  • Group similar messages or reviews
  • Retrieve passages for a chatbot on the device

FAQ search: "I forgot my login"

f16
Input
I forgot my login
Output
The question against 8 FAQ entries, by cosine similarity, on Metal. Best two: "How do I reset my password?" (0.611); "How do I delete my account?" (0.467).

FAQ search: "does it work offline?"

f16
Input
does it work offline?
Output
The question against 8 FAQ entries, by cosine similarity, on Metal. Best two: "Can I use the app without an internet connection?" (0.524); "Where can I download my invoice?" (0.242).

FAQ search: "my phone gets hot and the battery dies"

f16
Input
my phone gets hot and the battery dies
Output
The question against 8 FAQ entries, by cosine similarity, on Metal. Best two: "Why is the app draining my battery?" (0.410); "How do I contact customer support?" (0.230).

FAQ search: "talk to a human"

f16
Input
talk to a human
Output
The question against 8 FAQ entries, by cosine similarity, on Metal. Best two: "How do I contact customer support?" (0.157); "How do I change the language of the app?" (0.105).

Sentence similarity

f16
Input
"A man is playing a guitar on stage." and "Someone performs music in front of an audience."
Output
Cosine similarity 0.495 on Metal.

Sentence similarity

f16
Input
"A man is playing a guitar on stage." and "The stock market closed lower today."
Output
Cosine similarity -0.034 on Metal.

Sentence similarity

f16
Input
"The cat sat on the mat." and "A cat is sitting on a rug."
Output
Cosine similarity 0.730 on Metal.

Sentence similarity

f16
Input
"Ein Hund läuft über die Wiese." and "A dog runs across the meadow."
Output
Cosine similarity 0.008 on Metal.

Variants & downloads

Choose the build for your app

Model files are hosted on Google Drive. Large files may open a confirmation page before downloading.

Small

Slab

Weights stored as int8 in blocks of 64, decoded to float when loading. About 45% smaller; similarities move by up to 0.005 (see Accuracy).

Platforms: macos · android

all-minilm-l6-v2-int8.slab

25.3 MB · Hosted download

Download
SHA-256 checksum
0c4f7b67c8311d9372d6f81def00710db4dab06c15888e925689a5a299b63aca

LICENSE-Apache-2.0.txt

11 KB

Download
SHA-256 checksum
b7cf03fd0295a0bc17c79a89d684711a11b57863e89889ddd6ec4c47a7b6fe09
Conversion details
command
hf download sentence-transformers/all-MiniLM-L6-v2 --revision 1110a243fdf4706b3f48f1d95db1a4f5529b4d41 --local-dir all-MiniLM-L6-v2 --include "*.json" --include model.safetensors python -c "import torch; from transformers import AutoModel; torch.set_grad_enabled(False); b = AutoModel.from_pretrained('all-MiniLM-L6-v2', attn_implementation='eager').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)), 'all-minilm-l6-v2.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; do slab-load convert all-minilm-l6-v2.onnx minilm-$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 minilm-$n.slab minilm-$n-int8.slab; done cp minilm-16-int8.slab all-minilm-l6-v2-int8.slab && slab-load buckets all-minilm-l6-v2-int8.slab minilm-32-int8.slab minilm-64-int8.slab minilm-128-int8.slab minilm-256-int8.slab slab-load tokenizer all-minilm-l6-v2-int8.slab all-MiniLM-L6-v2/tokenizer.json slab-load meta set all-minilm-l6-v2-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, "all-minilm-l6-v2-f16.slab")   # carries the tokenizer

def embed(text):
    return model.run(slab.Input(text=text))   # already unit length

question = embed("I forgot my login")
for faq in ("How do I reset my password?", "How do I delete my account?"):
    print(faq, round(question.cosine_similarity(embed(faq)), 3))

Device & backend compatibility

Pack default: macos / GPU. Fast at every length: 2.2 ms for a short text and 3.3 ms for 250 tokens, against 3.0 and 37.8 ms on the CPU.

Available execution backends for all-MiniLM-L6-v2
PlatformEngineStatusPrecision
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

2.7 ms

Measured time · scope below

int8Session open (ms): 138 Platform: macos Runs: 100 Input: 1, 16 (the shortest of five lengths) Measured: 2026-10-30

Input(text="a photo of a dog"), tokenizing included, median of 100 (runs at 16 tokens). A 250-token text (runs at 256): 38.9 ms median of 30. Peak memory after opening and one run: 150 MB.

Mac with Apple M1 Max

Slab · GPU

macOS 26.6.2

2.4 ms

Measured time · scope below

int8Session open (ms): 293 Platform: macos Runs: 100 Input: 1, 16 (the shortest of five lengths) Measured: 2026-10-30

Input(text="a photo of a dog"), tokenizing included, median of 100 (runs at 16 tokens). A 250-token text (runs at 256): 3.2 ms median of 30. Peak memory after opening and one run: 208 MB.

Samsung Galaxy S23 Ultra (Snapdragon 8 Gen 2)

Slab · CPU

Android 17

9.0 ms

Measured time · scope below

int8Session open (ms): 108 Platform: android Runs: 100 Input: 1, 16 (the shortest of five lengths) Measured: 2026-11-06

Input(text="a photo of a dog"), tokenizing included, median of 100. open_ms: opening the session. Peak memory (resident) after the runs: 136 MB. A 234-token text: 96.2 ms median of 30.

Samsung Galaxy S23 Ultra (Snapdragon 8 Gen 2)

Slab · GPU

Android 17

9.5 ms

Measured time · scope below

int8Session open (ms): 125 Platform: android Runs: 100 Input: 1, 16 (the shortest of five lengths) Measured: 2026-11-06

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: 181 MB. A 234-token text: 40.2 ms median of 30.

Accuracy checks

macos · CPU · int8

sentence-transformers 6.2 with the upstream model (its own tokenizer, mean pooling and normalization) on 46 texts: 23 sentence pairs (paraphrases, unrelated pairs, German and French, accents, emoji, a 300-word text)

Cosine similarity to the upstream embedding 0.999751 on average, 0.998913 at worst. Pair similarities within 0.0049 of upstream; their order agrees (rank correlation 0.9990).

macos · GPU · int8

sentence-transformers 6.2 with the upstream model (its own tokenizer, mean pooling and normalization) on 46 texts: 23 sentence pairs (paraphrases, unrelated pairs, German and French, accents, emoji, a 300-word text)

Cosine similarity to the upstream embedding 0.999751 on average, 0.998913 at worst. Pair similarities within 0.0049 of upstream; their order agrees (rank correlation 0.9990).

Before you choose this model

  • Trained on English; other languages work poorly.
  • Text beyond 256 tokens (about 200 words) is cut: embed long documents in pieces.
  • Similarity reflects topic and meaning, not facts: "The bank raised rates" and "The river bank flooded" share words but not meaning, and the model can still score them fairly close.
  • Slab tokenizes as Hugging Face's tokenizer does, except for combining marks added to Unicode after 2016, which Hugging Face's BERT normalizer does not know (Slab strips them as accents; Hugging Face keeps them as unknown tokens).
  • Token ids are not accepted by Slab's Neural Engine path: it runs on the GPU or CPU.