{"slug": "getting-started-with-chromadb-vector-database", "title": "Getting Started with ChromaDB : Vector Database", "summary": "ChromaDB is an open-source vector database that enables semantic search and powers AI applications like RAG. It runs locally, requires no cloud account, and uses HNSW indexing for fast similarity search. A developer demonstrated how to install ChromaDB, create persistent collections, and perform semantic queries with automatic embedding generation.", "body_md": "If you've been exploring AI and large language models, you've probably heard about vector databases. They're very important for llm behind semantic search, recommendation systems, and Retrieval-Augmented Generation (RAG). **ChromaDB** is one of the most beginner-friendly options out there—it's open-source, runs locally, and requires no cloud account to get started. Let's dive in.\n\nTraditional databases search by matching keywords exactly. Vector databases work differently—they store data as **embeddings** (lists of numbers that capture meaning) and find results based on semantic similarity rather than exact word matches.\n\nHere's a simple example: if you search for \"pets,\" a vector database can return documents about dogs and cats, even if the word \"pets\" never appears in them. This capability powers modern AI applications, such as chatbots that can reason about your specific documents.\n\nChromaDB is particularly popular for its low learning curve. You can run it entirely on your machine, making it perfect for prototyping and learning before moving to production systems.\n\nInstalling ChromaDB is straightforward with pip:\n\n```\npip install chromadb\n```\n\nChromaDB works with Python 3.8 or higher, and the package includes everything needed for local usage.\n\nFor server-mode deployment (better suited for production), you can install the server extras:\n\n```\npip install chromadb[server]\n```\n\nThis gives you HTTP API support for connecting from other applications.\n\nLet's build a simple example from scratch. This code creates a persistent vector database, adds documents, and performs semantic search.\n\nA **persistent client** saves your data to disk so it's not lost when your program ends:\n\n``` python\nimport chromadb\n\n# Store data permanently on disk\nclient = chromadb.PersistentClient(path=\"./chroma_db\")\n```\n\nA **collection** is like a table in a traditional database—it stores your documents, embeddings, and metadata together:\n\n```\n# Get or create a collection (avoids duplicates)\ncollection = client.get_or_create_collection(name=\"my_documents\")\n```\n\nChromaDB can automatically generate embeddings for your text—you don't need to manage vectors manually:\n\n```\ncollection.add(\n    ids=[\"doc1\", \"doc2\", \"doc3\"],\n    documents=[\n        \"Dogs make wonderful companions and are known for their loyalty.\",\n        \"Cats are independent animals that make great pets for busy people.\",\n        \"I love driving fast cars on open highways.\"\n    ]\n)\n```\n\nEach document needs a unique ID, and Chroma handles the embedding process automatically.\n\nNow for the magic—querying by meaning rather than keywords:\n\n```\nresults = collection.query(\n    query_texts=[\"Tell me about animal companions\"],\n    n_results=2  # Return the top 2 most similar results\n)\n\nprint(results)\n```\n\nChroma returns documents that are semantically closest to your query. In this case, you'd likely get the dog and cat documents—not the car one.\n\nBehind the scenes, ChromaDB converts your documents into **embeddings**—numerical vectors that capture meaning. When you query, it calculates the distance between your query embedding and all stored embeddings using metrics like **cosine similarity** or **Euclidean distance**.\n\nChromaDB uses an indexing algorithm called **HNSW (Hierarchical Navigable Small World)** to find similar vectors quickly, even with millions of documents. This makes semantic search practical at scale.\n\nOnce you've got the fundamentals down, here are some directions to explore:\n\n`where`\n\nfiltersIf you are planning to handle more than 10 million users, you should use another vector database, such as Pinecone or Milvus. In this case, Milvus is free, while Pinecone is a paid service.", "url": "https://wpnews.pro/news/getting-started-with-chromadb-vector-database", "canonical_source": "https://dev.to/tarun6208/getting-started-with-chromadb-vector-database-4379", "published_at": "2026-07-14 10:41:19+00:00", "updated_at": "2026-07-14 10:58:09.746251+00:00", "lang": "en", "topics": ["artificial-intelligence", "large-language-models", "developer-tools", "ai-infrastructure"], "entities": ["ChromaDB", "Pinecone", "Milvus", "HNSW"], "alternates": {"html": "https://wpnews.pro/news/getting-started-with-chromadb-vector-database", "markdown": "https://wpnews.pro/news/getting-started-with-chromadb-vector-database.md", "text": "https://wpnews.pro/news/getting-started-with-chromadb-vector-database.txt", "jsonld": "https://wpnews.pro/news/getting-started-with-chromadb-vector-database.jsonld"}}