Skip to main content

Rag.NET Documentation

Rag.NET is a modular Retrieval-Augmented Generation (RAG) pipeline library for .NET, built on Microsoft.Extensions.AI abstractions. These docs cover every layer from first setup to production-grade extensions.

Pages​

Grouped the way the sidebar is.

Start here

PageWhat it covers
Why RAG?What RAG is, the problem it solves, and when Rag.NET is the right tool
Getting StartedDependency injection setup, ingesting a document, and running a Q&A loop
PositioningWhere Rag.NET sits against Semantic Kernel, LangChain, LlamaIndex and Haystack — and where it loses

The pipeline

PageWhat it covers
Choosing PackagesWhich two or three of the 73 packages a given pipeline actually needs
ArchitecturePipeline internals, data-flow diagram, the core interfaces and models
IngestionParsers, DocumentMetadata, IngestionOptions, OCR, progress reporting
ChunkingEight strategies with a trade-off table, plus the domain-specific templates
RetrievalRetrievalOptions, semantic and hybrid BM25+RRF search, metadata filtering, CRAG
Post-RetrievalLost-in-the-Middle reordering, redundancy filtering, MMR
Vector StoresAll seven stores, with the hybrid-search support matrix

Advanced retrieval

PageWhat it covers
RAPTORRecursive abstractive tree summarisation: tree scope, retrieval modes, cluster sizing
GraphRAGEntity extraction, community detection, local and global search, mind-map extraction
Query TechniquesHyDE, multi-query expansion, contextual compression
Answer EnginesMapReduce, Refine, FLARE and Dispatching answer strategies
Conversational MemoryIn-session history trimming, token budgets, persistent cross-session recall

Sources

PageWhat it covers
Data ProvidersAll 18 connectors: auth, delta-sync shape and options for each

Production

PageWhat it covers
SecurityPrompt-injection defence in depth, PII detection, RBAC, audit logging
ResilienceRetry and circuit-breaking, rate limiting, cost budgeting, fallback chains
ObservabilityILogger structured logging and the ActivitySource the pipeline emits on
Pipeline DebuggerPer-query traces: chunk scores, stage latencies, guard actions
EvaluationEmbedding-distance and LLM-judge evaluators, RAGAS metrics, A/B comparison
A/B Shadow ModeRunning a second pipeline against production traffic without touching the response

Integration

PageWhat it covers
Microsoft FoundryWiring the cloud endpoint, Foundry Local and the catalogue models, and what each one pins
MCP ServerExposing a pipeline to an LLM agent as MCP tools, and the four deployment patterns
REST and gRPCServing a pipeline over HTTP or gRPC, with clients that implement IRagPipeline
CLI (ragnet)Ingesting and querying a configured pipeline from the shell
MediatorDispatching ingest/retrieve/delete commands via IMediator
ExtendingImplementing IDocumentParser, IVectorStore, IChunkingStrategy, IDocumentOcrEngine

Reference

PageWhat it covers
BenchmarksMeasured throughput for chunking, embedding and retrieval
Retrieval QualityBEIR results per technique, and the ablation table behind them
Library ComparisonMeasured quality and cost against other RAG libraries
Comparison ScopeWhat each entrant was read for, cited per claim
Comparison DefaultsThe defaults every entrant was measured at
OpenTelemetryEvery span and metric the pipeline emits, and how to export them
OSS LibrariesEvery open-source dependency, where it is used, and why
CI and Test TiersWhich suites run where, and what each tier needs to run at all
  • Sample applications: samples/Rag.NET.Sample — interactive console app (PgVector, Ollama/OpenAI) — and samples/Rag.NET.QuickStart — a config-driven walkthrough built on Rag.NET.Hosting
  • Benchmark results: benchmarks.md
  • How Rag.NET compares: quality and cost (measured) and scope (read, cited per claim)
  • Feature roadmap and design notes: docs/plans/
  • GitHub README: covers the quick-start and package list

Package layout​

Rag.NET ships as 73 packages so that a pipeline downloads only the dependencies it actually uses. The shape is three layers — abstractions, core, and a satellite per opt-in feature — and Choosing packages walks through which two or three are yours.

Core​

NuGet packageContents
Rag.NETCore pipeline, Text/Markdown/CSV/JSON parsers, RecursiveChunkingStrategy, in-memory vector store
Rag.NET.AbstractionsInterfaces, models and options — no implementations, no heavy dependencies. Arrives with core
Rag.NET.QueryTechniquesHyDE, multi-query expansion and contextual compression. Arrives with core

Chunking​

NuGet packageContents
Rag.NET.ChunkingHierarchical-merge, code-aware, late, proposition, token-aware and embedding-based semantic chunking
Rag.NET.Chunking.CSharpCSharpChunkingStrategy — Roslyn-based semantic chunking for C# source
Rag.NET.Chunking.TemplatesDomain templates: Legal, Book, Academic Paper, Q&A Pairs, Email, Résumé
Rag.NET.Embeddings.OnnxONNX Runtime token-level embeddings, which late chunking needs

Vector stores​

NuGet packageContents
Rag.NET.VectorStores.PgVectorPostgreSQL + pgvector, with sparse-vector support
Rag.NET.VectorStores.QdrantQdrant
Rag.NET.VectorStores.AzureAISearchAzure AI Search, with native hybrid search
Rag.NET.VectorStores.PineconePinecone
Rag.NET.VectorStores.ChromaChroma
Rag.NET.VectorStores.WeaviateWeaviate
Rag.NET.VectorStores.RedisRedis (RediSearch)

Parsers​

NuGet packageContents
Rag.NET.Parsers.PdfPDF parser, with table extraction and Tesseract OCR
Rag.NET.Parsers.Pdf.AzureDocumentIntelligenceWhole-document OCR engine for the PDF parser (paid, per page)
Rag.NET.Parsers.HtmlHTML parser (AngleSharp)
Rag.NET.Parsers.OfficeWord .docx, Excel .xlsx and PowerPoint .pptx in one package (OpenXml)
Rag.NET.Parsers.EmailEML and MSG email parser (MimeKit)
Rag.NET.Parsers.EpubEPUB parser
Rag.NET.Parsers.ArchiveZIP archive parser — parses each entry with whichever parser claims it
Rag.NET.Parsers.AudioWAV/MP3/FLAC transcription via Whisper.net (local, no API key)
Rag.NET.Parsers.VisionImage and video description via a vision LLM and FFMpeg

Data providers​

NuGet packageContents
Rag.NET.DataProvidersShared OAuth, polling and watermark infrastructure. Arrives with any connector
Rag.NET.DataProviders.WebWeb crawler, sitemap loader, RSS/Atom feed loader
Rag.NET.DataProviders.Microsoft365Exchange/Outlook mail, Teams, OneDrive and SharePoint via Microsoft Graph
Rag.NET.DataProviders.AzureBlobAzure Blob Storage — ETag/LastModified delta sync
Rag.NET.DataProviders.GoogleDriveGoogle Drive — pageToken change stream
Rag.NET.DataProviders.DropboxDropbox — cursor-based delta sync
Rag.NET.DataProviders.BoxBox — events cursor delta sync
Rag.NET.DataProviders.ConfluenceConfluence pages via REST API
Rag.NET.DataProviders.JiraJira issues via REST API
Rag.NET.DataProviders.NotionNotion pages and blocks via REST API
Rag.NET.DataProviders.AsanaAsana tasks and subtasks via REST API
Rag.NET.DataProviders.LinearLinear issues via GraphQL API
Rag.NET.DataProviders.SlackSlack channel messages via REST API
Rag.NET.DataProviders.GmailGmail messages via IMAP (MailKit)
Rag.NET.DataProviders.GitHubGitHub repository files via Octokit
Rag.NET.DataProviders.GitLabGitLab repository files via NGitLab
Rag.NET.DataProviders.BitbucketBitbucket repository files via REST API
Rag.NET.DataProviders.ZendeskZendesk tickets and help-centre articles
Rag.NET.DataProviders.AirtableAirtable rows and attachments
Rag.NET.Ingestion.AzureServiceBusConsumes a queue or subscription, ingests each message end to end, and settles it (complete / abandon / dead-letter)

Advanced retrieval​

NuGet packageContents
Rag.NET.RaptorRAPTOR — recursive abstractive tree summarisation, corpus-scoped by default
Rag.NET.Raptor.StorePersistent leaf-chunk storage, which corpus-level RAPTOR clustering requires
Rag.NET.GraphRagGraphRAG — entity extraction, community detection, local and global search, Mind-Map Extractor
Rag.NET.GraphStandalone graph library — Leiden community detection, IGraphStore
Rag.NET.AnswerEnginesMapReduce, Refine, FLARE and Dispatching answer engines
Rag.NET.MemoryPersistent SQLite-backed cross-session conversation memory
Rag.NET.Reranking.CohereCohereReranker — hosted cross-encoder reranking
Rag.NET.Reranking.OnnxOnnxReranker — local ONNX cross-encoder reranking (no API key)
Rag.NET.WebSearch.TavilyTavily web search, the corrective-RAG (CRAG) fallback source

Production​

NuGet packageContents
Rag.NET.SecurityPrompt-injection defence in depth — chunk and query sanitisation, retrieval guards, prompt hardening, PII detection, RBAC
Rag.NET.Security.AspNetCoreBinds ICallerContext to ClaimsPrincipal
Rag.NET.Security.Audit.SqliteSQLite-backed audit log, split out so Security carries no native binary
Rag.NET.ResiliencePolly retry and circuit-breaking, token-bucket rate limiting, multi-provider chat fallback chain
Rag.NET.CachingUseCaching() — the HybridCache implementation behind the embedding and result caches
Rag.NET.Storage.SqliteBM25 and parent-chunk persistence, document sidecar, content-hash record manager, embedding-version store, persistent cost ledger

Observability and evaluation​

NuGet packageContents
Rag.NET.TelemetryAddRagNetInstrumentation() — OpenTelemetry SDK wiring, so core and its satellites take no SDK dependency
Rag.NET.DiagnosticsIn-memory pipeline traces — the last N executions with chunk scores, stage latencies and guard actions
Rag.NET.Diagnostics.AspNetCoreOpt-in MapRagNetTrace() HTTP endpoint for those traces
Rag.NET.EvaluationLLM-judge and embedding-distance evaluators, A/B comparison with confidence intervals, dataset generation, shadow capture
Rag.NET.Evaluation.RagasRAGAS-style metrics — faithfulness, answer relevancy, context precision and recall

Serving and integration​

NuGet packageContents
Rag.NET.ApiASP.NET Core REST API over a pipeline
Rag.NET.Api.ClientIRagPipeline implemented over HTTP against that API
Rag.NET.Api.GrpcgRPC service over a pipeline
Rag.NET.Api.Grpc.ClientIRagPipeline implemented over gRPC against that service
Rag.NET.McpModel Context Protocol server exposing a pipeline as MCP tools
Rag.NET.Mcp.AspNetCoreHTTP transport for the MCP server, which refuses to serve an unauthenticated write surface
Rag.NET.Mcp.ToolSelf-contained MCP server as a dotnet global tool, configured entirely from appsettings.json
Rag.NET.Cliragnet global tool — ingest into, and query, a configured pipeline
Rag.NET.HostingConfiguration-driven pipeline wiring for an executable
Rag.NET.MediatorZeroAlloc.Mediator integration — dispatch ingest/retrieve/delete via IMediator

Requirements​

  • .NET 10 or later
  • A compatible embedding provider (OpenAI, Azure OpenAI, Ollama, etc.)
  • A supported vector store (PostgreSQL+pgvector, Qdrant, or Azure AI Search)