All posts

AI Engineering

Before Replacing BM25 with CPU Embeddings: Same Score, Different Failures

A reproducible CPU run of bekko static embeddings against BM25: inspect query-level failures, word-order limits and the difference between vector size and model memory.

Published and maintained by Sambro · Report a correction

8 min read Static embeddingsBM25RAG retrievalCPU inference

What if a new search model leaves the score unchanged?

Before adding vector search to a small FAQ service, ask what it improves over the lexical baseline. Identical aggregate scores can hide different failures: one retriever misses payment retries while the other misses deployment recovery. Writing “75%” for both erases the difference a user experiences.

We ran the static model bekko-static-embedding-v1 on CPU on 12 self-authored Korean developer FAQs and eight queries. Both BM25 and the model found the single labeled document first in 6/8 cases and within the top three in 8/8. This is not a winner announcement. It is a small example of why replacement decisions need a query-level error review.

Separate the release facts from the author’s evaluation

Yuichi Tateno (hotchpotch) published the introduction on October 21, 2026 at 02:23 UTC, or 11:23 KST. It is an author post in the Hugging Face community, not an independent Hugging Face validation. Original: bekko static embedding — introduction

The MIT-licensed model averages token vectors without Transformer layers, targets 40 training languages including Korean, and has a default 1,024-dimensional output. Model card: bekko-static-embedding-v1 — model card

The author’s HAKARI-Bench comparison has BM25 ahead on 21 of 37 benchmark averages. The author also maintains HAKARI-Bench. A strong static-model result therefore does not establish that this model should replace BM25 for your documents. The card’s 100–400× speed reference comes from other static-embedding work; it is not a throughput measurement of this model.

What Sambro actually ran

On October 22, 2026 KST, we ran the published INT8 512-dimensional ONNX file with CPUExecutionProvider. We pinned revision c18167b8f244c1bc6de21ce9b710bac8a29c4615 and did not execute the repository’s remote Python loader. Pinned files: bekko — pinned model revision c18167b8

The environment used Python 3.12.14, ONNX Runtime 1.31.0, tokenizers 0.23.3 and NumPy 2.3.5, with one ONNX thread. Both BM25 and embeddings used the same WordPiece token IDs, without query or document prefixes. This is not a comparison against a tuned Korean morphological search engine.

Each query has one labeled relevant document. The eight queries mix exact error codes, paraphrases, policy questions and a deliberately confusable question. They contain no customer data. We did not select a best-scoring fixture across multiple model trials. This is a synthetic smoke test, not a representative Korean retrieval benchmark, and it does not evaluate generated answers or a complete RAG system.

The same 6/8 hides different errors

For the query meaning “send the same payment twice but charge only once,” BM25 ranked the HTTP 429 document first and idempotency second. bekko put idempotency first. For “the service broke after deployment; I want the old one back,” BM25 found rollback first while bekko preferred the generic deployment document.

For the query about an external server that never answers, both put the timeout document second. Equal aggregate hit counts do not make the systems interchangeable, and an embedding model does not necessarily win on every paraphrase.

We separately encoded dog bites man and man bites dog. Their token multisets matched, their normalized-vector cosine was 1.0, and the maximum component difference was approximately 1.49e-8: floating-point noise. This checks a structural mean-pooling limitation when subject and object matter; it is not a measurement of Korean language quality.

Observed results on the same corpus
Documents: 12 / Queries: 8
BM25      Hit@1: 6/8   Hit@3: 8/8
bekko512  Hit@1: 6/8   Hit@3: 8/8
Order-swapped pair cosine: 1.0

A smaller output is not a smaller loaded model

Halving output dimensions is different from loading half the weights. With the default model, truncate_dim=512 still loads the full 1,024-dimensional table. A memory-constrained deployment needs a file that actually stores only the selected dimensions.

Our downloaded INT8 512-dimensional ONNX file was 103,200,965 bytes and the tokenizer was 5,104,874 bytes. The 12 FP32 document vectors alone occupied 24,576 bytes. Even their sum is not peak process memory: runtime allocations, temporary buffers, an index and concurrency add separate costs.

As a narrow diagnostic, we timed 100 single-query encodings after 10 warmups with the model already loaded. Median time was about 0.086 ms and the 95th percentile about 0.145 ms. These short queries ran in this container only. Download, startup, retrieval and generation were excluded. This is neither a production latency promise nor a speedup against another model.

Repeat the experiment, not just the headline

The downloads contain our synthetic FAQ, BM25 and metric helpers, a local ONNX runner, tests and the actual result JSON. The tests need only Python’s standard library; the inference run additionally needs the model files and packages. We do not redistribute model weights here. Compare the model and tokenizer SHA-256 hashes in your result JSON with the saved result as well. Fixture: static retrieval — fixture.json

Evaluation helpers: static retrieval — retrieval.py

Runner: static retrieval — run.py

Regression tests: static retrieval — test_retrieval.py

Environment, file hashes, per-query ranks and measurements: static retrieval — results.json

Save the five files together. Download onnx/model_int8_dim512.onnx from the pinned revision into a separate model directory as model.onnx, plus tokenizer.json under its original name. The package versions below are those used for this run. Use an isolated virtual environment. run.py reads local inputs; it does not download files or call an external API.

Standard-library tests and optional model run
python -m unittest -v test_retrieval.py
# Separate virtual environment for model inference:
python -m pip install numpy==2.3.5 tokenizers==0.23.3 onnxruntime==1.31.0
python run.py /path/to/model-directory > my-results.json

Make the deployment decision from the failures

For a real service, keep separate cases for missing answers, policies from the wrong date or version, and sentences with reversed participants. A top-ranked document is not proof that the corpus contains the answer. Calibrate score thresholds and abstention on your data rather than copying thresholds from another model.

Hybrid retrieval and reranking are possible next experiments, but we did not run them here. Start with representative user questions, labeled documents and the cost of each failure, then compare ranks, latency and memory under the same conditions.

For code search, reducing the search space can matter alongside model choice. Related: Where Did Zero Go? Code Localization with ColGrep-Agent

If you are planning retrieval evaluation or search integration into an existing app, prepare anonymized example queries, corpus size, deployment constraints and acceptance criteria first. Sambro development and operations: Sambro — company and services

Back to Sambro Blog