Multilingual Similarity Search over 500GB
Trainable Hierarchical Index with Entity Linking
My Role
- Top-down search: clusters, then documents, then segments
- Retrain the k-means index as data grows
- Entity linking to filter and boost results
Approach at a Glance
Details- 1Multilingual Embeddings
- 2Trainable Hierarchical Index
- 3Top-Down Search
- 4Entity Linking
- 5Segment-Level Similarity Scoring
- 6Vector Store Evaluation
- 7Platform
Executive Summary
A similarity search system that finds documents, or parts of documents, similar to a new one across 500GB of translation memories and client documents, in any of the languages they're written in. Linguists and project managers use it to find past work that matches a new job, so existing translations can be reused instead of being produced again.
Searching that much text by brute force is too slow, so the search runs top-down over a trainable hierarchical index:
- k-means groups document vectors into clusters, and a query first goes to the nearest clusters;
- inside them, the closest documents are found;
- then the matching segments, the parts of documents that are actually similar.
The index is retrained as the data grows, which keeps queries under a second on a benchmark test. Multilingual mBERT and XLM-RoBERTa embeddings let it match content across languages, and entity linking tags documents with the entities they mention, so search can filter and boost results by shared entities. I built it alone, as the dedicated developer in the company's R&D team, and it runs in production.
Client Profile
The company translates very large volumes of content for its clients, and much of that content resembles something already translated before: a new version of a manual, a similar product page, a recurring contract. Its translation memories and client documents add up to hundreds of gigabytes.
Finding that earlier work was the problem:
- Scale: comparing a new document with 500GB of content one by one is far too slow to be useful in daily work.
- Similar, not identical: reusable content is rarely an exact match. It's a paragraph rephrased or a section updated, so it has to be found by meaning.
- Many languages: the same content exists in many languages, and a match can be on either side.
- Parts, not just files: often only a section of a document matches, and that section is what linguists need.
Technical Approach
-
Multilingual Embeddings – Documents and their segments are embedded with mBERT and XLM-RoBERTa, which place text in different languages into one vector space, so similar content can be found across languages.
-
Trainable Hierarchical Index – Document vectors are clustered with k-means, and the vectors are stored and searched with FAISS. The index has several levels, clusters, documents and segments, and it is retrained as new data arrives, so the clusters stay representative and search stays fast.
-
Top-Down Search – A query, a document or a part of one, is embedded and sent to the nearest clusters first. Only the documents inside them are compared, and then the most similar segments within those documents. Because each step narrows the search, queries over 500GB return in under a second on a benchmark test.
-
Entity Linking – An mBERT-based model tags documents with the entities they mention and links them, so results can be filtered and boosted by the entities they share with the query, on top of semantic similarity.
-
Segment-Level Similarity Scoring – A scoring tool compares pairs of segments by averaging several XLM-R and mBERT models, and produces a report on how similar they are.
-
Vector Store Evaluation – Besides FAISS, I evaluated Milvus and Qdrant as vector stores for the index.
-
Platform – The service runs on the company's language-AI platform with a Flask API and a React interface, in Docker on Kubernetes with Azure ML.
Business Outcome
Linguists and project managers can find the past work that matches a new job across 500GB of translation memories and client documents, in under a second and across languages, down to the specific segments that match. That makes it practical to reuse existing translations instead of redoing them. The system runs in production on the company's language-AI platform.
Technologies
Planning something similar?
Tell me about it on a short call. New projects can start within 2 weeks