વેક્ટર ડેટાબેઝો
AI કાર્યક્રમો માટે બનાવેલ ઓપન-સોર્સ જડિત ડેટાબેઝ. સરળ, માપન કરી શકાય તેવું, અને Python-first
ન્યૂનતમ સેટઅપ સાથે સહજ, pythonic ઇન્ટરફેસ - કોડની માત્ર 3 લાઇનમાં એમ્બેડિંગ ક્વેરી કરવાનું શરૂ કરો
OpenAI, Cohere, Sentence Transformers અને કસ્ટમ એમ્બેડિંગ ફંક્શન્સ સાથે સ્વચાલિત એમ્બેડિંગ જનરેશન
રિટ્રીવલ ઓગ્મેન્ટેડ જનરેશન અને LLM એપ્લિકેશન્સ માટે ઑપ્ટિમાઇઝ કરેલી અતિ ઝડપી સમાનતા શોધ
ઇન મેમરી ચલાવો, ડિસ્ક પર પર્સિસ્ટ કરો, અથવા આડા સ્કેલિંગ સાથે ડિસ્ટ્રિબ્યુટેડ ક્લાયંટ સર્વર તરીકે ડિપ્લોય કરો
ચોક્કસ રિટ્રીવલ માટે વેક્ટર સમાનતાને મેટાડેટા ફિલ્ટર, તારીખ શ્રેણીઓ અને બુલિયન તર્ક સાથે જોડો
મલ્ટી ટેનન્સી, ઓથેન્ટિકેશન, ઑબ્ઝર્વેબિલિટી, બેકઅપ/રિસ્ટોર, અને અબજ સ્કેલ એમ્બેડિંગ સપોર્ટ
sudo apt update && sudo apt upgrade -y
sudo apt install python3.10 python3-pip python3-venv -y2. વર્ચ્યુઅલ એન્વાયર્નમેન્ટ બનાવો:mkdir chromadb-server
cd chromadb-server
python3 -m venv venv
source venv/bin/activate3. ChromaDB ઇન્સ્ટોલ કરો:pip install chromadb4. ઝડપી પરીક્ષણ (ઇન મેમરી મોડ):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. ChromaDB સર્વર ઇન્સ્ટોલ કરો (પ્રોડક્શન):pip install chromadb[server]6. 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 80007. Docker ઇન્સ્ટોલેશન (પ્રોડક્શન માટે ભલામણ કરેલ):# 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 chromadb8. systemd સર્વિસ કન્ફિગર કરો (નોન Docker):sudo nano /etc/systemd/system/chromadb.serviceઉમેરો:[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સક્ષમ કરો અને શરૂ કરો:sudo systemctl daemon-reload
sudo systemctl enable chromadb
sudo systemctl start chromadb
sudo systemctl status chromadb9. Nginx રિવર્સ પ્રોક્સી કન્ફિગર કરો:sudo nano /etc/nginx/sites-available/chromadbઉમેરો: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;
}
}સક્ષમ કરો અને 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.com10. કનેક્શન ચકાસો: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())
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. કલેક્શન મેનેજમેન્ટ:# 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. દસ્તાવેજો ઉમેરવા: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. ફિલ્ટર સાથે ક્વેરી કરવી:# 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. એમ્બેડિંગ ફંક્શન્સ:# 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 embeddings6. અપડેટ અને ડિલીટ:# 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. એન્વાયર્નમેન્ટ વેરિએબલ (સર્વર):# 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=FALSE8. કામગીરી ઑપ્ટિમાઇઝેશન:# 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શ્રેષ્ઠ પ્રથાઓ:અમારી સરળ VPS વિસ્તરણ પ્રક્રિયા સાથે મિનિટોમાં શરૂ કરો
લગભગ2મિનિટમાં સ્થાપિત કરો • સંપૂર્ણ રુટ પ્રવેશ • ટિકિટ અને ઇમેઇલ દ્વારા આધાર