Expand description
OxiRAG - A three-layer RAG engine with SMT-based logic verification.
OxiRAG provides a robust Retrieval-Augmented Generation (RAG) pipeline with:
- Layer 1 (Echo): Semantic search using vector embeddings
- Layer 2 (Speculator): Draft verification using small language models
- Layer 3 (Judge): Logic verification using SMT solvers
§Quick Start
ⓘ
use oxirag::prelude::*;
#[tokio::main]
async fn main() -> Result<(), OxiRagError> {
// Create the Echo layer with mock embedding provider
let echo = EchoLayer::new(
MockEmbeddingProvider::new(384),
InMemoryVectorStore::new(384),
);
// Create the Speculator layer
let speculator = RuleBasedSpeculator::default();
// Create the Judge layer
let judge = JudgeImpl::new(
AdvancedClaimExtractor::new(),
MockSmtVerifier::default(),
JudgeConfig::default(),
);
// Build the pipeline
let mut pipeline = PipelineBuilder::new()
.with_echo(echo)
.with_speculator(speculator)
.with_judge(judge)
.build()?;
// Index documents
pipeline.index(Document::new("The capital of France is Paris.")).await?;
// Query the pipeline
let query = Query::new("What is the capital of France?");
let result = pipeline.process(query).await?;
println!("Answer: {}", result.final_answer);
println!("Confidence: {:.2}", result.confidence);
Ok(())
}§Features
echo(default): Enable Layer 1 with numrs2 for SIMD similarityspeculator(default): Enable Layer 2 with Candle for SLM inferencejudge(default): Enable Layer 3 withOxiZfor SMT verificationcuda: Enable CUDA acceleration for Candle modelsmetal: Enable Metal acceleration for Candle models
§Architecture
Query
│
▼
┌─────────────────┐
│ Layer 1: Echo │ ← Semantic search with embeddings
│ (Vector Store) │
└────────┬────────┘
│
▼
┌─────────────────────┐
│ Layer 2: Speculator │ ← Draft verification with SLM
│ (Draft Checker) │
└─────────┬───────────┘
│
▼
┌─────────────────┐
│ Layer 3: Judge │ ← Logic verification with SMT
│ (SMT Solver) │
└────────┬────────┘
│
▼
ResponseRe-exports§
pub use error::OxiRagError;pub use error::Result;
Modules§
- circuit_
breaker - Circuit breaker pattern implementation for resilient external service handling.
- config
- Configuration management for
OxiRAG. - connection_
pool - Connection pooling for external services.
- error
- Unified error types for
OxiRAG. - hybrid_
search - Hybrid search combining dense (vector) and sparse (BM25) retrieval.
- index_
management - Index management API for vector stores.
- layer1_
echo - Layer 1: Echo - Semantic search with vector embeddings.
- layer2_
speculator - Layer 2: Speculator - Draft verification using small language models.
- layer3_
judge - Layer 3: Judge - SMT-based logic verification.
- load_
testing - Load testing utilities for
OxiRAGpipeline performance evaluation. - memory
- Memory monitoring and resource management for
OxiRAG. - metrics
- Pipeline metrics and tracing support.
- pipeline
- Unified RAG pipeline combining all three layers.
- pipeline_
debug - Pipeline visualization and debugging tools.
- prelude
- Convenient re-exports for common usage.
- query_
builder - Fluent query builder API for constructing complex queries.
- query_
expansion - Query expansion and reformulation for improved retrieval.
- relevance_
feedback - Relevance feedback loop for improving search quality.
- reranker
- Reranking support for search results.
- retry
- Retry logic with exponential backoff for
OxiRAGoperations. - simd_
similarity - SIMD-optimized similarity computation for vector operations.
- streaming
- Async streaming API for the RAG pipeline.
- types
- Core data structures for
OxiRAG.