Back to Tutorials
LLM Application Development
Intermediate

Choosing an Embedding Model: Test It on Your Own Questions

Five free embedding models answer a help centre’s questions in English, Spanish and German. Build your own leaderboard, change the rule, and watch the benchmark favourite lose.

9 minInteractive: drag, click and try things as you read


Every search and RAG system starts with an embedding model, the model that turns text into a list of numbers so that similar meanings land close together. There are hundreds to choose from, and public leaderboards rank them. Here you’ll test five free models on a small help centre’s own questions, in three languages, and see the leaderboard’s favourite lose. The best embedding model is the one that finds your answers: build a small test set and measure.

A test set in ten minutes#

You don’t need much. Write down questions your users really ask, and for each one note the passage in your documents that answers it. That’s a retrieval test set. Then, for each candidate model, embed the passages and the questions, rank the passages for each question by cosine similarity, and count how often the answering passage comes first, or lands in the top few that your RAG prompt will include.

Ours is the Hearth help centre from the reranking explainer: 50 short passages about a made-up smart-home company, 35 questions phrased the way customers write (“the box arrived smashed”, “E-714”), and 15 of those questions translated into Spanish and German. The five candidates are all free and small enough to run on a laptop:

  • MiniLM (all-MiniLM-L6-v2): 23 million parameters, the default in many tutorials.
  • BGE small (bge-small-en-v1.5): 33 million, from the Beijing Academy of AI, and well ahead of MiniLM on public benchmarks. Its model card reports a retrieval average of 51.7 on the English MTEB benchmark; MiniLM’s is usually listed at about 42.
  • BGE small + instruction: the same model, with the prefix its card suggests for queries (“Represent this sentence for searching relevant passages:”).
  • BGE base (bge-base-en-v1.5): 110 million parameters, and 768 numbers per text instead of 384.
  • Multilingual MiniLM (paraphrase-multilingual-MiniLM-L12-v2): 118 million, trained on more than 50 languages.

Predict first

On the 35 English questions, which puts the answering passage first more often: MiniLM or BGE small, the one that scores about 10 points higher on the benchmark?

Try it
The passages, questions and answers are made up; the scores are real cosine similarities from each model, computed offline with sentence-transformers. The ranking and counting happen live.

The rule decides the winner#

Counting only first place, MiniLM wins with 28 of 35 and BGE base comes second with 27. Count the top 3, which is what a RAG prompt with three passages sees, and MiniLM, both BGE models and BGE with its instruction all find 32: a four-way tie. Count the top 5 and MiniLM and BGE base find 34. Decide how many passages your app will use before you compare models, and measure exactly that.

Two more things the figure shows. BGE base is three times the size of BGE small and stores twice as many numbers per passage, and in the top 3 it finds exactly as many answers. And BGE’s suggested instruction didn’t help here (23 first instead of 24); its own model card says the instruction is optional and to keep whichever works better on your task. That one-question difference is noise on 35 questions, which is itself the lesson: with a small test set, only big gaps mean anything.

Predict first

Now the customers write in Spanish, and the help centre stays in English. How many of the 15 Spanish questions does MiniLM answer with the right passage first?

One question, five answers#

A leaderboard hides which questions each model misses, and those are what your users will notice. Pick a question to see each model’s top three passages. Questions that were translated have buttons to ask the same thing in another language.

Try it
The same scores as above. Try “what does E-147 mean” (BGE small puts the answer 7th), “does it work with Siri”, and “can I get my money back” in Spanish.

The misses have reasons you can act on. Codes like E-147 are rare strings, and some models place them better than others; a keyword search alongside the vectors (hybrid search) catches them all. Translated questions need a multilingual model, or a translation step before search. And when two models miss different questions, a reranker that reads the top 20 closely can often recover both.

Look at the similarity scores too. For “what does E-147 mean”, MiniLM’s best match scores 0.33 and BGE base’s scores 0.62, and both are right. Each model has its own scale, so a fixed cut-off such as “ignore anything under 0.5” has to be chosen again whenever you switch models.

In code#

A test set and a comparison in a few lines, free and local (pip install sentence-transformers). Use your own passages and questions, and many more than six:

from sentence_transformers import SentenceTransformer

passages = {
    "Returns": "You can send back any Hearth product within 30 days of delivery for a full refund.",
    "Warranty": "Every Hearth device is covered for two years against manufacturing faults.",
    "Delivery": "Orders take 2 to 4 working days in the UK.",
    "Damaged on arrival": "If your device arrives broken, tell us within 14 days and we'll send a replacement.",
    "Can't sign in?": "Reset your password from the sign-in screen by tapping Forgotten password.",
    "Connected but offline": "If the thermostat can't reach the internet, you'll see E-147. Restart the router.",
}
# your own test set: real questions, and the passage that should answer each
tests = [
    ("can I get my money back", "Returns"),
    ("it broke after a year, will you fix it", "Warranty"),
    ("what does E-147 mean", "Connected but offline"),
    ("the box arrived smashed", "Damaged on arrival"),
    ("¿me pueden devolver el dinero?", "Returns"),
    ("ich habe mein Passwort vergessen", "Can't sign in?"),
]
for name in ["sentence-transformers/all-MiniLM-L6-v2", "BAAI/bge-small-en-v1.5",
             "sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2"]:
    model = SentenceTransformer(name)
    P = model.encode(list(passages.values()), normalize_embeddings=True)
    Q = model.encode([q for q, _ in tests], normalize_embeddings=True)
    best = (Q @ P.T).argmax(axis=1)
    right = [list(passages)[b] == answer for b, (_, answer) in zip(best, tests)]
    print(f"{name.split('/')[1]}: {sum(right)}/{len(tests)} first, missed: {[q for (q, _), ok in zip(tests, right) if not ok]}")
# all-MiniLM-L6-v2: 3/6 first, missed: ['it broke after a year, will you fix it', '¿me pueden devolver el dinero?', 'ich habe mein Passwort vergessen']
# bge-small-en-v1.5: 4/6 first, missed: ['it broke after a year, will you fix it', 'ich habe mein Passwort vergessen']
# paraphrase-multilingual-MiniLM-L12-v2: 5/6 first, missed: ['it broke after a year, will you fix it']

With these shortened passages, all three miss the warranty question: the passage never says “broke” or “fix”. That’s a finding about your documents, not your model, and a test set surfaces both.

What to remember

  • Benchmarks average many datasets unlike yours; a few dozen of your own questions, each with the passage that answers it, tell you more.
  • Measure what your app uses: here MiniLM won on first place, while four setups tied on the top 3, and the model three times bigger added nothing.
  • Check the languages and odd strings your users type: MiniLM put the right passage first for 2 of 15 Spanish questions; the multilingual model got 9.

Keep going

Sign in to save your place and keep a learning streak. Free, with Google.