The encoders crate is the fastest way to semantically embed text on CPU.1 We take a collection of state-of-the-art static embedding models, and compile them directly into Rust code. That means no downloading models at runtime, no GPU, no inference runtime, no Python... just nanosecond scale text embedding.
let query = encoders::encode_single("What is the capital of France?");
let docs = encoders::encode(["Paris is the capital of France.", "Tokyo is the capital of Japan."]);
for (doc, text) in docs.iter().zip(["Paris...", "Tokyo..."]) {
println!("{:.3} {text}", encoders::similarity(&query, doc));
}You can also configure encoders with a number of crate features for model selection, quantization, Matryoshka truncation (depending on a model's support for it), and parallelization (via rayon).
$ cargo add encoders
$ cargo add encoders --features='potion-retrieval-32m, int8, mrl-256, rayon'Encoders is fast. To give you an idea of just how fast, here's encoders with its default settings compared to a handful of other throughput-sensitive tasks (measured on an Apple M3 Pro CPU). If you're interested in learning how encoders is able to achieve this level of performance, check out the methodology section.
Warning
If you store embeddings from this crate, you should explicitly select model, quantization, and dimension features! We will change the default model and features between major versions as better models become available!
[dependencies]
encoders = { version = "3", features = ["bekko-static-v1-slim-32k", "mrl-256", "int8", "rayon"] }- Model. With none enabled you get the current default,
bekko-static-v1-slim-100ktruncated to 512 dimensions. Naming a model explicitly gets its native width. - Dimensions.
mrl-1024down tomrl-32truncates a Matryoshka-trained model to one of the widths it was trained at. Omit it for the model's native width; asking for a width a model was not trained at fails the build! - Internal Type.
int8is the default: a quarter the size of f32, with cosine agreement against f32 above 0.999 on multi-token text (so pretty much indistinguishable in practice).int16is half the size of f32 and closer still, andfloat32stores the weights unquantized. rayonmakesencodeparallel for large batches. This is only likely to improve performance if your workload is routinely encoding very large batches (a couple hundred or more inputs).std/alloc(default). Turn these off (default-features = false) to build this crate forno_stdenvironments: you can enable theallocfeature withoutstdto re-enable batch embedding if available;encode_singleandencode_intoare available otherwise.
The model hotchpotch/bekko-static-embedding-v1 represents the current state-of-the-art as far as static embedding. We've trained a family of models derived from this model to shrink the vocabulary (and thus the model size), specifically for use in encoders. These are multilingual models, trained with MRL so their vectors can be truncated (reducing vector and model size at the cost of embedding quality), and licensed MIT. Read all about it on HuggingFace.
| feature | vocab | languages | NanoBEIR-en | MNanoBEIR | size int8 / int16 / f32 |
|---|---|---|---|---|---|
bekko-static-embedding-v1 |
200k | 40 | 53.7 | 43.7 | 199 / 396 / 791 MiB |
bekko-static-v1-slim-100k (default, at mrl-512) |
100k | 25 | 52.9 | 43.0 | 100 / 198 / 396 MiB |
bekko-static-v1-slim-75k |
75k | 25 | 52.1 | 42.2 | 75 / 149 / 297 MiB |
bekko-static-v1-slim-50k |
50k | 25 | 50.2 | 40.4 | 50 / 99 / 198 MiB |
bekko-static-v1-slim-32k |
32k | 14 | 49.3 | 39.9 | 32 / 63 / 127 MiB |
Our smallest model, bekko-static-v1-slim-32k, covers English, Arabic, German, Spanish, French, Italian, Japanese, Korean, Norwegian, Portuguese, Serbian, Swedish, Thai, and Vietnamese. The larger models also support Bengali, Persian, Finnish, Hindi, Indonesian, Dutch, Russian, Swahili, Telugu, Yoruba, and Chinese.
Static models aligned with a transformer teacher, so an index built with the teacher can be queried with the static model. English language only, licensed MIT.
| feature | native width | teacher | size int8 / int16 / f32 |
|---|---|---|---|
nife-mxbai-embed-large-v1 |
1024 | mixedbread-ai/mxbai-embed-large-v1 | 108 / 214 / 427 MiB |
nife-gte-modernbert-base |
768 | Alibaba-NLP/gte-modernbert-base | 75 / 149 / 297 MiB |
Small, quick models distilled by MinishLab with their model2vec process: English only, licensed MIT.
| feature | native width | notes | size int8 / int16 / f32 |
|---|---|---|---|
blink-8m |
256 | general purpose, successor to potion-base-8m |
7.7 / 15 / 30 MiB |
potion-base-2m |
64 | general purpose | 2.1 / 3.9 / 7.6 MiB |
potion-base-4m |
128 | general purpose | 3.9 / 7.6 / 15 MiB |
potion-base-8m |
256 | general purpose | 7.6 / 15 / 29 MiB |
potion-base-32m |
512 | general purpose, larger vocabulary | 32 / 63 / 125 MiB |
potion-retrieval-32m |
512 | tuned for retrieval | 32 / 63 / 125 MiB |
potion-science-8m |
256 | scientific text | 7.6 / 15 / 29 MiB |
potion-science-32m |
256 | scientific text, larger vocabulary | 32 / 63 / 124 MiB |
potion-code-16m |
256 | source code; ships per-token weights, so use int16 or float32 |
16 / 31 / 62 MiB |
m2v-base-output |
256 | the original model2vec release, superseded by potion | 7.6 / 15 / 29 MiB |
We try to cover the spread as far as static embedding models, but if you have a static embedding model not yet included in this crate, please let us know! We are happy to add support for it.
Otherwise, check out the ese-build and ese crates, which can be used to deploy private and local models.
Trained by the sentence-transformers team with Matryoshka loss (see their write-up), licensed Apache-2.0.
| feature | notes | size int8 / int16 / f32 |
|---|---|---|
static-retrieval-mrl-en-v1 |
English, tuned for retrieval | 30 / 61 / 121 MiB |
static-similarity-mrl-multilingual-v1 |
multilingual, tuned for similarity rather than retrieval | 105 / 210 / 419 MiB |
Trained by Erik Kaunismäki with Matryoshka loss, building on static-retrieval-mrl-en-v1's recipe: English only, licensed MIT.
| feature | notes | size int8 / int16 / f32 |
|---|---|---|
lattice-retrieval |
English, tuned for retrieval | 30 / 61 / 121 MiB |
The idea behind encoders (and the crate that underpins it, ese) is simple: static embedding models are essentially lookup tables from token IDs to weights. Why not just resolve the tokens to their weights with a compile-time map? So, that's exactly what it does—with a lot of other performance-oriented tricks to boot!
The first chart here shows unbatched throughput on the question half of the GooAQ dataset (~43 bytes per query), one query per call, approximating query-side search workloads:
The second shows batched throughput on the answer half (generally much longer inputs, ~253 bytes a piece), approximating indexing workloads:
Build time. ese-build downloads the model, reads how it expects text to be tokenized and pooled from the model's own files, quantizes the weights, and writes them out as a perfect-hash table keyed by vocabulary entry. That table is compiled into your binary, so there is nothing to load or initialize at runtime.
Tokenization. ese reimplements the BERT tokenizer pipeline from Hugging Face's tokenizers crate as a single streaming pass that never allocates, with Unicode handled by precomputed tables in ese-unicode. That's a large part of why encoders can completely embed text faster than the tokenizers crate (and thus most models) can tokenize it, shown in the throughput benchmark above. The test suite checks the output against the real tokenizers crate for correctness' sake.
Lookup. Each token resolves to its weights with a single probe into the hash table, and WordPiece hashes every candidate piece of a word in one pass rather than one candidate at a time.
Quantization. Weights are stored as 8-bit integers by default, or 16-bit with int16, each dimension with its own scale. That quarters or halves the table, and the output stays nearly indistinguishable from full precision.
Pooling. Token weights are summed in integer registers, so each byte of the table is read once, and converted back to floating point once at the end. Sums drain into a running total every few hundred tokens, so there's no input length limit: a whole book embeds the same way a query does, and every token counts. You shouldn't embed a whole book, though... these are sentence level models!
Embedding quality. Encoders only works with static embedding models: each token has one fixed vector and a text is the mean of its tokens' vectors. There is no attention, so word order and context are invisible, and quality is a step below even small transformer encoders. On retrieval benchmarks the gap is real but not enormous; the bekko family scores about 49 to 54 on NanoBEIR against the low 60s for a small transformer. In exchange, embedding text runs in the order of nanoseconds instead of milliseconds. For a lot of (if not most) search, dedup, clustering, and routing work, that seems like the right trade (and we hope the speed makes up for the rest).
Binary size and compile time. The model's lookup table is embedded in your executable, so this can add a few MB (for a small model at a narrow width) up to a few hundred MB for a model large vocabulary at full width in f32. That said, any model needs its weights at runtime somehow; this crate just puts them in the binary rather than downloading/loading them at runtime. The first build of a model downloads it from the Hugging Face hub (into target/ese-cache, so it's cleaned up by cargo clean) and the final link of a large table takes a while. You also really, really need to compile this with optimizations on... give LLVM a chance to autovectorize!
Benchmarks showing encoders show performance at default model/dtype/mrl (ones labeled rayon enable that feature, too). The charts come from the bench crate (Criterion) and its Python companion, bench/py. The benchmark workloads run over questions/answers taken from the GooAQ dataset. To regenerate charts featured in this repo on your own machine:
$ uv run --project bench/py bench/py/charts.pyEncoders is brought to you by the folks at Flower Computer. If you like encoders, you'll definitely like some of our other work too! Keep up with what we're doing in these places:
- Our blog!
- @flowercomputers on GitHub
- @flowercomputers on Twitter
- @flowercomputers on HuggingFace
The code in this repo is licensed Apache-2.0. However, you must respect each model's license; model licenses are available at build time in the summary and at run time as encoders::model::LICENSE.
If you use encoders in your research, you can cite this repo with the BibTeX snippet below. But also, let us know! We'd love to hear from you.
@software{flowercomputer2026encoders,
author = {William Turner Abney},
title = {Encoders - Flower Computer},
url = {https://github.com/flowercomputers/encoders},
doi = {10.5281/zenodo.24023299},
publisher = {Zenodo},
year = 2026,
}Footnotes
-
Any person wishing to dispute this claim is invited to either: challenge the Flower Computer team to hand-to-hand combat at our office in Brooklyn, New York, OR create an issue on this repository referencing relevant benchmarks. ↩




