Diabase Diabase

Project · Research preview

Swedish retrieval stack

Embedding and reranking models for local semantic search and RAG — trained, audited, and published with the mistakes left in the write-up.

Problem

Swedish RAG often starts from multilingual encoders that treat Swedish as a minority language, or from strong public Swedish baselines you may not want to depend on for every deployment story. I wanted a European-foundation, Swedish-first retrieval path that runs locally: fast candidate recall, then optional cross-encoder precision — before a chat model like Europa answers.

Both models are explicitly labelled research preview. They are not marketed as production defaults or best-in-class Swedish embeddings.

Three stages

  1. 1

    European foundation

    Start from EuroBERT-210m (Apache 2.0) — a multilingual encoder built for European languages.

  2. 2

    Swedish adaptation

    Masked-language training on cleaned Swedish web text, Swedish Wikipedia, and English replay — then drop the MLM head.

  3. 3

    Retrieval training

    Contrastive query/document learning with in-batch and hard negatives; companion cross-encoder for reranking.

What went wrong in evaluation — and what I did about it

Early retrieval metrics looked excellent. An audit showed why: many paraphrased passages about the same facts sat across train/dev/test. Splits grouped exact documents but not semantic duplicates, so the model was rewarded for topic leakage, not true generalization.

That table stayed in the model card for transparency, but it was no longer treated as a release claim. I rebuilt the data into semantic/factual groups before splitting, retrained from the Swedish-adapted encoder (not from the contaminated checkpoint), and re-evaluated on the corrected hold-out.

Independent Swedish MTEB checks (SweFAQ / SweDN) then became the public honesty check: large gains over the adapted EuroBERT base, still clearly behind KBLab’s strong Swedish sentence-BERT baseline. Publishing both sides is intentional.

Signal, with context

vs adapted EuroBERT base

Corrected internal eval and MTEB both show large lifts after retrieval tuning — the training objective transferred.

vs KBLab Swedish SBERT

Still a substantial gap on SweFAQ and SweDN nDCG@10. That blocks any “best Swedish embedding” claim.

Latency (local)

Documented CPU and GPU query latency / throughput on the embedding card — useful for on-prem sizing, not a service SLA.

Reranker role

diabase-reranker-1 is the precision stage after embedding recall — same product story as the models page pipeline.

Why this shape

EuroBERT over “train a Swedish encoder from scratch”

A European open encoder plus controlled Swedish adaptation was a faster path to a usable retrieval stack than a from-scratch foundation — with license clarity (Apache 2.0) and a clear ablation story.

Two-stage retrieval, not one mega-model

Bi-encoder for recall, cross-encoder for precision. Matches how production RAG is usually operated and keeps the embedding model deployable on modest hardware.

Keep the failed eval in the card

Hiding the leakage episode would make the story prettier and less useful. Senior reviewers care that you can invalidate your own numbers.

What “stable release” would require

Topic-safe splits as default, multi-positive labels, a human-reviewed Swedish document benchmark, stronger baseline comparisons, cross-lingual regression checks, and production latency budgets — listed on the model card, not waved away.

Read the primary sources

The Hugging Face cards are the detailed lab notebook. This page is the executive case study for people who will not open every training table.