Built-in CPU models¶
Crate open/crates/oliviadb-models, in process, candle (pure Rust, f32, CPU). Weights are
downloaded at pinned revisions with checked SHA-256 by tools/fetch-models.sh
(tools/models.json; licences in THIRD_PARTY.md, checked by tools/licenses.py).
| role | model | licence | parameters | files | RSS when loaded |
|---|---|---|---|---|---|
embedder, default (384 dims, CLS pooling, query instruction; oliviadb_models::default_embedder) |
BAAI/bge-small-en-v1.5 @ 5c38ec7c | MIT (model card and Hugging Face metadata at the pinned revision, checked 2026-12-01) | 33.4M | 134 MB | not measured |
| embedder, previous default (384 dims, mean pooling) | sentence-transformers/all-MiniLM-L6-v2 | Apache-2.0 | 22.7M | 91 MB | +101 MB |
| person, place and organisation names | dslim/bert-base-NER | MIT | 108M | 434 MB | +480 MB |
| embedder, other candidates (see "Choosing retrieval models") | BAAI/bge-base-en-v1.5; ibm-granite/granite-embedding-small-english-r2, granite-embedding-english-r2; microsoft/harrier-oss-v1-0.6b | MIT; Apache-2.0; MIT | 109M; 47.7M, 149M; 596M | 438 MB; 95 MB, 298 MB; 1192 MB | not measured |
cross-encoder reranker (on by default where models are loaded: oliviadb_models::default_reranker = L6 over the best rerank_top = 80 candidates; oliviadb-mcp --models --no-rerank or the benchmarks' oliviadb+norerank switch it off; library setting Config::reranker) |
cross-encoder/ms-marco-MiniLM-L6-v2, L12-v2; Alibaba-NLP/gte-reranker-modernbert-base | Apache-2.0 | 22.7M, 33.4M; 149.6M | 91 MB, 133 MB; 598 MB | not measured |
| prompt-injection classifier | protectai/deberta-v3-base-prompt-injection-v2 | Apache-2.0 | 184M | 746 MB | +557 MB |
| personal-data rules | OliviaDB (e-mail, phone, payment card with Luhn, IBAN with mod 97, IPv4, URL, dates) | AGPL-3.0 | — | — | — |
The design's defaults (EmbeddingGemma under the Gemma Terms of Use, GLiNER2 PII filter, mmBERT injection guard) are not used: the Gemma terms add use restrictions that AGPL-3.0 distribution does not allow, and the replacements above have candle implementations.
Measured (Apple M3 Max, release build, 2026-11-30)¶
cargo run --release -p oliviadb-models --example eval against public test sets; the
published score of the same model is the external oracle for the implementation.
| check | result | reference |
|---|---|---|
| embedder, STS-B test (mteb/stsbenchmark-sts, 1379 pairs), Spearman | 82.03 | 82.03 published for this model (MTEB STSBenchmark) |
| NER, CoNLL-2003 test (tner/conll2003), entity F1 (P 90.17, R 91.48) | 90.82 | 91.3 published for this model |
| injection, deepset/prompt-injections test (116 texts), threshold 0.5 | accuracy 0.672, precision 1.000, recall 0.367, F1 0.537 | — (this test set is multilingual and labels role-play prompts as injections; the model flags none of the benign texts but misses most of those) |
| injection, deepset/deberta-v3-base-injection (MIT, trained on the deepset train split) on the deepset test | accuracy 0.991, precision 1.000, recall 0.983 | in-domain |
| injection on jackhhao/jailbreak-classification test (400, out of domain for both): protectai | accuracy 0.925, precision 0.959, recall 0.823 (5 false positives of 259) | — |
| same, deepset model | accuracy 0.388, precision 0.365, recall 1.000 (245 false positives of 259) | — |
| PII rules, synthetic labelled set (2000 texts generated by OliviaDB, not a public benchmark) | precision 1.000, recall 1.000 | — |
| latency | p50 | p99 |
|---|---|---|
| embed one sentence | 8.2 ms | 14.2 ms |
| embed a ~100-word paragraph | 20.1 ms | — |
| NER, one CoNLL sentence | 40.3 ms | 238 ms |
| PII rules + NER, 30-word paragraph | 57.7 ms | — |
| PII rules only | 1.5 µs | — |
| injection score, one test text | 108 ms | 233 ms |
The NER and injection latencies are far above the design's targets (20–60 ms per paragraph, 5–15 ms per text), which assume int8 ONNX models of a smaller class; these are f32 models of base size. Next steps: quantization, a smaller guard model, batching.
Guard choice¶
A stronger guard was looked for among AGPL-compatible models: deepset's model reaches
recall 0.983 on the deepset test, but it was trained on that dataset's train split and
does not generalize: on an independent set it flags 245 of 259 benign prompts. The
cascade max(protectai, deepset) inherits that (same numbers as deepset alone on both
sets) at twice the latency (186 ms vs 93 ms p50). The default stays protectai v2 alone
(precision 0.96–1.00 on both sets, recall 0.37–0.82); Cascade is available for
deployments that prefer recall over false alarms. Neither model was tuned on any test
split. Better options to evaluate next: a model trained on a broader mix with an
independent test set, and quantized smaller guards for latency.
Use in memory¶
default_embedder(bge-small-en-v1.5, aBgeEmbedder) is the memoryEmbedder(vector channel of RECALL) thatoliviadb-mcp --modelsloads;MiniLm(the default until 2026-12) remains available. The cross-encoder is on by default wherever models are loaded (oliviadb-mcp --models, the benchmark examples'oliviadb): it costs about 1.1 s of CPU per recall (80 query-passage pairs at about 14 ms each on one CPU core; batched scoring helps on a GPU). Switch it off witholiviadb-mcp --no-rerank(benchmarks:oliviadb+norerank); a library user leavesConfig::rerankerunset.InjectionDetectorimplements the memoryTextGuard: episode text is scored when it is written; text with risk ≥ 0.5 is withheld from RECALL (a placeholder with its length) and shown only through an explicit expand, labelled as untrusted. A model failure counts as maximal risk.PiiDetectorimplements the memoryMentionFinder: people found in an episode with confidence ≥ 0.8 become (pseudonymized) entities in the episode's mention list; the episode is sealed under their keys too, so erasing such a person finds and shreds episodes that never declared them (testerasure_finds_undeclared_subjects). Detected mentions do not drive row predicates.
Test oliviadb-models/tests/models.rs runs both models inside memory (skipped without the
model files).
Choosing retrieval models (embedder and reranker for conversational memory)¶
Rule: the newest, most capable model that fits the constraints: licence compatible with AGPL-3.0 distribution (Apache-2.0, MIT), in process on CPU (candle, f32), size recorded. The survey was made on 2026-11-30 from the models' own cards and papers; scores are as each card reports them and are not comparable across columns (MTEB v1 retrieval = 15 BEIR datasets; "MTEB-v2 retrieval" = the 10-task v2 retrieval set).
| candidate | released | published retrieval score | licence | params | CPU latency per LoCoMo turn p50 / p99 (M3 Max, f32) | in OliviaDB |
|---|---|---|---|---|---|---|
| all-MiniLM-L6-v2 (default until 2026-12) | 2021 | MTEB retrieval 41.95 (MTEB arena metadata) | Apache-2.0 | 22.7M | 17.9 / 61 ms | yes |
| bge-small-en-v1.5 (default since 2026-12) | 2023-09 | MTEB-v2 retrieval 53.9 (Granite R2 card's table) | MIT | 33M | 34.8 / 83 ms | yes |
| bge-base-en-v1.5 | 2023-09 | MTEB retrieval 53.25 (gte-modernbert card's table) | MIT | 109M | 57.8 / 113 ms | yes |
| granite-embedding-small-english-r2 | 2025-07 | BEIR 50.9, MTEB-v2 retrieval 53.9 | Apache-2.0 | 47.7M | 22.7 / 47 ms | yes |
| granite-embedding-english-r2 | 2025-07 | BEIR 53.1, MTEB-v2 retrieval 56.4 | Apache-2.0 | 149M | 55.0 / 138 ms | yes |
| gte-modernbert-base | 2025-01 | MTEB retrieval 55.33 | Apache-2.0 | 149M | not run (same architecture and size as Granite R2, older) | no |
| Qwen3-Embedding-0.6B | 2025-06 | MTEB Eng v2 retrieval 61.83 | Apache-2.0 | 596M | not run (same architecture and cost as Harrier 0.6B) | no |
| harrier-oss-v1-0.6b | 2026-03 | MTEB v2 overall 69.0 (no retrieval column) | MIT | 596M | 247 / 719 ms | yes |
| harrier-oss-v1-270m | 2026-03 | MTEB v2 overall 66.5 | MIT | 268M | not run: Gemma-3 decoder; candle's Gemma-3 returns only language-model logits | no |
| EmbeddingGemma-300M | 2025 | MTEB v2 overall 69.67 (third-party survey) | Gemma terms | 308M | excluded by licence | no |
| jina-embeddings-v5-small | 2026 | n/a | CC BY-NC 4.0 | ~677M | excluded by licence | no |
| reranker | released | published score | licence | params | CPU latency per query-turn pair p50 / p99 | in OliviaDB |
|---|---|---|---|---|---|---|
| ms-marco-MiniLM-L6-v2 | 2021 | (MS MARCO cross-encoder, no BEIR column on card) | Apache-2.0 | 22.7M | 14.3 / 24 ms | yes |
| ms-marco-MiniLM-L12-v2 | 2021 | same | Apache-2.0 | 33.4M | 29.4 / 50 ms | yes (not evaluated) |
| gte-reranker-modernbert-base | 2025-01 | BEIR 56.19 (overview) / 56.73 (BEIR table) | Apache-2.0 | 149.6M | 66.3 / 160 ms | yes |
| mxbai-rerank-base-v2 | 2025-03 | BEIR 55.57 | Apache-2.0 | 494M (Qwen2.5 decoder) | not run | no |
| Qwen3-Reranker-0.6B | 2025-05 | BEIR ~ the mxbai/gte range in third-party tables | Apache-2.0 | 596M (decoder) | not run | no |
| bge-reranker-v2-m3 | 2024-03 | n/a on card | Apache-2.0 | 568M (XLM-R) | not run | no |
Choices and why:
* The most capable embedders by published score that candle can run with their hidden states are
Qwen3-architecture decoders (Harrier-0.6B, Qwen3-Embedding-0.6B). candle's Qwen3 hides the hidden
states behind its LM head and keeps a cache that cannot be reset, so DecoderEmbedder is a
forward pass written for one sequence (causal attention, last-token pooling, task instruction on
queries). Latency is 14x MiniLM's, which puts it on a write path of hundreds of milliseconds per
episode: usable for background ingestion, not for interactive writes.
* The reranker choice is the 149M ModernBERT cross-encoder (2025) over the 0.5-0.6B decoder
rerankers: same published BEIR range at a quarter of the size and no LLM-style prompt format.
* Every model was checked against the reference implementation (PyTorch with Hugging Face
transformers, float32) on the same files: cosine scores and logits agree to 1e-4 to 5e-4
(oliviadb-models/tests/retrieval_models.rs, reference values in the test). Which model wins on
conversational memory is a measured question: see docs/benchmarks.md, "Recall quality: development
set, second round". Latency: cargo run --release -p oliviadb-models --example retrieval_latency
(100 LoCoMo turns, one text at a time, no batching, a machine that was running other work).
Decision (2026-12-01): the default embedder is bge-small-en-v1.5 (MIT at the pinned revision
5c38ec7c, read from the model card and the Hugging Face API; recorded in tools/models.json and
THIRD_PARTY.md). On the LoCoMo development split it beat MiniLM and the 2025 embedders on recall
and on end-to-end accuracy (docs/benchmarks.md, docs/e2e-eval.md); it is 2x MiniLM's latency. The
ms-marco-MiniLM-L6 cross-encoder over the best 80 candidates is on by default (owner's decision
of 2026-12-01, after the partial test-set run: it was better than without on both test sets) at about
1.1 s of CPU per recall; it can be switched off. Test-set numbers of both configurations:
docs/e2e-eval.md.