Skip to content

Commit 3c3fbc7

Browse files
authored
feat: Performance tips (#43)
1 parent 9f94c32 commit 3c3fbc7

File tree

2 files changed

+72
-1
lines changed

2 files changed

+72
-1
lines changed

docs/index.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ This is a collection of small guides and recipes to help you get started with Ch
66

77
If you are using Chroma `>=0.5.7` and `<=0.5.13` please upgrade to `0.5.13` as there is a critical bug that can cause data loss. Read more on the [GH Issue #2922](https://github.com/chroma-core/chroma/issues/2922).
88

9-
Latest ChromaDB version: [0.5.13](https://github.com/chroma-core/chroma/releases/tag/0.5.13)
9+
Latest ChromaDB version: [0.5.15](https://github.com/chroma-core/chroma/releases/tag/0.5.15)
1010

1111

1212
## New and Noteworthy
1313

14+
- 🏎️ [Performance Tips](running/performance-tips.md) - Learn how to optimize the performance of yourChroma - 📅`16-Oct-2024`
1415
- ⁉️[FAQs](faq/index.md) - Updated FAQ sections - 📅`15-Oct-2024`
1516
- 🔥 [SSL-Terminating Proxies](security/ssl-proxies.md) - Learn how to secure Chroma server with `Envoy` or `Nginx` proxies - 📅`31-Jul-2024`
1617
- 🗑️ [WAL Pruning](core/advanced/wal-pruning.md#chroma-cli) - Learn how to prune (cleanup) your Chroma database (WAL) with Chroma's built-in CLI `vacuum` command - 📅`30-Jul-2024`

docs/running/performance-tips.md

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Performance Tips
2+
3+
This section covers tips and tricks of how to improve your Chroma performance.
4+
5+
## Rebuild HNSW for your architecutre
6+
7+
Single node chroma [core package](https://pypi.org/project/chromadb/) and [server](https://hub.docker.com/r/chromadb/chroma) ship with a default HNSW build which is optimized for maximum compatibility. The default HNSW does not make use of available optimization for your CPU architecture such as SIMD/AVX.
8+
9+
10+
You can rebuild the HNSW index for the core package or the server as follows.
11+
12+
=== "Core Package"
13+
14+
To rebuild the HNSW index locally you may need to install build tooling such as `gcc` depending on your operating system.
15+
16+
```bash
17+
pip install --no-binary :all: chroma-hnswlib
18+
```
19+
20+
=== "Server"
21+
22+
In the following snippet, we clone the Chroma repository (you'll need git and docker installed), and then build a new docker image with the HNSW rebuild flag set to `true`.
23+
24+
```bash
25+
git clone https://github.com/chroma-core/chroma.git && cd chroma
26+
docker build --build-arg REBUILD_HNSWLIB=true -t my-chroma-image:latest .
27+
```
28+
29+
??? "Need help?"
30+
31+
If you need help with the above steps, please reach out to us on [Discord](https://discord.gg/MMeYNTmh3x) (look for `@taz`)
32+
33+
## Reducing (shortening) the dimensionality of your embeddings
34+
35+
Some embeddings models (or APIs) offer the ability to reduce the dimensionality of the resulting embeddings. This is a great way to reduce the storage and memory requirements of your Chroma.
36+
37+
Currently the following embedding functions support this feature:
38+
39+
- OpenAI with 3rd generation models (i.e. `text-embedding-3-small` and `text-embedding-3-large`)
40+
41+
42+
### OpenAI Example
43+
44+
For more information on shortening embeddings see the official [OpenAI Blog post](https://openai.com/index/new-embedding-models-and-api-updates/).
45+
46+
=== "Python"
47+
48+
```python
49+
from chromadb.utils.embedding_functions.openai_embedding_function import (
50+
OpenAIEmbeddingFunction,
51+
)
52+
import os
53+
54+
ef = OpenAIEmbeddingFunction(api_key=os.environ["OPENAI_API_KEY"], model_name="text-embedding-3-small", dimensions=64)
55+
embeddings = ef(["hello world"])
56+
```
57+
58+
=== "Javascript"
59+
60+
```javascript
61+
62+
import {OpenAIEmbeddingFunction} from "chromadb"
63+
64+
const embedder = new OpenAIEmbeddingFunction({
65+
openai_api_key: process.env.OPENAI_API_KEY,
66+
openai_embedding_dimensions: 64,
67+
openai_model: "text-embedding-3-small",
68+
});
69+
const embeddings = embedder.generate(["hello world"]);
70+
```

0 commit comments

Comments
 (0)