Embeddings and vector stores
An embedding model maps text to a numeric vector. A vector store keeps vectors beside their text and metadata, then finds nearby vectors for a query.
Tiny example
Section titled “Tiny example”from langchain_core.vectorstores import InMemoryVectorStore
store = InMemoryVectorStore(embeddings)store.add_documents(chunks)
matches = store.similarity_search( "How long do I have to return an order?", k=4,)Keep the contracts aligned
Section titled “Keep the contracts aligned”| Contract | What to keep consistent |
|---|---|
| Embedding | Model, version, vector dimension, and query/document mode |
| Vector store | Distance metric, index settings, and metadata schema |
| Permissions | Tenant and access filters applied before evidence reaches the model |
| Evaluation | Frozen questions and answer-bearing source spans |
Failure note
Section titled “Failure note”Similarity is not truth or permission. Using different embedding models for indexed documents and queries can collapse retrieval quality. Re-embedding only part of an index can mix incompatible vectors. Always version the index and measure retrieval after a migration.