Back to blog

Clinical Coding Embeddings: General or Specific?

A senior physician

A Tietai study showing that a Spanish biomedical bi-encoder with cross-encoder reranking outperforms public embeddings and BM25 on ICD-10 / CIE-10-ES coding search.

Research note. This study evaluates retrieval models on public benchmarks. It does not describe an available product or its clinical performance.

Clinical mention

A short query in EN, ES, CA, IT, PT or FR

Stage 1 · Bi-encoder (multilingual)

Encodes the query and every CIE-10 description independently and ranks them by cosine similarity. Trained on 19,502 curated synthetic examples across 17 ICD-10 chapters.

Top-k candidates

Stage 2 · Cross-encoder reranker (Spanish)

Reads each query–code pair together and reorders the shortlist. Trained on 10,628 listwise groups with clinically plausible hard negatives.

Ranked CIE-10-ES codes

Laterality, severity, etiology and episode type resolved in the final order

Two-stage ICD retrieval. A multilingual bi-encoder retrieves candidate CIE-10 codes, then a Spanish-tuned cross-encoder reranks the shortlist to recover clinically relevant distinctions such as laterality, severity, etiology, and episode type.

01 - The question

Can compact task-specific retrievers outperform broad public embeddings?

Sentence embeddings work well for broad semantic search, but ICD coding is not broad semantic search. The model must map short clinical mentions to a controlled vocabulary where neighboring codes often differ by a qualifier: anatomical site, laterality, severity, encounter type, or etiology.

The paper asks whether high-quality synthetic supervision can close that gap for Spanish clinical coding. We use a frontier LLM to generate multilingual examples grounded in the ICD-10 hierarchy, fine-tune a Spanish biomedical bi-encoder, then train a cross-encoder reranker on listwise groups with clinically plausible hard negatives.

The headline finding: task-aligned supervision and clinically meaningful negatives matter more than embedding size or generic English biomedical pretraining for Spanish ICD-10/CIE-10-ES retrieval.

02 - Method

A bi-encoder for recall, a cross-encoder for exact-code precision.

The retriever uses a standard but carefully aligned two-stage architecture. Stage 1 encodes each query and CIE-10 description independently and ranks by cosine similarity. Stage 2 jointly reads each query-code pair and reorders the top candidates with a listwise objective.

The training data was not treated as raw synthetic output. We curated the generated examples through rule-based validation, semantic deduplication, language consistency checks, and manual spot inspection before using them to build the bi-encoder and reranking classifiers. That curation step is central to the paper: the goal is not simply to make more data, but to create examples and hard negatives that reflect the clinical distinctions encoded in ICD-10/CIE-10.

Synthetic bi-encoder examples across 17 ICD-10 chapters.
19,502
Languages used for synthetic supervision: EN, ES, CA, IT, PT, and FR.
6
Spanish listwise cross-encoder groups with one positive and hard negatives.
10,628
Evaluation resolutions: full code, 3-character category, and chapter.
3

Retrieval strategies compared

StrategyRole in the study
Tietai Cross-EncoderReranks the bi-encoder shortlist and optimizes exact-code ordering.
Tietai Bi-EncoderSpanish biomedical dense retrieval backbone fine-tuned on synthetic supervision.
BM25 (Postgres FTS)Lexical full-text baseline over CIE-10-ES descriptions.
ST MiniLM-L6-v2General-purpose public sentence-transformer baseline.
ST BioBERTEnglish biomedical sentence-transformer baseline.
ST MPNet-v2Larger 768-dimensional general sentence-transformer baseline.

03 - Results

F1 and MAP@10 put the ranking quality in focus.

On CodiESP v4, the Tietai cross-encoder reaches F1 = 0.709 and MAP@10 = 0.747 at exact-code resolution. On DISTEMIST, it reaches F1 = 0.776 and MAP@10 = 0.812. The updated paper treats MAP@10 as the ranking metric and F1 as the top-1 decision metric.

CodiESP exact-code F1 for the Tietai Cross-Encoder.
0.709
CodiESP exact-code MAP@10 for the Tietai Cross-Encoder.
0.747
DISTEMIST exact-code F1 for the Tietai Cross-Encoder.
0.776
DISTEMIST exact-code MAP@10 for the Tietai Cross-Encoder.
0.812

CodiESP v4 F1 and MAP@10

ModelF1 exactF1 categoryMAP@10 exactMAP@10 category
Tietai Cross-Encoder0.7090.8230.7470.851
Tietai Bi-Encoder0.3590.6170.4610.694
BM25 (Postgres FTS)0.2390.3760.3220.471
ST MiniLM-L6-v20.2250.3710.2870.426
ST BioBERT0.1930.3140.2520.373
ST MPNet-v20.1610.3170.2260.376
CodiESP F1 and MAP@10 at exact-code and category levels.Tietai Cross-EncoderTietai Bi-EncoderBM25 (Postgres FTS)ST MiniLM-L6-v2ST BioBERTST MPNet-v20%20%40%60%80%100%F1 exactF1 categoryMAP@10 exactMAP@10 category
CodiESP F1 and MAP@10. The Tietai cross-encoder leads every metric. MAP@10 is higher than F1, showing that many top-1 misses still contain the correct code in the top-10 shortlist.

CodiESP exact-code top-1 precision, recall and F1

ModelPrecisionRecallF1
Tietai Cross-Encoder0.7090.7090.709
Tietai Bi-Encoder0.3590.3590.359
BM25 (Postgres FTS)0.2540.2270.239
ST MiniLM-L6-v20.2250.2250.225
ST BioBERT0.1930.1930.193
ST MPNet-v20.1610.1610.161
CodiESP top-1 precision, recall, and F1 at exact-code resolution.Tietai Cross-EncoderTietai Bi-EncoderBM25 (Postgres FTS)ST MiniLM-L6-v2ST BioBERTST MPNet-v20%20%40%60%80%100%PrecisionRecallF1
CodiESP top-1 exact-code precision, recall and F1. Dense retrievers emit one prediction per query, so the three metrics coincide. BM25 diverges because it returns no candidate for about 11% of CodiESP queries.
CodiESP precision at k by retrieval model for exact-code and category matches.Tietai Cross-EncoderTietai Bi-EncoderBM25 (Postgres FTS)ST MiniLM-L6-v2ST BioBERTST MPNet-v2Exact code0%20%40%60%80%100%13510kCategory (3 characters)13510k
CodiESP Precision@k. Precision decays with k because each query usually has one gold code, but the model ordering is stable at both exact-code and category resolutions.
CodiESP recall at k by retrieval model for exact-code and category matches.Tietai Cross-EncoderTietai Bi-EncoderBM25 (Postgres FTS)ST MiniLM-L6-v2ST BioBERTST MPNet-v2Exact code0%20%40%60%80%100%13510kCategory (3 characters)13510k
CodiESP Recall@k. The cross-encoder reaches R@10 = 0.813 exact and 0.903 category, while the bi-encoder closes much of the gap by deeper ranks.

CodiESP top-1 accuracy by hierarchy

CodiESP top-1 accuracy at exact-code, category, and chapter levels.Tietai Cross-EncoderTietai Bi-EncoderBM25 (Postgres FTS)ST MiniLM-L6-v2ST BioBERTST MPNet-v20%20%40%60%80%100%Exact codeCategory (3 characters)Chapter
CodiESP hierarchical accuracy. The same top-1 decision improves from exact code to category and chapter, reflecting how often models find the right disease family even when the full code is wrong.

DISTEMIST F1 and MAP@10

ModelF1 exactF1 categoryMAP@10 exactMAP@10 category
Tietai Cross-Encoder0.7760.8180.8120.846
Tietai Bi-Encoder0.6030.6900.6820.747
BM25 (Postgres FTS)0.4310.4700.5040.537
DISTEMIST F1 and MAP@10 at exact-code and category levels.Tietai Cross-EncoderTietai Bi-EncoderBM25 (Postgres FTS)0%20%40%60%80%100%F1 exactF1 categoryMAP@10 exactMAP@10 category
DISTEMIST F1 and MAP@10. The relative ordering of cross-encoder, bi-encoder, and BM25 is unchanged on an independent Spanish clinical corpus.
DISTEMIST precision at k by retrieval model for exact-code and category matches.Tietai Cross-EncoderTietai Bi-EncoderBM25 (Postgres FTS)Exact code0%20%40%60%80%100%13510kCategory (3 characters)13510k
DISTEMIST Precision@k. Precision drops as k grows, but the task-specific dense models remain ahead of the BM25 lexical baseline at both exact-code and category levels.
DISTEMIST top-1 accuracy at exact-code, category, and chapter levels.Tietai Cross-EncoderTietai Bi-EncoderBM25 (Postgres FTS)0%20%40%60%80%100%Exact codeCategory (3 characters)Chapter
DISTEMIST hierarchical accuracy. Accuracy rises from exact code to category and chapter, while the model ordering stays consistent: cross-encoder, bi-encoder, then BM25.

04 - Interpretation

The bottleneck is task alignment, not embedding scale.

The public-baseline ordering is the important negative result. BioBERT-ST has biomedical pretraining, but it is English-centric. MPNet-v2 has larger embeddings, but it still trails MiniLM-L6-v2. Neither scale nor generic domain pretraining solves Spanish clinical-code retrieval by itself.

ICD retrieval requires models to separate sibling concepts that are semantically close but operationally different. The bi-encoder captures chapter-level topic information well, but exact-code ranking needs a reranker trained on hard negatives drawn from neighboring CIE-10 codes.

  • Task alignment matters. Synthetic examples must reflect the ICD hierarchy, not just broad biomedical relatedness.
  • Hard negatives matter. Neighboring codes teach the model to distinguish etiology, anatomy, severity, and episode type.
  • Reranking matters. The cross-encoder adds the qualifier-level discrimination required by CIE-10-ES guidelines.
  • Small data can be enough. A compact synthetic corpus can train a competitive retriever when examples are aligned with the target vocabulary structure.
  • Biomedical pretraining is not automatic transfer. English biomedical encoders still struggle when both query and target vocabulary are Spanish.

For production clinical coding search, the practical lesson is to train for the target vocabulary, target language, and target ranking problem. The useful unit is not a bigger embedding model; it is a retriever trained on the distinctions coders actually need to make.

Read the full paper

Clear the way for health.