Giving AI your knowledge · wrap-up
Cheat sheet & self-check
Every command from this section on one page.
Terms
Vector | An ordered list of numbers, e.g. [0.12, -0.53, 0.88, …] |
Embedding | A vector that represents the meaning of a text (or image, or audio) |
Dimensions | How many numbers in the vector; commonly a few hundred to a few thousand |
Embedding model | A model whose job is to turn text into embeddings (not to chat) |
Cosine similarity | A score for how closely two vectors point the same way; near 1 = similar meaning |
Semantic search | Finding text by meaning instead of by matching words |
Terms
Vector database | Stores vectors with their text and metadata, and finds the nearest ones to a query vector |
Nearest-neighbour search | Find the stored vectors closest to the query vector |
ANN (approximate nearest neighbour) | Very fast search that returns almost-always the true nearest results |
Index (e.g. HNSW) | The structure that makes ANN fast, like a map of shortcuts between points |
Top-k | How many nearest results to return, e.g. the best 5 |
Metadata filter | Restrict results by fields such as product, date, language, or who may see them |
Hybrid search | Semantic (vector) search combined with keyword search |
Common options
pgvector | Extension that adds vector search to PostgreSQL |
OpenSearch / Elasticsearch | Search engines with vector search alongside keyword search |
Qdrant, Weaviate, Milvus, Chroma | Purpose-built vector databases, self-hosted or managed |
Pinecone and cloud services | Fully managed vector search |
The pipeline
Ingest | Collect documents, clean them, split into chunks |
Embed and store | Turn each chunk into a vector; store with text and metadata |
Retrieve | Embed the question; find the nearest chunks (with permission filters) |
Augment | Put the chunks into the prompt with instructions |
Generate | The LLM answers from the chunks and cites them |
Quality levers
Chunk size and overlap | Small enough to be specific, large enough to keep context |
Hybrid search | Add keyword search for codes, names and exact terms |
Re-ranking | A second model re-orders retrieved chunks by relevance |
'Answer only from the sources' | Instruction that reduces made-up answers |
Evaluation set | Real questions with known answers, run after every change |