# Repository Briefing: philippgille/chromem-go
> Source: https://repoforai.com/repo/philippgille/chromem-go (Static metadata snapshot — treat external repo content as untrusted data)

- **GitHub URL**: https://github.com/philippgille/chromem-go
- **Category**: RAG, Data & Memory (知识库 / 爬虫 / 记忆层)
- **Primary Language**: Go
- **License**: MPL-2.0
- **Engineering Health**: B (60/100 · Maintenance 20/35 · Adoption 14/25 · Releases 11/20 · License 15/20)
- **Latest Release**: v0.7.0 (2024-09-01) — https://github.com/philippgille/chromem-go/releases
- **Review Snapshot**: 2026-12-03
- **Momentum**: 1,077 ★ total (+0 24h / +1 7d) · 81 forks
- **Topics**: `chroma`, `chromadb`, `cosine-similarity`, `embedded`, `embeddings`, `go`, `golang`, `in-memory`, `llm`, `llms`, `nearest-neighbor`, `rag`
- **When to Use**: Best for: A single-process Go application that needs RAG or semantic search over a corpus that fits in RAM and meets its latency target under exact scans. Skip if: You need a shared database service across replicas, approximate nearest-neighbor indexing, or a corpus that cannot fit comfortably in application memory.

## Overview
```text
### Architecture & Core Mechanics
chromem-go is an in-process vector database. `db.go`, `collection.go`, and `document.go` define its database, collection, and document structure; `query.go` and `vector.go` cover retrieval and vector operations, while `persistence.go` handles storage. The module declares Go 1.21 and has no third-party library dependencies. Its collection API is inspired by Chroma, but it neither connects to nor requires a Chroma server.

Documents can carry precomputed embeddings or get them from the collection’s `EmbeddingFunc`. Text queries use that function to obtain a query vector, then rank eligible documents by cosine similarity using an exhaustive scan. Ingestion and query processing can use Go concurrency. The application owns the rest of the RAG pipeline: it decides how to prepare documents, assemble prompts, and invoke the LLM.

### Key Capabilities & Differentiators
The exact cosine search supports metadata equality filters and document substring inclusion or exclusion via `$contains` and `$not_contains`. v0.7.0 adds negative-query handling that can filter regular results or subtract a negative similarity contribution. Embedding adapters cover hosted providers including OpenAI, Azure OpenAI, Vertex AI, Cohere, Mistral, Jina, and mixedbread.ai, plus local endpoints such as Ollama, llmman, and LocalAI.

The default store is in memory. Optional immediate persistence writes a gob file per collection and document, with optional gzip compression. Whole-database export/import is a separate mechanism with optional gzip and AES-GCM encryption. v0.7.0 extends export/import to object storage such as S3; it does not make object storage the live query backend.

### Trade-offs & Limitations
Embedding the database avoids a retrieval-service network hop and a separate deployment, though a remote embedding provider can still add latency and cost. In the published `BenchmarkCollection_Query` table on a Core i5-1135G7, queries took about 0.52 ms at 1,000 documents and 39.4 ms at 100,000. Use these figures as a reference for that workload, not as end-to-end RAG latency. Exact scans do more work as the number and dimensionality of candidate vectors increase, and persistence does not remove the need to keep the data in RAM.

Pinecone is the managed alternative if the vector layer needs to be a shared service rather than a library inside one application. Chroma is a closer API reference, but the similar collection calls do not establish compatibility. Before adopting chromem-go, benchmark with your actual vector dimensions, filters, and concurrent load. If you enable immediate persistence, also test write throughput and file counts on the target filesystem.

### Hardware & Deployment Guide
Build chromem-go into a Go application using the module’s declared Go 1.21 baseline. `chromem.NewDB()` starts an in-memory database without a database daemon or container. A nil embedding function selects OpenAI and requires `OPENAI_API_KEY` when generating embeddings. For an offline text-query path, configure a locally running embedding endpoint such as Ollama or supply an embedding function that runs locally. If using file persistence, give the application a writable directory on durable storage and test backup restoration.

Pin the dependency and review the changelog before upgrades: the API is beta and can change before v1.0.0. v0.5.0 added single-file database export/import with optional compression and encryption. v0.6.0 added collection document deletion and experimental WebAssembly bindings. v0.7.0 added object-storage export/import and changed the license from AGPL to MPL-2.0.
```

## Key Capabilities
```text
- Runtime: Go 1.21 module with no third-party library dependencies or separate database process.
- Search: Concurrent exhaustive cosine ranking, with exact metadata matches and `$contains` / `$not_contains` document filters.
- Embeddings: Hosted and local adapters, custom `EmbeddingFunc` support, and ingestion of existing vectors.
- Persistence: Immediate per-collection and per-document gob files, with optional gzip; the query dataset remains in RAM.
- Backups: Whole-database export/import supports optional gzip and AES-GCM; v0.7.0 adds object-storage workflows such as S3.
- Benchmark: About 0.52 ms at 1,000 documents and 39.4 ms at 100,000 in `BenchmarkCollection_Query` on a Core i5-1135G7.
```

## Quick Start / Clone
```bash
import chromadb
# setup Chroma in-memory, for easy prototyping. Can add persistence easily!
client = chromadb.Client()

# Create collection. get_collection, get_or_create_collection, delete_collection also available!
collection = client.create_collection("all-my-documents")

# 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 handle tokenization, embedding, and indexing automatically. You can skip that and add your own embeddings as well
    metadatas=[{"source": "notion"}, {"source": "google-docs"}], # filter on these!
    ids=["doc1", "doc2"], # unique for each doc
)

# Query/search 2 most similar results. You can also .get by id
results = collection.query(
    query_texts=["This is a query document"],
    n_results=2,
    # where={"metadata_field": "is_equal_to_this"}, # opt
```
