esc
  • WorkflowsPages
  • Case studiesPages
  • Machine Learning FoundationsLearn
  • AI EngineeringLearn
  • AI Guardrails & Red TeamingLearn
  • UI/UXLearn
  • Design SystemsLearn
  • Production System DesignLearn
  • AI papersPages
  • Interview KitPages
  • Book a callContact
Let’s talk

I’ll build the agent for it.

How Do You Fine-Tune Embedding Models?

How to train an embedding model on your own labelled pairs, test it fairly and re-index safely, explained simply for your AI interview.

In short

You fine-tune an embedding model by training it on labelled pairs: text that should match, and near misses that should not. Then you test it on searches it never saw. If you change the model's own weights, re-embed your whole index, because old and new vectors can't be compared.

14 min readAdvancedOccasional · estimateFacts checked 27 November 2026

Say it out loud

Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.

I fine-tune an embedding model on pairs of text that should match, like a claims search and the note the adjuster opened, plus close look-alikes that should not. Training pulls matches together and pushes the rest apart. I test on searches the model never saw, and check the new model beats the old one. If I retrain the model's own weights, I re-embed the whole index, because old and new vectors don't line up.

What is fine-tuning an embedding model, in plain words?

An embedding model turns a piece of text into a list of numbers, called a vector. Texts with a similar meaning get lists that sit close together. Fine-tuning means training that existing model a bit more on your own examples, so it learns what "similar" means in your work.

Think of a new claims handler at an insurer. The handbook never says that "burst pipe" and "water leak in the kitchen" are the same kind of claim. After a few months of real cases, she knows it. A general embedding model may still put those two phrases far apart. A fine-tuned one learns the link from your own cases.

Key words

Embedding
A list of numbers that stands for the meaning of a piece of text.
Positive pair
Two texts that should match, like a search and the note that solved it.
Hard negative
A near miss that looks like a match but is wrong. It teaches the model the fine lines.
Held-out set
Examples kept out of training and used only to test the model.
Re-embed
Recalculate every stored vector with the new model.

How do you build the training pairs?

The training data decides most of the result. Google's guide to tuning text embeddings says supervised tuning uses labelled examples that show the output you want:

  • “Supervised tuning uses labeled examples that demonstrate the type of output you'd like from your text embedding model during inference.”

    Google Cloud, tuning text embeddings

  • “using "entailment" pairs as positives and "contradiction" pairs as hard negatives”

    SimCSE paper, 2021

A positive pair is a search and the note that solved it. A hard negative is a near miss from the same family of documents. SimCSE, a 2021 paper on sentence embeddings, used the same idea with pairs of sentences where one follows from the other or contradicts it: an entailment pair (a sentence and another that follows from it) became the positive, and the contradiction pair became the hard negative. A 2020 paper on dense passage retrieval found that a small set of questions and passages can be enough to train the embeddings.

Hard negatives matter because the easy ones teach little. The ANCE paper of 2020 found that the negatives used in training were not like the documents a search meets later. Its fix was to pick negatives from your own corpus, using a search index that finds the closest documents to each query, so the near misses are the ones the model will meet.

Labelled pairs are often scarce. The GPL paper of 2021 said that search systems built on embeddings (called dense retrievers) "require large amounts of training data which is not available for most domains". Its method "combines a query generator with pseudo labeling from a cross-encoder". So if you have no labels, you can generate queries and let a cross-encoder label the pairs, but treat those machine labels as a weaker source.

Tip

Watch for false negatives. A hard negative can be a right answer that nobody labelled, so check a sample of pairs by hand before training.

  1. 1

    Collect real pairs

    Take searches and the notes people opened to solve them. Keep only clear matches.

  2. 2

    Split before anything else

    Set aside about one search in ten as a test set. Its text must never reach training.

  3. 3

    Add hard negatives

    For each match, add a near miss from the same kind of document, and check a sample by hand.

  4. 4

    Train gently

    Take small learning steps (the learning rate), so the model learns your words without losing general language.

  5. 5

    Compare on the test set

    Score the old and the new model on the same held-out searches.

  6. 6

    Re-embed and switch

    Rebuild every stored vector with the new model, then move traffic over in steps.

Here is a made-up example. A mid-size insurer logged 8,000 searches where an adjuster opened the note that solved the claim. It set aside 800 as a test set. Each of the other 7,200 became a positive pair, and each got a hard negative from the same policy type. That gave about 14,400 training pairs.

One fine-tuning run, from pairs to release

Training pairs

Search + right note

a note an adjuster opened

Search + near miss

same policy type, wrong claim

Training run

moves matches closer, misses away

Check on held-out searches

Searches it never saw

set aside before training, 1 in 10

Score old vs new

same searches for both models

Ship or keep old

decided by the held-out score

  1. 1The right note goes in as a match.
  2. 2The near miss goes in as a wrong answer to push away.
  3. 3The new model is then run on searches it never trained on.
  4. 4Both models answer the same searches, and the scores are compared.
  5. 5The held-out score decides whether the new model goes live.
Matching pairs and near misses feed one training run. The new model then answers searches it never saw, next to the old one. The score decides whether it goes live.

Should you retrain the whole model or add a small layer?

There are two common ways. A full fine-tune changes the model's own weights. An adapter keeps the model frozen and learns a small add-on that reshapes its output. Both start from the same pairs.

  • Full fine-tune

    Change the model

    Can fit your language best, but needs GPUs (graphics chips built for training) and a careful test. You also decide how the tuned model is served.

  • Small adapter

    Add a layer

    Cheaper and faster, and the base model stays as it was. It may be weaker when your words are far from general text.

  • “The output is a matrix that you can use to multiply your embeddings.”

    OpenAI cookbook (archived)

OpenAI's cookbook shows the adapter idea in an old recipe, dated March 2022. It says: "This recipe is archived and may reference outdated models or APIs." The recipe trains a matrix that multiplies your vectors, and its authors saw gains "as little as ~100 training examples" on other data sets. Treat those numbers as old.

Google's tuning guide is clear on cost: "Tuning requires GPU accelerators." Its list of tunable models names three text embedding models: text-embedding-004, text-embedding-005 and text-multilingual-embedding-002. Check that list for your model before you plan. It also says that "Unlike text model tuning jobs, a text embedding tuning job doesn't deploy your tuned models" to an endpoint. So plan who runs the new model before you book the job.

Tip

If someone asks which to pick, start with the adapter because it is cheap to test. Move to a full fine-tune only if the held-out scores say so.

How do you know the new model is better?

Test on searches the model never trained on, and run the same searches through both models. Count the score that matters to users. For a claims search, that is the hit rate: how often the right note appears in the top three results.

OpenAI's archived cookbook recipe makes the order clear: "it's important to split data into training and test sets before generating synthetic negatives or positives." Split first, then build the negatives, so no test text leaks into training.

In the made-up insurer example, the old model put the right note in the top three for 61% of the 800 held-out searches. The new model did it for 79%. Those are the numbers that decide the release.

Here is the same count in plain Python, on ten made-up searches. Each rank is where the right note landed, with 1 as the top result:

Python
# Made-up ranks: where the right claim note landed for ten held-out searches.
# 1 is the top result, 0 means not in the top 5. A hit is a rank of 1 to 3.
OLD_RANK = [2, 1, 0, 1, 0, 0, 0, 3, 1, 1]
NEW_RANK = [1, 1, 2, 1, 3, 0, 1, 3, 2, 1]

def hit_rate(ranks):
    hits = [r for r in ranks if 1 <= r <= 3]
    return len(hits) / len(ranks)

def show(name, ranks):
    print(f"{name}: hit rate at 3 = {hit_rate(ranks):.0%} on {len(ranks)} searches")

show("Old model", OLD_RANK)
show("New model", NEW_RANK)

Output

Old model: hit rate at 3 = 60% on 10 searches
New model: hit rate at 3 = 90% on 10 searches

Ten searches are far too few to trust, so the real test is the 800-search set above.

Tip

Check the held-out set once, at the end. If you keep tuning until the test score looks good, you have trained on the test set without saying so.

Also check general searches, such as a question that has nothing to do with claims. A model tuned hard on claims can get worse on everything else, so keep a small set of general searches in the test.

Why must you re-embed the whole index?

Each model draws its own map of meaning. After a full fine-tune, a vector from the old model sits at a place the new model would never put it. So comparing a new query with old vectors gives scores that look like results but can't be trusted. An adapter that leaves the base model alone may not need that rebuild, but check how the layer is applied to stored vectors before you skip it.

Two ways to switch to a new embedding model

Safe: rebuild first

Re-embed every note

all vectors made by the new model

Search with new model

queries and notes now match

Risky: mix versions

Keep old vectors

built by the previous model

Search with new model

query from a model they don't match

Scores mean something

ranks follow real meaning

Scores can't be trusted

ranks can't be relied on

  1. 1Every stored note is rebuilt by the new model first.
  2. 2Queries then meet vectors from the same model, so the scores compare.
  3. 3A new query is run against the old vectors.
  4. 4A new query is compared with old vectors, so the scores can't be trusted.
Two ways to switch. Rebuilding every vector first makes the scores comparable. Mixing new queries with old vectors after a full fine-tune gives scores that look like results but can't be trusted.

Re-embedding costs time and money, so plan it early. The made-up insurer keeps 2.4 million claim notes in its index. Put that rebuild in the plan before anyone promises a launch date.

How would you roll out a new embedding model safely?

I would build the new index next to the old one, and leave live search alone while I build it. Then I would move traffic over in steps:

  1. 1

    Send a small share

    Send a small share of searches to the new index, such as 5%.

  2. 2

    Watch the numbers

    Watch the hit rate and the complaints for two weeks.

  3. 3

    Switch all traffic

    Switch all traffic and keep the old index for a week.

  4. 4

    Clean up

    Then remove the old index and its vectors.

Tip

Say in advance what would make you roll back: a drop in the hit rate, or adjusters saying the top result is wrong more often.

What does the interviewer want to hear?

A strong answer covers

  • A plain definition: an embedding model trained on your own labelled pairs.
  • The data: matching pairs plus hard negatives, with a test set split off first.
  • The judge: held-out searches, run on the old and new model side by side.
  • The re-embed: every stored vector is rebuilt before the switch.
  • Full fine-tune or adapter, and why you picked it.
  • An honest limit: it helps most when your words differ from the base model's.

Common traps

  • Trap"Train on everything you have, then test on the same data."

    BetterTesting on training data flatters the model. Hold out a test set first and never train on it.

  • Trap"Just swap in the new model. The old vectors will still work."

    BetterAfter a full fine-tune they won't line up with the new model's. Re-embed the whole index before you switch.

  • Trap"A lower training loss means a better search."

    BetterTraining loss is the model's own error score during training. It measures fit to the training data, not new searches. Judge the model on searches it never saw, with the hit rate.

Can you spot the bad pair?

Spot the bad pair

Your team builds pairs for the claims search. Which label teaches the model the wrong thing?

Quick check

Your fine-tuned model scores 18 points higher on the held-out searches (61% to 79%). What do you do before going live?

Can you answer these from memory?

Flash cards · tap a card to flip it

1 / 6

What will they ask next?

  1. Q147When must you re-embed everything?12 min
  2. Q116How do you choose an embedding model?12 min
  3. Q294How do you prepare a fine-tuning dataset?11 min
  4. Q297How do you spot overfitting during fine-tuning?11 min
  5. Q300How do you evaluate a fine-tuned model?11 min

Learn it in depth

Last updated on 27 November 2026

Changing how your search finds things?

I design and build AI products and agents, including the search and the way it is tested. Book a short call and say what your search has to find.