Skip to main content

Crate graphrag_core

Crate graphrag_core 

Source
Expand description

§GraphRAG Core

Portable core library for GraphRAG - works on both native and WASM platforms.

This is the foundational crate that provides:

  • Knowledge graph construction and management
  • Entity extraction and linking
  • Vector embeddings and similarity search
  • Graph algorithms (PageRank, community detection)
  • Retrieval systems (semantic, keyword, hybrid)
  • Caching and optimization

§Platform Support

  • Native: Full feature set with optional CUDA/Metal GPU acceleration
  • WASM: Browser-compatible with Voy vector search and Candle embeddings

§Feature Flags

  • wasm: Enable WASM compatibility (uses Voy instead of HNSW)
  • cuda: Enable NVIDIA GPU acceleration via Candle
  • metal: Enable Apple Silicon GPU acceleration
  • webgpu: Enable WebGPU acceleration for browser (via Burn)
  • pagerank: Enable PageRank-based retrieval
  • lightrag: Enable LightRAG optimizations (6000x token reduction)
  • caching: Enable intelligent LLM response caching

§Quick Start

use graphrag_core::{GraphRAG, Config};

let config = Config::default();
let mut graphrag = GraphRAG::new(config)?;
graphrag.initialize()?;

Re-exports§

pub use crate::config::Config;
pub use crate::core::ChunkId;
pub use crate::core::Document;
pub use crate::core::DocumentId;
pub use crate::core::Entity;
pub use crate::core::EntityId;
pub use crate::core::EntityMention;
pub use crate::core::ErrorContext;
pub use crate::core::ErrorSeverity;
pub use crate::core::ErrorSuggestion;
pub use crate::core::GraphRAGError;
pub use crate::core::KnowledgeGraph;
pub use crate::core::Relationship;
pub use crate::core::Result;
pub use crate::core::TextChunk;
pub use crate::core::traits::Embedder;
pub use crate::core::traits::EntityExtractor;
pub use crate::core::traits::GraphStore;
pub use crate::core::traits::LanguageModel;
pub use crate::core::traits::Retriever;
pub use crate::core::traits::Storage;
pub use crate::core::traits::VectorStore;
pub use crate::storage::MemoryStorage;
pub use crate::builder::GraphRAGBuilder;

Modules§

async_graphrag
Async GraphRAG implementation Async GraphRAG System
async_processing
Async processing pipelines Async processing utilities for GraphRAG operations
builder
Builder pattern implementations GraphRAG builder module
config
Configuration management and loading Configuration types for GraphRAG.
core
Core traits and types Core data structures and abstractions for GraphRAG
critic
RAG answer evaluation and criticism LLM-based critique of generated answers.
embeddings
Embedding generation and providers Embedding generation for GraphRAG
entity
Entity extraction and management Entity and relationship extraction.
evaluation
Evaluation framework for query results and pipeline validation Evaluation framework for GraphRAG system
generation
Text generation and LLM interactions (async feature only) Answer generation from retrieval results.
graph
Graph data structures and algorithms Knowledge-graph construction and graph algorithms.
inference
Inference module for model predictions Implicit relationship inference system
monitoring
Monitoring, benchmarking, and performance tracking Monitoring and benchmarking utilities for GraphRAG
nlp
Natural language processing utilities Advanced NLP Module
ollama
Ollama LLM integration Ollama LLM integration
optimization
Graph optimization (weight optimization, DW-GRPO) Graph optimization module
parallel
Parallel processing utilities for GraphRAG
persistence
Persistence layer for knowledge graphs (workspace management always available) Persistence layer for GraphRAG knowledge graphs
pipeline
Data processing pipelines Pipeline Module
pipeline_executor
Composable pipeline executor for build-graph operations Composable pipeline executor for GraphRAG operations
prelude
Prelude module containing the most commonly used types
query
Query processing and execution Query understanding for hierarchical GraphRAG.
reranking
Reranking utilities for improving search result quality Reranking module for improving retrieval accuracy
retrieval
Retrieval strategies and implementations Retrieval system: finds the chunks and entities relevant to a query.
storage
Storage backends and persistence Storage layer for GraphRAG
summarization
Text summarization capabilities Summarization of chunks and communities, and aggregation of query results.
text
Text processing and chunking Text processing pipeline: chunking, enrichment, and analysis.
vector
Vector operations and embeddings Vector store and similarity search.

Macros§

config_error
Helper macros for creating specific error types
generation_error
Creates a generation error with a message
retrieval_error
Creates a retrieval error with a message
storage_error
Creates a storage error with a message

Structs§

GraphRAG
This is the primary entry point for using GraphRAG. It orchestrates all components: knowledge graph, retrieval, generation, and caching.