鱼皮AI导航
鱼皮AI导航
  • 主页
  • 社区
  • AI工具
  • AI知识库
  • AI提示词
  • MCP
  • Skills
  • AI学习资源
  • AI资讯
  • GitHub开源
登录/注册

rag-chroma

提供嵌入式数据存储与检索能力,支持向量搜索、全文匹配及元数据过滤,适用于构建本地化语义搜索、RAG 应用和文档召回系统,兼顾开发灵活性与生产部署需求。

数据与分析数据库研究
访问 GitHub
文档Skills.MD
name
chroma
description
Open-source embedding database for AI applications. Store embeddings and metadata, perform vector and full-text search, filter by metadata. Simple 4-function API. Scales from notebooks to production clusters. Use for semantic search, RAG applications, or document retrieval. Best for local development and open-source projects.
version
1.0.0
author
Orchestra Research
license
MIT
tags["RAG","Chroma","Vector Database","Embeddings","Semantic Search","Open Source","Self-Hosted","Document Retrieval","Metadata Filtering"]
dependencies["chromadb","sentence-transformers"]

Chroma - Open-Source Embedding Database

The AI-native database for building LLM applications with memory.

When to use Chroma

Use Chroma when:

  • Building RAG (retrieval-augmented generation) applications
  • Need local/self-hosted vector database
  • Want open-source solution (Apache 2.0)
  • Prototyping in notebooks
  • Semantic search over documents
  • Storing embeddings with metadata

Metrics:

  • 24,300+ GitHub stars
  • 1,900+ forks
  • v1.3.3 (stable, weekly releases)
  • Apache 2.0 license

Use alternatives instead:

  • Pinecone: Managed cloud, auto-scaling
  • FAISS: Pure similarity search, no metadata
  • Weaviate: Production ML-native database
  • Qdrant: High performance, Rust-based

Quick start

Installation

▼
bash
复制代码
# Python pip install chromadb # JavaScript/TypeScript npm install chromadb @chroma-core/default-embed

Basic usage (Python)

▼
python
复制代码
import chromadb # Create client client = chromadb.Client() # Create collection collection = client.create_collection(name="my_collection") # Add documents collection.add( documents=["This is document 1", "This is document 2"], metadatas=[{"source": "doc1"}, {"source": "doc2"}], ids=["id1", "id2"] ) # Query results = collection.query( query_texts=["document about topic"], n_results=2 ) print(results)

Core operations

1. Create collection

▼
python
复制代码
# Simple collection collection = client.create_collection("my_docs") # With custom embedding function from chromadb.utils import embedding_functions openai_ef = embedding_functions.OpenAIEmbeddingFunction( api_key="your-key", model_name="text-embedding-3-small" ) collection = client.create_collection( name="my_docs", embedding_function=openai_ef ) # Get existing collection collection = client.get_collection("my_docs") # Delete collection client.delete_collection("my_docs")

2. Add documents

▼
python
复制代码
# Add with auto-generated IDs collection.add( documents=["Doc 1", "Doc 2", "Doc 3"], metadatas=[ {"source": "web", "category": "tutorial"}, {"source": "pdf", "page": 5}, {"source": "api", "timestamp": "2025-01-01"} ], ids=["id1", "id2", "id3"] ) # Add with custom embeddings collection.add( embeddings=[[0.1, 0.2, ...], [0.3, 0.4, ...]], documents=["Doc 1", "Doc 2"], ids=["id1", "id2"] )

3. Query (similarity search)

▼
python
复制代码
# Basic query results = collection.query( query_texts=["machine learning tutorial"], n_results=5 ) # Query with filters results = collection.query( query_texts=["Python programming"], n_results=3, where={"source": "web"} ) # Query with metadata filters results = collection.query( query_texts=["advanced topics"], where={ "$and": [ {"category": "tutorial"}, {"difficulty": {"$gte": 3}} ] } ) # Access results print(results["documents"]) # List of matching documents print(results["metadatas"]) # Metadata for each doc print(results["distances"]) # Similarity scores print(results["ids"]) # Document IDs

4. Get documents

▼
python
复制代码
# Get by IDs docs = collection.get( ids=["id1", "id2"] ) # Get with filters docs = collection.get( where={"category": "tutorial"}, limit=10 ) # Get all documents docs = collection.get()

5. Update documents

▼
python
复制代码
# Update document content collection.update( ids=["id1"], documents=["Updated content"], metadatas=[{"source": "updated"}] )

6. Delete documents

▼
python
复制代码
# Delete by IDs collection.delete(ids=["id1", "id2"]) # Delete with filter collection.delete( where={"source": "outdated"} )

Persistent storage

▼
python
复制代码
# Persist to disk client = chromadb.PersistentClient(path="./chroma_db") collection = client.create_collection("my_docs") collection.add(documents=["Doc 1"], ids=["id1"]) # Data persisted automatically # Reload later with same path client = chromadb.PersistentClient(path="./chroma_db") collection = client.get_collection("my_docs")

Embedding functions

Default (Sentence Transformers)

▼
python
复制代码
# Uses sentence-transformers by default collection = client.create_collection("my_docs") # Default model: all-MiniLM-L6-v2

OpenAI

▼
python
复制代码
from chromadb.utils import embedding_functions openai_ef = embedding_functions.OpenAIEmbeddingFunction( api_key="your-key", model_name="text-embedding-3-small" ) collection = client.create_collection( name="openai_docs", embedding_function=openai_ef )

HuggingFace

▼
python
复制代码
huggingface_ef = embedding_functions.HuggingFaceEmbeddingFunction( api_key="your-key", model_name="sentence-transformers/all-mpnet-base-v2" ) collection = client.create_collection( name="hf_docs", embedding_function=huggingface_ef )

Custom embedding function

▼
python
复制代码
from chromadb import Documents, EmbeddingFunction, Embeddings class MyEmbeddingFunction(EmbeddingFunction): def __call__(self, input: Documents) -> Embeddings: # Your embedding logic return embeddings my_ef = MyEmbeddingFunction() collection = client.create_collection( name="custom_docs", embedding_function=my_ef )

Metadata filtering

▼
python
复制代码
# Exact match results = collection.query( query_texts=["query"], where={"category": "tutorial"} ) # Comparison operators results = collection.query( query_texts=["query"], where={"page": {"$gt": 10}} # $gt, $gte, $lt, $lte, $ne ) # Logical operators results = collection.query( query_texts=["query"], where={ "$and": [ {"category": "tutorial"}, {"difficulty": {"$lte": 3}} ] } # Also: $or ) # Contains results = collection.query( query_texts=["query"], where={"tags": {"$in": ["python", "ml"]}} )

LangChain integration

▼
python
复制代码
from langchain_chroma import Chroma from langchain_openai import OpenAIEmbeddings from langchain.text_splitter import RecursiveCharacterTextSplitter # Split documents text_splitter = RecursiveCharacterTextSplitter(chunk_size=1000) docs = text_splitter.split_documents(documents) # Create Chroma vector store vectorstore = Chroma.from_documents( documents=docs, embedding=OpenAIEmbeddings(), persist_directory="./chroma_db" ) # Query results = vectorstore.similarity_search("machine learning", k=3) # As retriever retriever = vectorstore.as_retriever(search_kwargs={"k": 5})

LlamaIndex integration

▼
python
复制代码
from llama_index.vector_stores.chroma import ChromaVectorStore from llama_index.core import VectorStoreIndex, StorageContext import chromadb # Initialize Chroma db = chromadb.PersistentClient(path="./chroma_db") collection = db.get_or_create_collection("my_collection") # Create vector store vector_store = ChromaVectorStore(chroma_collection=collection) storage_context = StorageContext.from_defaults(vector_store=vector_store) # Create index index = VectorStoreIndex.from_documents( documents, storage_context=storage_context ) # Query query_engine = index.as_query_engine() response = query_engine.query("What is machine learning?")

Server mode

▼
python
复制代码
# Run Chroma server # Terminal: chroma run --path ./chroma_db --port 8000 # Connect to server import chromadb from chromadb.config import Settings client = chromadb.HttpClient( host="localhost", port=8000, settings=Settings(anonymized_telemetry=False) ) # Use as normal collection = client.get_or_create_collection("my_docs")

Best practices

  1. Use persistent client - Don't lose data on restart
  2. Add metadata - Enables filtering and tracking
  3. Batch operations - Add multiple docs at once
  4. Choose right embedding model - Balance speed/quality
  5. Use filters - Narrow search space
  6. Unique IDs - Avoid collisions
  7. Regular backups - Copy chroma_db directory
  8. Monitor collection size - Scale up if needed
  9. Test embedding functions - Ensure quality
  10. Use server mode for production - Better for multi-user

Performance

OperationLatencyNotes
Add 100 docs~1-3sWith embedding
Query (top 10)~50-200msDepends on collection size
Metadata filter~10-50msFast with proper indexing

Resources

  • GitHub: https://github.com/chroma-core/chroma ⭐ 24,300+
  • Docs: https://docs.trychroma.com
  • Discord: https://discord.gg/MMeYNTmh3x
  • Version: 1.3.3+
  • License: Apache 2.0
数据与分析
数据库
研究

快捷安装

复制到终端去安装 Skill

npxskillsadddavila7/claude-code-templates--skill"rag-chroma"
站长:程序员鱼皮 老鱼简历 商务合作 增值电信业务经营许可证
2026 鱼皮AI导航 | 沪ICP备19026706号-6
站长:程序员鱼皮 老鱼简历 商务合作 增值电信业务经营许可证
2026 鱼皮AI导航 | 沪ICP备19026706号-6
🔥热门工具
朱雀AI检测朱雀AI检测
朱雀AI检测助手朱雀AI检测助手
LovartLovart
老鱼简历老鱼简历
WritePass官网WritePass官网
面多多面多多
CursorCursor
星月写作星月写作
朱雀AI检测助手朱雀AI检测助手
零感AI零感AI
Skills 推荐
definition-of-done-generator
自动生成项目完成标准的规范定义与配置文件,提供符合企业级工作流要求的最佳实践指导,输出可直接投入生产环境的代码和验证结果,适用于需要标准化流程审批、合规审查及跨系统集成的复杂项目管理场景。
sagemaker-endpoint-deployer
自动化部署机器学习模型至云端服务端点,支持从配置生成到生产验证的全流程,适用于模型上线、服务监控与推理优化等场景,确保部署方案符合工业级标准。
docx
支持专业级 Word 文档的全生命周期处理,包括从零创建结构化文档、精准编辑内容、管理修订痕迹与批注、提取纯文本或原始 XML 数据、转换为 PDF 或图像用于视觉分析,适用于法律、学术及企业场景下的高保真文档协作与自动化处理。
skills-search
提供对 Claude Code 技能生态的全周期管理能力,支持按功能关键词检索技能、查看详细信息、安装或卸载指定技能,并区分用户级与项目级作用域,覆盖发现、评估、部署及维护各环节。
moai-foundation-core
构建高质量、可扩展的AI开发工作流,通过领域驱动设计与模块化架构实现需求规范先行,结合自动化质量门禁、精细化上下文管理与渐进式知识呈现,在保障安全与可维护性的同时提升开发效率与协作清晰度。