Concept guide · Embeddings and vector search
How do metadata filters interact with vector search?
A slower explanation for when the short interview answer is not enough. Start with the intuition, then connect it to the technical idea and the way an interviewer expects you to reason about it.
ML area
Generative AI → Metadata and permission filters
Interview format
Core · Scenario
Question
GENAI-041
Start with the idea
In simple terms
Metadata filters apply hard rules such as tenant, language, date, or document type alongside semantic search. They prevent a relevant-looking result from being returned when it is not valid for the current user or request.
Make it concrete
A finance employee may search policy documents semantically, but the retriever must still restrict results to the employee’s organisation and the current policy version.
Build the answer
How to approach it
- 1Separate semantic relevance from hard business or security constraints.
- 2Apply filters at retrieval time and make them part of the trace.
- 3Test tenant isolation, revoked access, and cache or citation leakage.
Go one level deeper
The technical explanation
Embeddings do not reliably represent every business constraint, and they are not an access-control mechanism. Store filterable metadata with each retrievable unit, index fields used frequently, and apply authorisation before context assembly. Test strict filters, empty-result behaviour, cache keys, citations, memory, and revoked access; post-filtering after generation is too late.
Say this in the interview
Metadata filters restrict candidates by fields such as tenant, language, date, or document type. Applying them during retrieval is safer and more efficient than retrieving unauthorised content and filtering after generation. Index design must support the filter pattern or vector recall and latency may suffer.
Keep preparing