Chroma
ChromaVectorStore #
Bases: BaseVectorStore
Chroma is the AI-native open-source vector database. Embeddings are stored within a ChromaDB collection.
Attributes:
| Name | Type | Description |
|---|---|---|
embed_model |
BaseEmbedding
|
Embedding model used to compute vectors. |
collection_name |
str
|
Name of the ChromaDB collection. |
distance_strategy |
str
|
Distance strategy for similarity search.
Currently supports |
Example
from beekeeper.embeddings.huggingface import HuggingFaceEmbedding
from beekeeper.vector_stores.chroma import ChromaVectorStore
embedding = HuggingFaceEmbedding()
vector_db = ChromaVectorStore(embed_model=embedding)
model_post_init #
model_post_init(__context)
Initialize ChromaDB client and collection after Pydantic validation.
add_documents #
add_documents(documents: list[Document]) -> list
Add documents to the ChromaDB collection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
documents
|
list[Document]
|
List of documents to add to the collection. |
required |
query_documents #
query_documents(query: str, top_k: int = 4) -> list[DocumentWithScore]
Performs a similarity search for the top-k most similar documents.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Query text. |
required |
top_k
|
int
|
Number of top results to return. Defaults to |
4
|
Returns:
| Type | Description |
|---|---|
list[DocumentWithScore]
|
list[DocumentWithScore]: List of the most similar documents. |
delete_documents #
delete_documents(ids: list[str]) -> None
Delete documents from the ChromaDB collection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ids
|
list[str]
|
List of |
required |
get_all_documents #
get_all_documents(include_fields: list[str] | None = None) -> list[Document]
Get all documents from vector store.