Vector Search With a Vector Store
Retrieve the most relevant passages.
Vector Search With a Vector Store is a free NLP Academy lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the NLP Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
What a Vector Store Does
A vector store holds your chunk embeddings and finds the closest ones to a query fast, even across millions of vectors.
Searching by Similarity
Instead of matching keywords, you match meaning. The store returns chunks whose vectors sit nearest to the query vector.
Cosine Similarity
The common distance measure is cosine similarity. It compares the angle between two vectors, so closer in meaning scores higher.
Embed the Query the Same Way
The question must use the same model as your chunks. Mismatched embeddings live in different spaces and cannot be compared.
query_vec = model.encode(["How do I reset my password?"])Top-K Retrieval
You rarely want every match. Ask the store for the top-k nearest chunks, where k is a small number like 3 or 5.
A Simple In-Memory Store
For small data, FAISS keeps vectors in memory and searches in milliseconds. You build an index, then add your vectors.
import faiss
index = faiss.IndexFlatIP(384)
index.add(vectors)Running a Search
Call search with the query vector and k. It returns the scores and the indexes of the best-matching chunks.
scores, ids = index.search(query_vec, k=3)Mapping Results Back to Text
The store gives you indexes, not text. Use them to look up the original chunks you stored alongside the vectors.
hits = [chunks[i] for i in ids[0]]Persistent Vector Databases
For real apps, a vector database like Chroma or Pinecone stores vectors on disk, scales out, and survives restarts.
Filtering With Metadata
Attach tags such as author or date to each vector. Then you can filter the search, like only chunks from one document.
Why Approximate Search Helps
Exact search gets slow at scale. Approximate nearest-neighbor indexes trade a tiny bit of accuracy for huge speed gains.
Quick Check
Recall how a vector store finds relevant chunks.
Recap
A vector store embeds the query, finds the top-k nearest chunks by similarity, and maps results back to text. ✅
Frequently asked questions
Is the “Vector Search With a Vector Store” lesson free?
Yes — the full text of “Vector Search With a Vector Store” is free to read here on the web, and the NLP Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the NLP Academy course, upgrade to CoddyKit PRO.
What will I learn in “Vector Search With a Vector Store”?
Retrieve the most relevant passages. You practise NLP Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start NLP Academy?
No prior experience is required. NLP Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Vector Search With a Vector Store” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this NLP Academy lesson?
Yes. Every NLP Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Why LLMs Need Retrieval
- Chunking and Embedding Documents
- Vector Search With a Vector Store
- Wiring Retrieval Into the Prompt