Skip to main content

Crate xz_rag

Crate xz_rag 

Source
Expand description

Multi-channel Retrieval-Augmented Generation (RAG) engine.

xz-rag provides a composable RAG engine with multiple retrieval channels (semantic, BM25, metadata, graph), result fusion (RRF), context window management, query preprocessing (HYDE, expansion), and optional LLM generation.

§Architecture

  • Engine: DefaultRagEngine coordinating retrieval, fusion, and generation
  • Channels: semantic, bm25, metadata, graph retrieval backends
  • Pipeline: Channel orchestration with RRF fusion and score normalization
  • Context: Token budget management and citation formatting
  • Indexing: Document chunking strategies (fixed, recursive, separator-based)
  • Caching: Optional in-memory result caching via moka
  • Generation: LLM integration via xz-provider (feature-gated)

Re-exports§

pub use engine::DefaultRagEngine;
pub use engine::DefaultRagEngineBuilder;
pub use error::RagError;
pub use traits::RagEngine;
pub use types::chunk::Chunk;
pub use types::chunk::ChunkMetadata;
pub use types::config::RagConfig;
pub use types::config::RagEngineInfo;
pub use types::rag::BuiltContext;
pub use types::rag::ChatMessage;
pub use types::rag::ChatRole;
pub use types::rag::Citation;
pub use types::rag::CitationFormat;
pub use types::rag::ContextConfig;
pub use types::rag::PromptTemplate;
pub use types::rag::RagGenerationConfig;
pub use types::rag::RagRequest;
pub use types::rag::RagRequestBuilder;
pub use types::rag::RagResponse;
pub use types::rag::RagStreamEvent;
pub use types::rag::RagTokenUsage;
pub use types::rag::RequestOptions;
pub use types::retrieval::ChannelStats;
pub use types::retrieval::QueryPreprocessing;
pub use types::retrieval::RetrieveRequest;
pub use types::retrieval::RetrieveRequestBuilder;
pub use types::retrieval::RetrieveResult;
pub use types::retrieval::RetrievedChunk;
pub use types::retrieval::StructuredFilter;
pub use pipeline::channel::ChannelConfig;
pub use pipeline::channel::ChannelPipeline;
pub use pipeline::channel::ChannelType;
pub use pipeline::fusion::RrfFusion;
pub use pipeline::normalize::MinMaxNormalizer;
pub use pipeline::normalize::ZScoreNormalizer;
pub use context::citation::format_citations_numeric;
pub use context::token_budget::ContextBuilder;
pub use indexing::chunker::ChunkStrategy;
pub use indexing::chunker::fixed::FixedSizeChunker;
pub use indexing::chunker::recursive::RecursiveCharacterChunker;
pub use indexing::chunker::semantic::SeparatorChunker;
pub use indexing::DocumentIndexer;
pub use indexing::IndexDocument;
pub use channels::graph::GraphChannelExecutor;
pub use channels::graph::KnowledgeGraphSearch;
pub use channels::metadata::MetadataChannelExecutor;
pub use channels::metadata::MetadataStore;
pub use channels::semantic::Embedder;
pub use channels::semantic::SemanticChannelExecutor;
pub use channels::semantic::SemanticSearch;

Modules§

cache
In-memory result caching.
channels
Retrieval channel implementations (semantic, BM25, metadata, graph).
context
Context assembly: token budget management and citation formatting.
engine
Default RAG engine implementation.
error
RAG error types.
generation
LLM generation integration.
indexing
Document indexing and chunking strategies.
pipeline
Multi-channel pipeline orchestration.
preprocessing
Query preprocessing (HYDE, expansion).
traits
Core trait definitions.
types
Shared type definitions.