Skip to content

Latest commit

 

History

History
81 lines (58 loc) · 2.26 KB

File metadata and controls

81 lines (58 loc) · 2.26 KB

Vector Database & ChromaDB: Quick Guide

What is a Vector Database?

A vector database stores high-dimensional vectors (embeddings) instead of just raw text, images, or audio.
These embeddings let you search by meaning/similarity, not just by exact keywords or file names.


How Are Embeddings Created?

  • Images:
    Models like CLIP (by OpenAI) convert images to vectors.
    Example: A photo of mountains and sun becomes a unique vector (e.g. [0.23, 0.99, ...]).

  • Text:
    Models like GloVe, OpenAI Embeddings, BERT convert sentences to vectors.
    Example: "Apple is a fruit." → [0.031, 0.245, ...]

  • Audio:
    Models like Wav2Vec2 encode sound files into vectors for search and retrieval.

Process:
All these models are trained on massive datasets.
Each embedding is a summary of "meaning" or "features"—the deeper the layer, the more abstract/semantic the representation.


Why Vector Search?

With millions of items, keyword search is limiting.
Embeddings let you find "similar" items—e.g. images of sunsets, sentences with the same intent, or similar-sounding audio clips—even if the exact words/pixels are different.


How is Similarity Search Performed?

1. Brute-Force (Flat) Search

  • Compares your query vector to every stored vector.
  • Accurate, but slow for large data.

2. Vector Indexing (ANN Methods)

IVF (Inverted File Index)

  • Divides vectors into clusters/classes.
  • Searches only in the most relevant clusters for speed.
  • Good for large databases (10k+ items).

HNSW (Hierarchical Navigable Small Worlds)

  • Builds a multi-layer graph.
  • Quickly finds the closest vectors by graph traversal.
  • Super fast and scales well.

Installation Guide

pip install chromadb

To run the code

streamlit run chromadb_demo.py

what happens under the hood

Image/Text/Audio
   ↓
[ Embedding Model ]
   ↓
[ Vector ]
   ↓
[ Vector DB (ChromaDB, FAISS, etc) ]
   ↓
Similarity Search (Flat / IVF / HNSW)

RAG (Retrieval-Augmented Generation)

Combines a vector DB with an LLM (like GPT) for "chat with your data" or "document QA" use cases.

Process: Query is embedded → Find top-k similar items from DB → Feed into LLM for generation.