chroma
AIアプリケーション向けのオープンソース埋め込みデータベースで、embeddingとメタデータの保存、ベクトル検索・全文検索、メタデータによるフィルタリングをシンプルな4つのAPIで実現します。ノートブックから本番クラスターまでスケール可能で、セマンティック検索・RAGアプリ・ドキュメント検索などに活用できます。ローカル開発やオープンソースプロジェクトに最適です。
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.
SKILL.md 本文
Chroma - オープンソース埋め込みデータベース
LLM アプリケーションをメモリとともに構築するための AI ネイティブデータベース。
Chroma を使用する場合
以下の場合に Chroma を使用してください:
- RAG (検索増強生成) アプリケーションを構築する
- ローカル/セルフホスト型のベクトルデータベースが必要
- オープンソースソリューション (Apache 2.0) が欲しい
- ノートブックでプロトタイピングしている
- ドキュメントの意味検索
- メタデータ付きの埋め込みを保存している
メトリクス:
- GitHub スター 24,300+
- フォーク 1,900+
- v1.3.3 (安定版、週1回のリリース)
- Apache 2.0 ライセンス
代わりに別の選択肢を使用する場合:
- Pinecone: マネージドクラウド、自動スケーリング
- FAISS: 純粋な類似度検索、メタデータなし
- Weaviate: プロダクション ML ネイティブデータベース
- Qdrant: 高パフォーマンス、Rust ベース
クイックスタート
インストール
# Python
pip install chromadb
# JavaScript/TypeScript
npm install chromadb @chroma-core/default-embed
基本的な使用法 (Python)
import chromadb
# クライアントを作成
client = chromadb.Client()
# コレクションを作成
collection = client.create_collection(name="my_collection")
# ドキュメントを追加
collection.add(
documents=["This is document 1", "This is document 2"],
metadatas=[{"source": "doc1"}, {"source": "doc2"}],
ids=["id1", "id2"]
)
# クエリ
results = collection.query(
query_texts=["document about topic"],
n_results=2
)
print(results)
コア操作
1. コレクションを作成
# シンプルなコレクション
collection = client.create_collection("my_docs")
# カスタム埋め込み関数付き
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
)
# 既存のコレクションを取得
collection = client.get_collection("my_docs")
# コレクションを削除
client.delete_collection("my_docs")
2. ドキュメントを追加
# 自動生成 ID で追加
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"]
)
# カスタム埋め込みで追加
collection.add(
embeddings=[[0.1, 0.2, ...], [0.3, 0.4, ...]],
documents=["Doc 1", "Doc 2"],
ids=["id1", "id2"]
)
3. クエリ (類似度検索)
# 基本的なクエリ
results = collection.query(
query_texts=["machine learning tutorial"],
n_results=5
)
# フィルター付きクエリ
results = collection.query(
query_texts=["Python programming"],
n_results=3,
where={"source": "web"}
)
# メタデータフィルター付きクエリ
results = collection.query(
query_texts=["advanced topics"],
where={
"$and": [
{"category": "tutorial"},
{"difficulty": {"$gte": 3}}
]
}
)
# 結果にアクセス
print(results["documents"]) # マッチしたドキュメントのリスト
print(results["metadatas"]) # 各ドキュメントのメタデータ
print(results["distances"]) # 類似度スコア
print(results["ids"]) # ドキュメント ID
4. ドキュメントを取得
# ID で取得
docs = collection.get(
ids=["id1", "id2"]
)
# フィルター付きで取得
docs = collection.get(
where={"category": "tutorial"},
limit=10
)
# すべてのドキュメントを取得
docs = collection.get()
5. ドキュメントを更新
# ドキュメント内容を更新
collection.update(
ids=["id1"],
documents=["Updated content"],
metadatas=[{"source": "updated"}]
)
6. ドキュメントを削除
# ID で削除
collection.delete(ids=["id1", "id2"])
# フィルター付きで削除
collection.delete(
where={"source": "outdated"}
)
永続的なストレージ
# ディスクに永続化
client = chromadb.PersistentClient(path="./chroma_db")
collection = client.create_collection("my_docs")
collection.add(documents=["Doc 1"], ids=["id1"])
# データは自動的に永続化される
# 後で同じパスで再度読み込む
client = chromadb.PersistentClient(path="./chroma_db")
collection = client.get_collection("my_docs")
埋め込み関数
デフォルト (Sentence Transformers)
# デフォルトで sentence-transformers を使用
collection = client.create_collection("my_docs")
# デフォルトモデル: all-MiniLM-L6-v2
OpenAI
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
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
)
カスタム埋め込み関数
from chromadb import Documents, EmbeddingFunction, Embeddings
class MyEmbeddingFunction(EmbeddingFunction):
def __call__(self, input: Documents) -> Embeddings:
# あなたの埋め込みロジック
return embeddings
my_ef = MyEmbeddingFunction()
collection = client.create_collection(
name="custom_docs",
embedding_function=my_ef
)
メタデータフィルタリング
# 完全一致
results = collection.query(
query_texts=["query"],
where={"category": "tutorial"}
)
# 比較演算子
results = collection.query(
query_texts=["query"],
where={"page": {"$gt": 10}} # $gt, $gte, $lt, $lte, $ne
)
# 論理演算子
results = collection.query(
query_texts=["query"],
where={
"$and": [
{"category": "tutorial"},
{"difficulty": {"$lte": 3}}
]
} # また: $or
)
# 含む
results = collection.query(
query_texts=["query"],
where={"tags": {"$in": ["python", "ml"]}}
)
LangChain 統合
from langchain_chroma import Chroma
from langchain_openai import OpenAIEmbeddings
from langchain.text_splitter import RecursiveCharacterTextSplitter
# ドキュメントを分割
text_splitter = RecursiveCharacterTextSplitter(chunk_size=1000)
docs = text_splitter.split_documents(documents)
# Chroma ベクトルストアを作成
vectorstore = Chroma.from_documents(
documents=docs,
embedding=OpenAIEmbeddings(),
persist_directory="./chroma_db"
)
# クエリ
results = vectorstore.similarity_search("machine learning", k=3)
# レトリーバーとして
retriever = vectorstore.as_retriever(search_kwargs={"k": 5})
LlamaIndex 統合
from llama_index.vector_stores.chroma import ChromaVectorStore
from llama_index.core import VectorStoreIndex, StorageContext
import chromadb
# Chroma を初期化
db = chromadb.PersistentClient(path="./chroma_db")
collection = db.get_or_create_collection("my_collection")
# ベクトルストアを作成
vector_store = ChromaVectorStore(chroma_collection=collection)
storage_context = StorageContext.from_defaults(vector_store=vector_store)
# インデックスを作成
index = VectorStoreIndex.from_documents(
documents,
storage_context=storage_context
)
# クエリ
query_engine = index.as_query_engine()
response = query_engine.query("What is machine learning?")
サーバーモード
# Chroma サーバーを実行
# ターミナル: chroma run --path ./chroma_db --port 8000
# サーバーに接続
import chromadb
from chromadb.config import Settings
client = chromadb.HttpClient(
host="localhost",
port=8000,
settings=Settings(anonymized_telemetry=False)
)
# 通常通り使用
collection = client.get_or_create_collection("my_docs")
ベストプラクティス
- 永続的なクライアントを使用 - 再起動時にデータを失わない
- メタデータを追加 - フィルタリングと追跡を可能にする
- バッチ操作 - 複数のドキュメントを一度に追加
- 適切な埋め込みモデルを選択 - 速度と品質のバランスを取る
- フィルターを使用 - 検索スペースを狭める
- 一意の ID - 衝突を回避する
- 定期的なバックアップ - chroma_db ディレクトリをコピー
- コレクションサイズを監視 - 必要に応じてスケールアップ
- 埋め込み関数をテスト - 品質を確保
- 本番環境ではサーバーモードを使用 - マルチユーザーに最適
パフォーマンス
| 操作 | レイテンシ | 注記 |
|---|---|---|
| 100 個のドキュメントを追加 | ~1-3s | 埋め込み付き |
| クエリ (上位 10) | ~50-200ms | コレクションサイズに依存 |
| メタデータフィルター | ~10-50ms | 適切なインデックス付きで高速 |
リソース
- GitHub: https://github.com/chroma-core/chroma ⭐ 24,300+
- ドキュメント: https://docs.trychroma.com
- Discord: https://discord.gg/MMeYNTmh3x
- バージョン: 1.3.3+
- ライセンス: Apache 2.0
ライセンス: MIT(寛容ライセンスのため全文を引用しています) · 原本リポジトリ
詳細情報
- 作者
- davila7
- ライセンス
- MIT
- 最終更新
- 不明
Source: https://github.com/davila7/claude-code-templates / ライセンス: MIT
関連スキル
agent-browser
AI エージェント向けのブラウザ自動化 CLI です。ウェブサイトとの対話が必要な場合に使用します。ページ遷移、フォーム入力、ボタンクリック、スクリーンショット取得、データ抽出、ウェブアプリのテスト、ブラウザ操作の自動化など、あらゆるブラウザタスクに対応できます。「ウェブサイトを開く」「フォームに記入する」「ボタンをクリックする」「スクリーンショットを取得する」「ページからデータを抽出する」「このウェブアプリをテストする」「サイトにログインする」「ブラウザ操作を自動化する」といった要求や、プログラマティックなウェブ操作が必要なタスクで起動します。
anyskill
AnySkill — あなたのプライベート・スキルクラウド。GitHubを基盤としたリポジトリからエージェントスキルを管理、同期、動的にロードできます。自然言語でクラウドスキルを検索し、オンデマンドでプロンプトを自動ロード、カスタムスキルのアップロードと共有、スキルバンドルの一括インストールが可能です。OpenClaw、Antigravity、Claude Code、Cursorに対応しています。
engram
AIエージェント向けの永続的なメモリシステムです。バグ修正、意思決定、発見、設定変更の後はmem_saveを使用してください。ユーザーが「覚えている」「記憶している」と言及した場合、または以前のセッションと重複する作業を開始する際はmem_searchを使用します。セッション終了前にmem_session_summaryを使用して、コンテキストを保持してください。
skyvern
AI駆動のブラウザ自動化により、任意のウェブサイトを自動化できます。フォーム入力、データ抽出、ファイルダウンロード、ログイン、複数ステップのワークフロー実行など、ユーザーがウェブサイトと連携する必要があるときに使用します。Skyvernは、LLMとコンピュータビジョンを活用して、未知のサイトも自動操作可能です。Python SDK、TypeScript SDK、REST API、MCPサーバー、またはCLIを通じて統合できます。
pinchbench
PinchBenchベンチマークを実行して、OpenClawエージェントの実世界タスクにおけるパフォーマンスを評価できます。モデルの機能テスト、モデル間の比較、ベンチマーク結果のリーダーボード提出、またはOpenClawのセットアップがカレンダー、メール、リサーチ、コーディング、複数ステップのワークフローにどの程度対応しているかを確認する際に使用します。
openui
OpenUIとOpenUI Langを使用してジェネレーティブUIアプリを構築できます。これらはLLM生成インターフェースのためのトークン効率的なオープン標準です。OpenUI、@openuidev、ジェネレーティブUI、LLMからのストリーミングUI、AI向けコンポーネントライブラリ、またはjson-render/A2UIの置き換えについて述べる際に使用します。スキャフォルディング、defineComponent、システムプロンプト、Renderer、およびOpenUI Lang出力のデバッグに対応しています。