Skip to main content

Crate oxirag

Crate oxirag 

Source
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 similarity
  • speculator (default): Enable Layer 2 with Candle for SLM inference
  • judge (default): Enable Layer 3 with OxiZ for SMT verification
  • cuda: Enable CUDA acceleration for Candle models
  • metal: 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)   │
└────────┬────────┘
         │
         ▼
      Response

Re-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 OxiRAG pipeline 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 OxiRAG operations.
simd_similarity
SIMD-optimized similarity computation for vector operations.
streaming
Async streaming API for the RAG pipeline.
types
Core data structures for OxiRAG.