Embeddings & vector databases
Turn text into coordinates in meaning-space, then search by closeness — the index that makes semantic search and RAG work.
In one line
An embedding model maps text (or images, audio) to a long vector of numbers such that similar meaning lands nearby — so "heart attack" and "myocardial infarction" become neighbours even though they share no words.
The idea: meaning as geometry
Keyword search fails the moment two phrases mean the same thing in different words — "heart attack" vs "myocardial infarction", "shortness of breath" vs "dyspnoea". An embedding model solves this by placing each piece of text at a point in a high-dimensional space (hundreds to thousands of numbers) arranged so that closeness = similar meaning. Synonyms cluster; unrelated concepts sit far apart. Search becomes geometry: find the nearest points.
How a vector database works
- Index once — each chunk of content is embedded and stored as a vector.
- Query — the question is embedded the same way; the database returns the nearest vectors by cosine or dot-product distance.
- Approximate nearest neighbour (ANN) — exact comparison against millions of vectors is too slow, so indexes like HNSW (a navigable graph) find the closest matches in milliseconds, trading a sliver of accuracy for huge speed.
Storage is either a dedicated engine (Qdrant, Pinecone, Milvus, Weaviate) or an extension in the database you already run — pgvector in Postgres, which is exactly what this platform uses: every Kosha entry carries an embedding column from day one, so semantic search and RAG need no separate system.
Things that trip people up
- Embeddings aren't interchangeable — vectors from one model can't be compared with another's; re-embed everything if you switch models.
- Chunk size shapes results — the unit you embed is the unit you retrieve.
- Distance ≠ correctness — "nearest" can still be wrong; that's why RAG adds re-ranking and citations.
- Domain matters — a general embedder may miss clinical nuance; biomedical models (and concept annotation) often do better on notes.
Where it shows up in digital health
- Semantic search over clinical guidelines — "post-op fever workup" finds the right document even if it never uses those words.
- Patient-similarity research — find comparable cases by vector proximity.
- Terminology candidate matching in NLP pipelines (surface→concept).
- The retrieval half of every RAG assistant, Vaidya included.
Key takeaways
- Embeddings turn meaning into vectors; near means similar, regardless of wording.
- A vector DB does fast approximate nearest-neighbour search (HNSW) — dedicated engine or pgvector in Postgres.
- Embeddings are model-specific; chunking and domain fit drive quality.
- They are the foundation under semantic search and RAG.
Check your recall
0 of 2 recalledActive recall beats re-reading — try to answer, then reveal.
What does an embedding model do?
Why use approximate nearest-neighbour (e.g. HNSW) in a vector database?