🎨

ChromaDB

Libasebedisi tsa data tsa vector

Open-sourcembedding database e thehiloe bakeng sa li-applications tsa AI. E bonolo, e ka thehoa, le Python-first

Lintlha tsa ho kenya

Ho romelloa ha basebetsi: 2-5 min
sehlopha: Libasebedisi tsa data tsa vector
RAM e tlase: 1024MB
Tšehetso: Litekete le imeile

Tseba lengolo lena

Tlhaloso

ChromaDB ke database ea vector e nang le mohloli o bulehileng e etselitsoeng ho aha lits'ebetso tsa AI tse thehiloeng ho li-model tse kholo tsa puo (LLM) le ho kenya lintlha ka mokhoa oa embedding. Joalo ka database ea embedding e thehiloeng ho AI, ChromaDB e etsa hore ho be bonolo ho aha lits'ebetso tsa LLM ka ho fana ka tharollo e potlakileng ka ho makatsa le e bonolo ho bahlahisi bakeng sa ho boloka le ho batla li-vector embedding hammoho le metadata.

Ka pelo ea ChromaDB ho na le tsepamiso ea eona bonolong le boiphihlelo ba bahlahisi. Ho fapana le li-database tsa setso tse hlokang tlhophiso e rarahaneng, ChromaDB e ka sebetsa ka mela e seng mekae feela ea khoutu ea Python. E etselitsoe ho utloahala e le ea Python le ho ba bonolo ho utloisisa, e na le API e hlakileng e ntšang ho rarahana ha ho batla kamano ea vector empa e ntse e fana ka mesebetsi e matla ha ho hlokahala.

ChromaDB e atleha ho batla ka sebopeho sa semantics le retrieval-augmented generation (RAG), mekhoa e 'meli e tloaelehileng ka ho fetisisa litlhophisong tsa LLM. Ha u botsa LLM potso ka RAG, ChromaDB e fumana moelelo o amehang ka ho fetisisa ho tsoa setsing sa hau sa tsebo ka ho etsa lipatlisiso tsa ho tšoana ho li-vector embedding. Sena se lumella lits'ebetso tsa AI ho fihlella le ho sebetsa ka data ea hau ea sebele, litokomane kapa litsebo tsa tsebo ntle le ho lokisa mohlala o felletseng.

Database e boloka li-embedding (li-vector tse nang le likarolo tse ngata tse emelang mongolo, lifano kapa data e ling) hammoho le metadata le litokomane tse amanang le tsona. ChromaDB e sebetsana le ts'ebetso ea ho hlahisa embedding ka bonolo ka likopanyo le mefuta e tummeng ea embedding joalo ka OpenAI, Cohere le Sentence Transformers. U fana feela ka litokomane tsa hau, ebe ChromaDB e nka boikarabelo ba ho hlahisa le ho boloka li-embedding.

ChromaDB e fana ka mekhoa e mengata ea ts'ebetso ho ipapisa le litlhoko tsa hau. E sebetse ka memory bakeng sa nts'etsopele le ho leka, boloka disk bakeng sa litsamaiso tsa mochine o le mong, kapa atoloha ka ho hokahanya lits'ebetso tsa client-server tse aroloang bakeng sa mosebetsi oa tlhahiso. Mokhoa oa seva o tšehetsa netefatso, multi-tenancy, mme o ka sebetsana le li-embedding tsa limilione tse likete tse ngata ho feta li-collection tse likete.

Ka tšehetso e kahare bakeng sa filtering, metadata queries le bokhoni ba hybrid search, ChromaDB e lumella maano a retrieval a rarahaneng ho feta ts'ebetso e bonolo ea ho tšoana ha vector. U ka kopanya ho batla ka semantics le filtering ea mantsoe, linako tsa letsatsi, kapa metadata ea boikhethelo bakeng sa ho lebisa ka nepo tlhaiso-leseling eo LLM ea hau e e hlokang. Sesebelisoa se boetse se kenyelletsa likarolo tsa observability ho thusa ho utloisisa le ho ntlafatsa ts'ebetso ea ho batla ha vector.

Likarolo tsa bohlokoa

API ea Python e bonolo

Sebopeho se bonolo le se hlakileng sa Python, se nang le tlhophiso e fokolang - qala ho botsa li-embeddings ka mela e 3 feela ea khoutu

Tšehetso ea Embedding e Kakehileng ka Hare

Ho hlahisa embedding ka boyeona ka OpenAI, Cohere, Sentence Transformers le mesebetsi ea embedding ea tlhophiso

Semantic Search le RAG

Ho batla ho tšoana ka potlako haholo ho lokelletsoe bakeng sa retrieval-augmented generation le lits'ebetso tsa LLM

Kenyo e Bonolo

Sebetsa ka memory, boloka disk, kapa sebelisa client-server e aroloang e atolohang ka mokhoa o lekanyang

Filtering e Matla ea Metadata

Kopanya ho tšoana ha vector le li-filter tsa metadata, linako tsa letsatsi le boolean logic bakeng sa ho khutlisa ka nepo

Likarolo tse Lokelletsoeng Tlhahiso

Multi-tenancy, netefatso, observability, backup/khutlisa le tšehetso ea li-embedding tsa limilione tse likete tse ngata

Mehlala ea ho sebelisa

• Retrieval-Augmented Generation (RAG): Fana ka moelelo o amehang ho LLM ho tsoa setsing sa hau sa tsebo bakeng sa likarabo tse nepahetseng, tse ikhethang ho sebaka
• Lits'ebetso tsa Semantic Search: Aha mechini ea patlo e hlalosang moelelo le morero ho feta ho tšoana ha mantsoe
• Litsamaiso tsa Ho Araba Lipotso: Theha li-chatbot le bathusi ba virtual ba ka arabang lipotso ka litokomane tsa hau tsa boiphihlelo
• Tlhahlobo ea Litokomane: Nolofalletsa AI ho batla le ho hlahloba li-collection tse kholo tsa litokomane (molao, bongaki, lipampiri tsa lipatlisiso)
• Litsamaiso tsa Litlhahiso: Fana ka litlhahiso tsa litaba ho ipapisa le ho tšoana ha moelelo ho e-na le filtering ea collaborative
• Patlo ea Khoutu: Thusa bahlahisi ho fumana li-snippet tsa khoutu le litokomane ho li-codebase tse kholo
• Patlo ea Multi-Modal: Batla ho tloha mongolong, litšoantšong le mehlaleng e meng ea data ka ho tšoana ho thehiloeng ho embedding

Litaelo tsa ho kenya

Kenyo ho Ubuntu VPS:

1. Kenya Python le Litšebelisoa Tse Hlokahalang:
sudo apt update && sudo apt upgrade -y
sudo apt install python3.10 python3-pip python3-venv -y
2. Theha Tikoloho e Ikemetseng ea Virtual:
mkdir chromadb-server
cd chromadb-server
python3 -m venv venv
source venv/bin/activate
3. Kenya ChromaDB:
pip install chromadb
4. Teko e Potlakileng (Mokhoa oa Memory):
import chromadb

# Create client
client = chromadb.Client()

# Create collection
collection = client.create_collection(name="test_collection")

# Add documents
collection.add(
    documents=["This is a document", "This is another document"],
    metadatas=[{"source": "doc1"}, {"source": "doc2"}],
    ids=["id1", "id2"]
)

# Query
results = collection.query(
    query_texts=["This is a query document"],
    n_results=2
)

print(results)
5. Kenya Seva ea ChromaDB (Tlhahiso):
pip install chromadb[server]
6. Sebetsa Seva ea ChromaDB:
# Start server on localhost:8000
chroma run --path ./chroma_data --host 0.0.0.0 --port 8000

# Or with authentication
export CHROMA_SERVER_AUTH_CREDENTIALS="admin:secure_password"
export CHROMA_SERVER_AUTH_PROVIDER="chromadb.auth.basic.BasicAuthServerProvider"
chroma run --path ./chroma_data --host 0.0.0.0 --port 8000
7. Kenyo ea Docker (E khothaletsoang bakeng sa tlhahiso):
# Create docker-compose.yml
cat > docker-compose.yml << 'EOF'
version: '3.8'

services:
  chromadb:
    image: chromadb/chroma:latest
    container_name: chromadb
    ports:
      - "8000:8000"
    volumes:
      - ./chroma_data:/chroma/chroma
    environment:
      - CHROMA_SERVER_AUTH_CREDENTIALS=admin:secure_password
      - CHROMA_SERVER_AUTH_PROVIDER=chromadb.auth.basic.BasicAuthServerProvider
      - IS_PERSISTENT=TRUE
      - ANONYMIZED_TELEMETRY=FALSE
    restart: unless-stopped
EOF

# Start service
docker-compose up -d

# Check logs
docker-compose logs -f chromadb
8. Hlophisa Tšebeletso ea systemd (Ntle le Docker):
sudo nano /etc/systemd/system/chromadb.service
Kenya:
[Unit]
Description=ChromaDB Server
After=network.target

[Service]
Type=simple
User=ubuntu
WorkingDirectory=/home/ubuntu/chromadb-server
Environment="PATH=/home/ubuntu/chromadb-server/venv/bin"
Environment="CHROMA_SERVER_AUTH_CREDENTIALS=admin:secure_password"
Environment="CHROMA_SERVER_AUTH_PROVIDER=chromadb.auth.basic.BasicAuthServerProvider"
ExecStart=/home/ubuntu/chromadb-server/venv/bin/chroma run --path /home/ubuntu/chromadb-server/chroma_data --host 0.0.0.0 --port 8000
Restart=always

[Install]
WantedBy=multi-user.target
Nolofalletsa 'me u qale:
sudo systemctl daemon-reload
sudo systemctl enable chromadb
sudo systemctl start chromadb
sudo systemctl status chromadb
9. Hlophisa Nginx Reverse Proxy:
sudo nano /etc/nginx/sites-available/chromadb
Kenya:
server {
    listen 80;
    server_name chroma.yourdomain.com;

    location / {
        proxy_pass http://localhost:8000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}
Nolofalletsa 'me u fumane SSL:
sudo ln -s /etc/nginx/sites-available/chromadb /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx
sudo certbot --nginx -d chroma.yourdomain.com
10. Leka Likhokahano:
import chromadb

# Connect to server
client = chromadb.HttpClient(
    host='chroma.yourdomain.com',
    port=443,
    ssl=True,
    headers={"Authorization": "Basic YWRtaW46c2VjdXJlX3Bhc3N3b3Jk"}  # base64 of admin:secure_password
)

# List collections
print(client.list_collections())

Litlhahiso tsa ho kenya

Litlhophiso tse Hlokahalang:

1. Tlhophiso ea Client:
import chromadb
from chromadb.config import Settings

# In-memory (development)
client = chromadb.Client()

# Persistent (single machine)
client = chromadb.PersistentClient(path="/path/to/chroma/data")

# HTTP Client (production)
client = chromadb.HttpClient(
    host='localhost',
    port=8000,
    settings=Settings(
        chroma_client_auth_provider="chromadb.auth.basic.BasicAuthClientProvider",
        chroma_client_auth_credentials="admin:password"
    )
)
2. Taolo ea Collection:
# Create collection with custom embedding function
collection = client.create_collection(
    name="my_collection",
    embedding_function=chromadb.utils.embedding_functions.OpenAIEmbeddingFunction(
        api_key="your-openai-key",
        model_name="text-embedding-3-small"
    ),
    metadata={"description": "My vector collection"}
)

# Get or create collection
collection = client.get_or_create_collection(name="my_collection")

# Delete collection
client.delete_collection(name="my_collection")
3. Ho Eketsa Litokomane:
collection.add(
    documents=["Document 1 text", "Document 2 text", "Document 3 text"],
    metadatas=[
        {"source": "web", "date": "2024-01-01"},
        {"source": "pdf", "date": "2024-01-02"},
        {"source": "api", "date": "2024-01-03"}
    ],
    ids=["id1", "id2", "id3"]
)

# Add with custom embeddings
collection.add(
    embeddings=[[0.1, 0.2, 0.3], [0.4, 0.5, 0.6]],
    documents=["doc1", "doc2"],
    ids=["id1", "id2"]
)
4. Ho Batla ka Filtering:
# Semantic search
results = collection.query(
    query_texts=["What is RAG?"],
    n_results=10
)

# With metadata filtering
results = collection.query(
    query_texts=["What is RAG?"],
    n_results=10,
    where={"source": "web"},  # Exact match
    where_document={"$contains": "retrieval"}  # Full-text search
)

# Complex filters
results = collection.query(
    query_texts=["machine learning"],
    n_results=5,
    where={
        "$and": [
            {"source": {"$in": ["web", "pdf"]}},
            {"date": {"$gte": "2024-01-01"}}
        ]
    }
)
5. Mesebetsi ea Embedding:
# OpenAI embeddings
from chromadb.utils.embedding_functions import OpenAIEmbeddingFunction
embedding_fn = OpenAIEmbeddingFunction(
    api_key="your-key",
    model_name="text-embedding-3-small"
)

# Sentence Transformers (local)
from chromadb.utils.embedding_functions import SentenceTransformerEmbeddingFunction
embedding_fn = SentenceTransformerEmbeddingFunction(
    model_name="all-MiniLM-L6-v2"
)

# Cohere embeddings
from chromadb.utils.embedding_functions import CohereEmbeddingFunction
embedding_fn = CohereEmbeddingFunction(
    api_key="your-cohere-key",
    model_name="embed-english-v3.0"
)

# Custom embedding function
from chromadb import EmbeddingFunction
class MyEmbeddingFunction(EmbeddingFunction):
    def __call__(self, texts):
        # Your embedding logic here
        return embeddings
6. Ho Ntlafatsa le ho Hlakola:
# Update documents
collection.update(
    ids=["id1"],
    documents=["Updated document text"],
    metadatas=[{"source": "updated"}]
)

# Delete by IDs
collection.delete(ids=["id1", "id2"])

# Delete by filter
collection.delete(where={"source": "old"})
7. Mefuta ea Tikoloho (Seva):
# Authentication
export CHROMA_SERVER_AUTH_CREDENTIALS="admin:password"
export CHROMA_SERVER_AUTH_PROVIDER="chromadb.auth.basic.BasicAuthServerProvider"

# Persistence
export IS_PERSISTENT=TRUE
export PERSIST_DIRECTORY=/path/to/data

# Performance
export CHROMA_SERVER_HTTP_PORT=8000
export CHROMA_OTEL_COLLECTION_ENDPOINT=""  # Disable telemetry
export ANONYMIZED_TELEMETRY=FALSE
8. Ntlafatso ea Ts'ebetso:
# Batch operations
collection.add(
    documents=large_document_list,
    ids=large_id_list,
    metadatas=large_metadata_list
)

# Use persistent client for disk caching
client = chromadb.PersistentClient(path="./chroma_data")

# Optimize n_results for speed
results = collection.query(query_texts=["query"], n_results=10)  # Lower is faster
Mekhoa e Molemo ka ho Fetisisa:
- Sebelisa mokhoa o tsoelang pele kapa oa seva bakeng sa tlhahiso (e seng ea memory feela)
- Eketsa litokomane ka li-batch ho ntlafatsa ts'ebetso
- Khetha mehlala e loketseng ea embedding (kamano ea boholo le ho nepahala)
- Lenaneha linthlo tsa metadata tseo u li sefang khafetsa
- Sebelisa mabitso a collection le metadata a nang le moelelo
- Kenya netefatso e nepahetseng mokhoeng oa seva
- Etsa backup ka mehla ea directory ea chroma_data
- Lekola litšenyehelo tsa ho hlahisa embedding (mehlala e thehiloeng ho API)
- Sebelisa mehlala ea embedding ea lehae (Sentence Transformers) ho boloka litšenyehelo
- Kenya logic ea ho leka hape bakeng sa mesebetsi ea embedding e thehiloeng ho API

Likopo tsa theknoloji

Litaelo tsa sistimi

  • Khopolo: 1024MB RAM

Lekanya Sengoloa sena

★★★★★
-
Ho kenya...

Na o se o loketse ho kenya kopo ya hao? ChromaDB?

Qala ka metsotsoana ka ts'ebetso ea rona e bonolo ea ho kenya VPS

Ho kenya ka ho ka bang 2 metsotso • Full root ho kena • Thuto ka terene le lengolo tsoibila