Go library for graph-augmented retrieval with pluggable backends.
- Pluggable storage: Neo4j (graph), Qdrant (vectors), Redis/SQL (cache)
- Multi-provider embeddings: Voyage AI, OpenAI, local models via sidecar
- Multi-provider reranking: Voyage AI, Cohere, local models via sidecar
- Configurable retrieval pipeline: Combine semantic, graph, temporal, and reranking stages
- Code-based configuration: Functional options, no YAML files
- Production-ready: Context support, retries with backoff, connection pooling
go get github.com/randalmurphal/graphrag
package main import ( "context" "fmt" "log" "os" "time" "github.com/randalmurphal/graphrag/pkg/graphrag" "github.com/randalmurphal/graphrag/pkg/graphrag/embedding/voyage" "github.com/randalmurphal/graphrag/pkg/graphrag/retrieval" "github.com/randalmurphal/graphrag/pkg/graphrag/retrieval/stages" "github.com/randalmurphal/graphrag/pkg/graphrag/store/neo4j" "github.com/randalmurphal/graphrag/pkg/graphrag/store/qdrant" ) func main() { ctx := context.Background() // Initialize backends graphStore, _ := neo4j.New( neo4j.WithURI("bolt://localhost:7687"), neo4j.WithAuth("neo4j", "password"), ) defer graphStore.Close() vectorStore, _ := qdrant.New( qdrant.WithHost("localhost", 6334), qdrant.WithCollection("documents"), ) defer vectorStore.Close() embedder, err := voyage.New( voyage.WithAPIKey(os.Getenv("VOYAGE_API_KEY")), voyage.WithModel("voyage-3.5"), ) if err != nil { log.Fatal(err) } // Build retrieval pipeline pipeline, err := retrieval.NewPipeline(). AddStage(stages.Semantic(vectorStore, embedder, 50)). AddStage(stages.Hydrate(graphStore)). AddStage(stages.GraphExpansion(graphStore, 2)). AddStage(stages.TemporalDecay(90 * 24 * time.Hour)). Build() if err != nil { log.Fatal(err) } // Execute query results, err := pipeline.Execute(ctx, "How does authentication work?", 10) if err != nil { panic(err) } for _, r := range results { fmt.Printf("%.3f: %s\n", r.Score, r.Document.Content[:100]) } }
GraphRAG is designed as infrastructure, not a product. It provides:
| Layer | Purpose |
|---|---|
| Interfaces | GraphStore, VectorStore, Embedder, Reranker |
| Implementations | Neo4j, Qdrant, Redis, Voyage, OpenAI, Cohere, Sidecar |
| Pipeline | Composable retrieval stages with scoring |
| Server | Optional HTTP API (cmd/graphrag-server) |
Business logic (memory tiers, scope isolation, multi-tenancy) belongs in consumers.
| Backend | Interface | Port | Use Case |
|---|---|---|---|
| Neo4j | GraphStore | 7687 | Graph relationships, PageRank |
| Qdrant | VectorStore | 6334 (gRPC) | Vector similarity search |
| Redis | CacheStore | 6379 | Distributed caching (optional) |
| SQL | CacheStore | - | Embedded caching with PostgreSQL/SQLite |
| Provider | Models | Dimensions |
|---|---|---|
| Voyage AI | voyage-3.5, voyage-3.5-lite, voyage-3-large, voyage-code-3 | 1024 |
| OpenAI | text-embedding-3-small, text-embedding-3-large | 1536/3072 |
| Sidecar | all-MiniLM-L6-v2, BAAI/bge-large-en-v1.5, etc. | varies |
| Provider | Models |
|---|---|
| Voyage AI | rerank-2.5, rerank-2 |
| Cohere | rerank-english-v3.0, rerank-multilingual-v3.0 |
| Sidecar | cross-encoder/ms-marco-MiniLM-L-6-v2, etc. |
Build custom pipelines or use presets:
// Custom pipeline pipeline := retrieval.NewPipeline(). AddStage(stages.Semantic(vectorStore, embedder, 50)). AddStage(stages.Hydrate(graphStore)). AddStage(stages.GraphExpansion(graphStore, 2)). AddStage(stages.Rerank(reranker, 20)). WithScoring(retrieval.WeightedScorer{ Semantic: 0.4, Graph: 0.3, Rerank: 0.3, }). Build() // Or use a preset pipeline := presets.Standard(graphStore, vectorStore, embedder, reranker)
# Start dev containers docker compose up -d # Run tests go test ./... # Run with race detector go test -race ./... # Integration tests (requires containers) go test -tags=integration ./... # Start HTTP server go run ./cmd/graphrag-server
- CLAUDE.md - AI agent guide
- docs/ARCHITECTURE.md - System design
- docs/PIPELINE.md - Retrieval pipeline details
- docs/BACKENDS.md - Backend configuration
- docs/TESTING.md - Testing strategy
MIT