Multilingual and Domain-Specific Embeddings
Retrieval across languages and in specialised domains such as law, medicine and code.
General-purpose English embedding models are trained mostly on web text in English. If your users ask questions in Hindi about documents written in English, or your documents are full of legal clauses, drug names or source code, a general model may retrieve poorly. This lesson covers multilingual and cross-lingual retrieval, and when a domain-specific model is worth it.
Three multilingual scenarios
| Scenario | Example | What you need |
|---|---|---|
| Monolingual, non-English | Tamil questions over Tamil documents | A model trained on that language |
| Multilingual collection | Documents in English, German and Japanese | A multilingual model so all languages share one vector space |
| Cross-lingual | Hindi question, English documents | A multilingual model aligned across languages |
Multilingual models
Multilingual embedding models map text with the same meaning to nearby vectors regardless of language. Well-known open options include BAAI/bge-m3 (100+ languages, 8,192 tokens, and it can also output sparse and multi-vector representations), intfloat/multilingual-e5-large and the Qwen3-Embedding family. Hosted APIs from Cohere, Voyage AI, OpenAI and Google also offer multilingual models.
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("intfloat/multilingual-e5-base")
documents = [
"passage: Employees receive 18 days of paid leave in their first year.",
"passage: Expense claims must be submitted within 30 days.",
"passage: The office is closed on public holidays.",
]
queries = [
"query: ???? ??? ??? ????? ????????? ????? ????", # Hindi: how much leave in the first year?
"query: Wie lange habe ich Zeit, um Spesen einzureichen?", # German: how long to submit expenses?
]
doc_vecs = model.encode(documents, normalize_embeddings=True)
for q, q_vec in zip(queries, model.encode(queries, normalize_embeddings=True)):
best = (doc_vecs @ q_vec).argmax()
print(q[7:45], "->", documents[best][9:60])
???? ??? ??? ????? ????????? ????? ???? -> Employees receive 18 days of paid leave in their
Wie lange habe ich Zeit, um Spesen einzureic -> Expense claims must be submitted within 30 days.
Practical tips for multilingual RAG
- Store the language of each chunk as metadata. It lets you filter or boost same-language results.
- Keyword search needs per-language tokenisation. BM25 with a simple English tokenizer works badly for Chinese, Japanese or Thai, which do not separate words with spaces.
- Answer in the user's language. The LLM can read English context and answer in Hindi; say so in the prompt: "Answer in the language of the question."
- Consider query translation as a cheap alternative when only a few languages matter: translate the question into the document language with the LLM, then search.
Domain-specific embeddings
Specialised domains use vocabulary that general models rarely saw in training: "estoppel" and "indemnification" in law, drug and gene names in medicine, function names in code. Options, from cheapest to most expensive:
- Try a stronger general model. Large modern models often handle specialised text well.
- Add keyword search. Hybrid search recovers most exact-term failures (Hybrid Search).
- Use a domain model. Examples include code embedding models (such as Voyage's code models or Jina's code embeddings), finance and legal variants from hosted providers, and biomedical models such as those trained on PubMed.
- Fine-tune a model on your data (next lesson).
A quick domain check
Before investing in a domain model, test whether your current model actually separates your domain's concepts. Pairs that should be close should score clearly higher than pairs that should not:
from rag_helpers import embed
pairs = [
("indemnification clause", "the supplier shall hold harmless the customer", True),
("indemnification clause", "the agreement is governed by Indian law", False),
("force majeure", "neither party is liable for delays caused by natural disasters", True),
("force majeure", "invoices are payable within 45 days", False),
]
for a, b, related in pairs:
va, vb = embed([a, b])
print(f"{'related ' if related else 'unrelated'} {va @ vb:.3f} {a} / {b[:40]}")
If related and unrelated pairs score about the same, the model does not understand your domain well enough.
Key takeaways
- Use a multilingual model when documents or queries span languages; it puts all languages in one vector space.
- Store chunk language as metadata and tell the LLM to answer in the user's language.
- For specialised domains, try hybrid search and stronger models before training your own.
- Check domain understanding with a few related and unrelated pairs.