Expand description
docling-rag: a pluggable Retrieval-Augmented-Generation subsystem built on
the docling.rs document converter.
The pipeline is: source → convert to Markdown → chunk → embed → vector store → retrieve → (optionally) synthesize an answer. Every external dependency is a trait with swappable backends:
- Embedders (
embed): Ollama (default), Gemini, local ONNX, or a deterministic hashing embedder for offline tests. - Vector stores (
store): SQLite (default), PostgreSQL + pgvector, or in-memory. Documents and chunks live in separate tables. - Retrieval (
retrieve): dense vector, sparse BM25, Hybrid (RRF), Multi-Query fusion, and HyDE. - LLM (
llm): OpenRouter (default model DeepSeek-V3). - Sources (
source): local folder (default), FTP, SFTP. - Queues (
queue): in-process, RabbitMQ, Redis pub/sub.
Configuration comes from the environment / a .env file via RagConfig.
use docling_rag::{RagConfig, Pipeline, RetrievalMode};
let cfg = RagConfig::from_env()?;
let pipeline = Pipeline::from_config(&cfg).await?;
pipeline.ingest_all().await?;
let hits = pipeline.query(RetrievalMode::Hybrid, "how does chunking work?", 5).await?;
for h in hits {
println!("{:.3} {}", h.score, h.chunk.text);
}Re-exports§
pub use config::RagConfig;pub use error::RagError;pub use error::Result;pub use model::Chunk;pub use model::Document;pub use model::RetrievalMode;pub use model::Scored;pub use pipeline::Answer;pub use pipeline::IngestOutcome;pub use pipeline::IngestReport;pub use pipeline::Pipeline;pub use retrieve::Retriever;
Modules§
- api
- REST API over a
Pipeline: document info and search in every retrieval mode. - chunk
- Markdown-aware chunking.
- config
- Configuration, loaded from the process environment (and a
.envfile). - embed
- Pluggable embedding providers.
- error
- Error type for the RAG subsystem.
- eval
- Evaluation harness: sweep a matrix of
{chunk_size, overlap, retrieval mode}over a labelled dataset and rank the configurations by retrieval quality. - llm
- Pluggable chat/LLM provider, used for Multi-Query and HyDE retrieval and for
final answer synthesis. The only shipped backend is
openrouter. - math
- Small, dependency-free vector maths used by embedders and stores.
- metrics
- Per-document processing metrics, captured during ingestion and stored in the
document’s JSON
metadatacolumn under the"metrics"key — a plain JSON object, so new metrics can be added later without a schema migration. - model
- Core data types shared across the pipeline: documents, chunks, scored hits.
- pipeline
- End-to-end orchestration: ingestion (source → convert → chunk → embed → store) and querying (retrieve → optional LLM answer synthesis).
- queue
- Pluggable message queue for decoupling document discovery from ingestion.
- retrieve
- Retrieval: dense vector, sparse BM25, and the advanced modes that combine or rewrite queries (Hybrid, Multi-Query fusion, HyDE).
- source
- Pluggable document sources. The default is a local
folder; FTP and SFTP are available behind theremote-sourcesfeature. - store
- Pluggable vector store.