Embeddings made easy
Chroma has all the tools you need to use embeddings
install and run chroma
pip install chromadb
chroma run # run the server
the core API is 4 commands
Python
# python can also run in-memory with no server running: chromadb.PersistentClient()
import chromadb
client = chromadb.HttpClient()
collection = client.create_collection("sample_collection")
# Add docs to the collection. Can also update and delete. Row-based API coming soon!
collection.add(
documents=["This is document1", "This is document2"], # we embed for you, or bring your own
metadatas=[{"source": "notion"}, {"source": "google-docs"}], # filter on arbitrary metadata!
ids=["doc1", "doc2"], # must be unique for each doc
)
results = collection.query(
query_texts=["This is a query document"],
n_results=2,
# where={"metadata_field": "is_equal_to_this"}, # optional filter
# where_document={"$contains":"search_string"} # optional filter
)
Javascript
// install the JS client and the (optional) default embedding function
npm install --save chromadb chromadb-default-embed
// set "type": "module" in your package.json
import { ChromaClient } from 'chromadb'
async function chromaExample() {
const client = new ChromaClient();
const collection = await client.createCollection({name: "sample_collection"});
await collection.add({
documents: ["This is a document", "This is another document"], // we embed for you, or bring your own
metadatas: [{ source: "my_source" }, { source: "my_source" }], // filter on arbitrary metadata!
ids: ["id1", "id2"] // must be unique for each doc
});
const results = await collection.query({
queryTexts: ["This is a query document"],
nResults: 2,
// where: {"metadata_field": "is_equal_to_this"}, // optional filter
// whereDocument: {"$contains":"search_string"} // optional filter
});
}
chromaExample();
Roadmap
Chroma is an open-source vector database. Pick up an issue, create a PR, or participate in our Discord and let the community know what features you would like.
Community Town Halls
Chroma runs a Community Town Hall once a month. Please join the community!
Register© 2023 Chroma. All rights reserved