Skip to main content

08. Programming & Technologies

Vector Databases for Agents (Pinecone, Chroma, FAISS, Weaviate)

Vector databases store embeddings so agents can retrieve similar chunks for RAG: Pinecone (managed), Chroma (dev-friendly), FAISS (in-process ANN library), and Weaviate (open-source hybrid search). They are retrieval indexes — not a replacement for SQL systems of record — and must enforce metadata filters for tenant ACL.

What you will learn

  • Explain what a vector DB stores and returns for agents
  • Describe the embed → search → filter → ground loop
  • Pick among Pinecone, Chroma, FAISS, and Weaviate
  • List metadata, ACL, and eval practices for safe RAG tools
  • Answer interview questions with short, solid answers
Pinecone Chroma FAISS Weaviate overview for agents
Interview staple: vectors for similarity; SQL for truth; filters for tenancy.

Definition

A vector database (or vector index) stores high-dimensional embedding vectors plus metadata, and answers nearest-neighbor queries: “which chunks are most similar to this query embedding?” Agents use that for RAG — retrieve evidence, then generate — and sometimes for memory recall.

Pinecone, Chroma, Weaviate are databases/services around that idea. FAISS is a library for similarity search you embed in your process. pgvector (mentioned for context) adds vectors to Postgres; this lesson focuses on the four named in the title.

Introduction

This lesson (#6 in Programming & Technologies) follows SQL/NoSQL backends. You have a system of record; now add semantic retrieval so agents ground answers in your corpus.

Next: Embeddings, RAG and Semantic Search Basics — the concepts these stores implement.

Why agents need vector stores

  • Context windows cannot hold entire knowledge bases
  • Keyword search misses paraphrases agents hear from users
  • Tooling can “search_docs” as a first-class agent action
  • Long-term memory often embeds summaries for later recall
  • Eval of retrieval quality drives agent answer quality

Agent retrieval loop

Same pattern whether the store is Pinecone or FAISS behind an API.

Query embed vector search filter then LLM
Use the same embedding model at index and query time.
  • Chunk and embed documents offline (ingest pipeline)
  • Store vector + text + metadata (doc_id, tenant, ACL tags)
  • At query time: embed question → ANN top-k → metadata filter
  • Pass compact snippets to the LLM with citations
  • Link chunk ids back to SQL/files for the source of truth

Pinecone

  • Managed vector database — less ops for production indexes
  • Namespaces/metadata filters for multi-tenant agents
  • Good default when you want cloud scale without running ANN infra
  • Watch: cost, data residency, and vendor coupling
  • Pair with your own chunk store or metadata in SQL

Chroma

  • Developer-friendly collections for local and small-server use
  • Fast path for notebooks, demos, and early agent prototypes
  • Can run embedded or as a server depending on setup
  • Watch: production HA/scale needs a clear ops plan
  • Great for learning RAG before committing to managed infra

FAISS

  • Facebook AI Similarity Search — a library, not a full DB product
  • Very fast in-process ANN; you own persistence and distribution
  • Fits offline indexing, research, or custom serving layers
  • Watch: no built-in multi-tenant DB features — you build them
  • Often wrapped by a service that adds filters and auth

Weaviate

  • Open-source vector database with cloud and self-host options
  • Strong story for hybrid search (vector + keyword/BM25-style)
  • Schema/classes and modules for richer object search
  • Fits teams that want OSS control inside their VPC
  • Watch: cluster ops and version upgrades are your job if self-hosted

Decision map

Choose on ops model and query features, then measure recall on your corpus.

Decision map Pinecone Chroma FAISS Weaviate
Managed → Pinecone; prototype → Chroma; in-process ANN → FAISS; hybrid/self-host → Weaviate.
  • Ship managed prod quickly → Pinecone (or similar SaaS)
  • Local prototype / teaching → Chroma
  • Custom high-performance ANN in your binary → FAISS
  • Hybrid search + self-host → Weaviate
  • Also consider pgvector if you want vectors beside SQL

Safety and quality for agent RAG

  • Always filter by tenant_id / ACL before returning chunks
  • Cap top-k and total characters injected into the prompt
  • Cite sources; prefer refusal when retrieval is weak
  • Re-embed when the embedding model changes
  • Eval retrieval (hit rate) separately from generation quality
  • Do not store secrets inside chunk text

Map to earlier modules

  • Complements SQL/NoSQL — ids and permissions stay relational
  • Powers Module 09-style RAG / knowledge agents
  • search_docs tool = Module 05 tool-use with retrieval semantics
  • Frameworks (LlamaIndex, LangChain, Haystack) often wrap these stores
  • Next lesson deepens embeddings and RAG theory

Failure modes

  • Wrong embedding model at query vs index time
  • No metadata filters → cross-tenant data leaks
  • Huge top-k dumps that drown the LLM
  • Treating FAISS files as a multi-writer database
  • Skipping retrieval evals — “RAG” that never finds the answer

Program / implementation notes

Ingest offline: chunk → embed → upsert with metadata. At runtime expose a search_docs tool that embeds, filters, and returns cited snippets. Keep canonical documents in object storage/SQL.

  • Pin embedding model id in config next to index name
  • Next: Embeddings, RAG and Semantic Search Basics

Advantages and limitations

  • Advantage: semantic recall beyond keywords
  • Advantage: scalable knowledge for grounded agents
  • Advantage: multiple deployment styles (SaaS, OSS, library)
  • Limitation: approximate search can miss exact IDs — hybrid helps
  • Limitation: garbage chunks in → garbage answers out
  • Limitation: not a transactional store for orders or balances

Key points

  • Vector DBs retrieve similar embeddings + metadata for RAG/memory.
  • Pinecone managed; Chroma prototype-friendly; FAISS library; Weaviate hybrid/OSS.
  • Same embedding model for index and query.
  • Filter by tenant/ACL; cap context size; cite sources.
  • Link chunks to SQL/files as source of truth.
  • Eval retrieval quality separately from generation.

FAQs

Vector DB vs SQL?

SQL holds authoritative entities and permissions. Vector DBs hold embeddings for similarity search. Agents usually need both.

Is FAISS a database?

It is a similarity-search library. You must handle persistence, concurrency, filters, and serving yourself (or via a wrapper service).

Pinecone or Weaviate?

Pinecone optimizes for managed ops. Weaviate fits open-source/self-host and hybrid search needs. Benchmark filters and recall on your data.

Do I need hybrid search?

Often yes for IDs, SKUs, and exact tokens. Pure vectors miss precise strings; keyword + vector (or re-rank) fixes many agent failures.

Interview questions

  1. What does a vector database do for an agent?

    Answer It stores embeddings and returns the nearest chunks (plus metadata) so the agent can ground answers or memory in retrieved evidence.

  2. Compare Pinecone, Chroma, FAISS, and Weaviate briefly.

    Answer Pinecone is managed cloud indexes; Chroma is easy for local/prototypes; FAISS is an in-process ANN library; Weaviate is OSS/cloud with strong hybrid-search options.

  3. Why metadata filters matter?

    Answer They enforce tenancy and ACL so retrieval cannot surface another customer’s documents into the prompt.

  4. What breaks if embedding models differ at query time?

    Answer Vectors live in incompatible spaces — similarity scores become meaningless and retrieval quality collapses.

  5. How should a search_docs tool behave?

    Answer Embed the query, apply ACL filters, return top-k compact snippets with source ids, and respect size budgets for the context window.

  6. Can a vector DB replace Postgres for tickets?

    Answer No. Tickets need transactional updates and constraints; vectors only help find related text, not own the system of record.

Related topics

Practice task

Complete each numbered practice step in a notebook or doc before opening the next lesson.

  1. List metadata fields you would store with each chunk for a multi-tenant support agent.
  2. Pick a store for (a) weekend prototype and (b) regulated self-host prod — justify in 2 bullets each.
  3. Write the steps of search_docs from user question to cited snippets.
  4. Define 3 retrieval eval queries and what “pass” means (doc id in top-5).
  5. Answer interview questions 1, 2, and 3 in two sentences each.