gorag

module
v1.1.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 6, 2026 License: MIT

README

🦖 GoRAG

The Expert-Grade, High-Performance Modular RAG Framework for Go

Go Report Card Go Reference Go Version Documentation

English | 中文文档


GoRAG is a production-ready Retrieval-Augmented Generation (RAG) framework built for high-scale AI engineering. It features a three-layer architecture that serves developers at all skill levels.

🏗️ Three-Layer Architecture

graph TB
    subgraph Pattern层["Pattern Layer (Application)"]
        P1["NativeRAG<br/>Vector Retrieval"]
        P2["GraphRAG<br/>Knowledge Graph"]
    end
    
    subgraph Pipeline层["Pipeline Layer (Assembly)"]
        I["Indexer"]
        R["Retriever"]
        D["Repository"]
    end
    
    subgraph Step层["Step Layer (Function)"]
        S1["Independent Modules<br/>Rewrite/Chunk/Embed..."]
    end
    
    Pattern层 --> Pipeline层
    Pipeline层 --> Step层
Layer Who Uses Responsibility
Pattern Application Developers Choose RAG mode, configure Options
Pipeline Advanced Developers Assemble Indexer/Retriever/Repository
Step Framework Developers Extend independent modules

✨ Key Features

  • 🚀 Performance First: Concurrent workers and streaming parsers with O(1) memory efficiency
  • 🏗️ Pipeline-Based Architecture: Every step is explicit, traceable, and pluggable
  • 🧠 Three-Phase Enhancement: Query enhancement → Retrieval → Result enhancement
  • 🕸️ Advanced GraphRAG: Native support for Neo4j, SQLite, and BoltDB
  • 🔭 Built-in Observability: Comprehensive distributed tracing
  • 📦 Zero Dependencies: Pure Go implementation with auto-download models

🚀 Quick Start

NativeRAG (Vector Retrieval)

Best for document QA and semantic search:

import "github.com/DotNetAge/gorag/pkg/pattern"

// Create a NativeRAG with auto-configuration
rag, _ := pattern.NativeRAG("my-app",
    pattern.WithBGE("bge-small-zh-v1.5"),
)

// Index documents
rag.IndexDirectory(ctx, "./docs", true)

// Retrieve
results, _ := rag.Retrieve(ctx, []string{"What is GoRAG?"}, 5)

GraphRAG (Knowledge Graph)

Best for complex relationship reasoning:

rag, _ := pattern.GraphRAG("knowledge-graph",
    pattern.WithBGE("bge-small-zh-v1.5"),
    pattern.WithNeoGraph("neo4j://localhost:7687", "neo4j", "password", "neo4j"),
)

// Add nodes and edges
rag.AddNode(ctx, &core.Node{ID: "person-1", Type: "Person", ...})
rag.AddEdge(ctx, &core.Edge{Source: "person-1", Target: "company-1", ...})

// Query neighbors
neighbors, edges, _ := rag.GetNeighbors(ctx, "person-1", 1, 10)

📚 Documentation

Getting Started

Advanced Topics

Step Layer


🔭 Built-in Observability

idx, _ := indexer.DefaultAdvancedIndexer(
    indexer.WithZapLogger("./logs/rag.log", 100, 30, 7, true),
    indexer.WithPrometheusMetrics(":8080"),
    indexer.WithOpenTelemetryTracer(ctx, "jaeger:4317", "RAG"),
)

⚡ Technical Standards

  • Go 1.24+: Latest language features
  • Zero-CGO SQLite: Painless cross-compilation
  • Clean Architecture: Strict separation of interfaces and implementations
  • Modular Steps: Reuse steps in any custom pipeline

🤝 Contributing

We aim to build the most robust AI infrastructure for the Go ecosystem.

📄 License

GoRAG is licensed under the MIT License.

Directories

Path Synopsis
cmd
gorag command
examples
quickstart command
pkg
core
Package core defines the fundamental entities, interfaces, and types for the goRAG framework.
Package core defines the fundamental entities, interfaces, and types for the goRAG framework.
core/env
Package env provides environment configuration and management for the GoRAG runtime.
Package env provides environment configuration and management for the GoRAG runtime.
di
Package di provides a lightweight dependency injection container for managing component lifecycle.
Package di provides a lightweight dependency injection container for managing component lifecycle.
indexer
Package indexer provides high-level indexers for building RAG pipelines.
Package indexer provides high-level indexers for building RAG pipelines.
indexing
Package indexing provides the core indexing pipeline for offline data preparation.
Package indexing provides the core indexing pipeline for offline data preparation.
indexing/community
Package community provides community detection algorithms for GraphRAG.
Package community provides community detection algorithms for GraphRAG.
logging
Package logging provides structured logging capabilities for the goRAG framework.
Package logging provides structured logging capabilities for the goRAG framework.
observability
Package observability provides metrics collection and distributed tracing capabilities.
Package observability provides metrics collection and distributed tracing capabilities.
retrieval/answer
Package answer provides answer generation utilities for RAG systems.
Package answer provides answer generation utilities for RAG systems.
retrieval/enhancement
Package enhancement provides query and document enhancement utilities for RAG systems.
Package enhancement provides query and document enhancement utilities for RAG systems.
retrieval/fusion
Package fusion provides result fusion strategies for combining multiple retrieval results.
Package fusion provides result fusion strategies for combining multiple retrieval results.
retrieval/graph
Package graph provides graph-related utilities for RAG systems.
Package graph provides graph-related utilities for RAG systems.
retrieval/query
Package query provides query processing components for the RAG system.
Package query provides query processing components for the RAG system.
retriever/graph
Package graph provides GraphRAG retrieval implementation following Microsoft GraphRAG architecture.
Package graph provides GraphRAG retrieval implementation following Microsoft GraphRAG architecture.
steps/crag
Package crag provides evaluation steps for RAG retrieval quality assessment.
Package crag provides evaluation steps for RAG retrieval quality assessment.
steps/decompose
Package decompose provides query decomposition steps for RAG retrieval pipelines.
Package decompose provides query decomposition steps for RAG retrieval pipelines.
steps/filter
Package filter provides query preprocessing steps for RAG pipelines.
Package filter provides query preprocessing steps for RAG pipelines.
steps/fuse
Package fuse provides result fusion steps for RAG retrieval pipelines.
Package fuse provides result fusion steps for RAG retrieval pipelines.
steps/generate
Package generate provides answer generation steps for RAG pipelines.
Package generate provides answer generation steps for RAG pipelines.
steps/graph
Package graph provides GraphRAG retrieval steps following Microsoft GraphRAG architecture.
Package graph provides GraphRAG retrieval steps following Microsoft GraphRAG architecture.
steps/image
Package image provides image retrieval steps for multimodal RAG pipelines.
Package image provides image retrieval steps for multimodal RAG pipelines.
steps/indexing
Package indexing provides document indexing pipeline steps for RAG data preparation.
Package indexing provides document indexing pipeline steps for RAG data preparation.
steps/rerank
Package rerank provides reranking steps for RAG retrieval pipelines.
Package rerank provides reranking steps for RAG retrieval pipelines.
steps/rewrite
Package rewrite provides query rewriting steps for RAG retrieval pipelines.
Package rewrite provides query rewriting steps for RAG retrieval pipelines.
steps/sparse
Package sparse provides sparse retrieval steps using BM25 algorithm.
Package sparse provides sparse retrieval steps using BM25 algorithm.
steps/stepback
Package stepback provides query abstraction steps for RAG pipelines.
Package stepback provides query abstraction steps for RAG pipelines.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL