Skip to content

RAG with citations, hybrid search and GraphRAG

DocsGPT returns RAG answers that cite title, source and page number on every response, using classic vector, hybrid BM25 + vector (pgvector) or GraphRAG retrieval, configurable per source.

classic · hybrid (bm25 + vector) · graphrag · pgvector · citations: title · source · page

Last updated:

docsgpt — chat

Cited answers on every response

Every answer names the title, source and page number of the passages it used, and the source panel opens on that page. Prompt patterns instruct the model to answer only from retrieved passages and to say when they do not cover the question.

A per-source score threshold makes the assistant abstain rather than guess when nothing relevant scores high enough.

citation = title · source · page · score threshold → abstain

app.docsgpt.cloud — Chat
A chat answer to “What is the EU proposing on tobacco taxation?”. A Sources row lists three retrieved passages from “annual report on taxation …” with a “1 more sources” card, above a collapsed Reasoning row. The answer states that on 16 July 2025 the Commission adopted a proposal to revise the Tobacco Taxation Directive (Council Directive 2011/64/EU), with numbered citation chips after each claim, and lists the key elements: revised minimum excise rates, an expanded scope covering new tobacco products, and inclusion of raw tobacco.
app.docsgpt.cloud — Chat
A chat answer to “What is the EU proposing on tobacco taxation?”. A Sources row lists three retrieved passages from “annual report on taxation …” with a “1 more sources” card, above a collapsed Reasoning row. The answer states that on 16 July 2025 the Commission adopted a proposal to revise the Tobacco Taxation Directive (Council Directive 2011/64/EU), with numbered citation chips after each claim, and lists the key elements: revised minimum excise rates, an expanded scope covering new tobacco products, and inclusion of raw tobacco.

Three retrievers

Retrieval is chosen per source. Classic vector similarity runs on any vector store; hybrid BM25 + vector and GraphRAG (both v0.18) need pgvector, because the default FAISS store is vector-only. The retriever sits in a fixed pipeline with optional rephrasing, an optional LLM relevance prescreen and context compression before the cited answer.

GraphRAG can be switched on when a source is first ingested or later, on a source already in place. Extraction then runs over the whole source from scratch and can be resumed if it is interrupted; it costs roughly one LLM call per chunk, and the source settings show a token estimate before the run. Until the graph exists, that source is served by classic vector retrieval.

Classic retrieval uses vector similarity and suits short factual lookups. Hybrid (v0.18) adds BM25 keyword search to vector search for exact terms, codes and names. GraphRAG (v0.18) builds an entity/relation graph over the source and traverses it with Personalized PageRank for questions that span many documents.

DocsGPT retrievers: method and best use
 MethodBest for
Classicvector similarityshort factual lookups
Hybridv0.18BM25 keyword + vectorexact terms, codes, names
GraphRAGv0.18entity/relation graph traversed with Personalized PageRank, multi-hopquestions spanning many documents

graphrag graph · built at ingest or later · resumable · ~1 llm call per chunk · no graph yet → classic vector

Retrieval pipeline
  1. 01Queryuser or agent
  2. 02Rephraseoptional
  3. 03Retrieverclassic · hybrid · graphrag
  4. 04PrescreenLLM relevance filter · optional
  5. 05Compressat 0.8 of context
  6. 06Answertitle · source · page
Text version

A query (from a user or an agent) is optionally rephrased, then passed to the retriever configured for the source: classic, hybrid or GraphRAG. An optional prescreen step uses an LLM to filter retrieved chunks for relevance. When the context reaches 80 % of the model's limit (the default; configurable), it is compressed, and the answer is generated with citations to title, source and page.

Per-source retrieval configuration

Each source carries its own retrieval settings, so a contracts library and a wiki can be tuned differently and searched together.

Exposure mode decides how an agent sees the source: prefetch retrieves before the model runs; agentic_tool exposes retrieval as a tool the model calls when it decides it needs to.

app.docsgpt.cloud — Sources › Source settings
Source settings for “annual report on taxation 2026-KP0126035ENN.pdf”. A Retrieval group (marked “no re-ingest”) sets Retriever to Classic, Chunks to retrieve (top-k) to 2, Score threshold to None, Rephrase query before search on, Search exposure to “Pre-fetch into context” and Enable LLM prescreen off. A Chunking group (marked “re-ingest to apply”) sets Chunking strategy to Classic, Max tokens per chunk 1250, Min tokens per chunk 150 and Duplicate headers across chunks off.
app.docsgpt.cloud — Sources › Source settings
Source settings for “annual report on taxation 2026-KP0126035ENN.pdf”. A Retrieval group (marked “no re-ingest”) sets Retriever to Classic, Chunks to retrieve (top-k) to 2, Score threshold to None, Rephrase query before search on, Search exposure to “Pre-fetch into context” and Enable LLM prescreen off. A Chunking group (marked “re-ingest to apply”) sets Chunking strategy to Classic, Max tokens per chunk 1250, Min tokens per chunk 150 and Duplicate headers across chunks off.

Per-source settings

top-k
number of chunks retrieved
score threshold
below it the assistant abstains rather than guesses
query rephrasing
on / off
prescreen
LLM relevance filter on retrieved chunks
chunking strategy
classic · recursive · markdown · parent_child · semantic
exposure mode
prefetch · agentic_tool (retrieval as a callable tool)

Cross-source search and context compression

One question can span every connected knowledge base. Retrieved passages are merged into one context; when that context reaches 80 % of the model's limit, DocsGPT summarises and truncates recursively so the answer still fits. The threshold is 0.8 by default and configurable.

An optional separate compression model keeps the main model's budget for the answer itself.

all sources → merge → compress at 0.8 of context · configurable → answer

Cross-source searchquery → sources → merge → compress → answer
Cross-source search and context compression in DocsGPTOne query goes to every connected knowledge base at once; the retrieved passages are merged into a single context. When that context reaches 80 % of the model's limit (the default; configurable), DocsGPT summarises and truncates it recursively, optionally with a separate and smaller compression model, before the answer is generated with citations.One queryPoliciessharepoint · hybridContractsgoogle drive · classicEngineering handbookgithub · graphragMerged contextall passagesCompressat 0.8 of contextAnswer+ citationsOPTIONAL SEPARATE COMPRESSION MODEL
Text version

One query goes to every connected knowledge base at once; the retrieved passages are merged into a single context. When that context reaches 80 % of the model's limit (the default; configurable), DocsGPT summarises and truncates it recursively, optionally with a separate and smaller compression model, before the answer is generated with citations.

Graph view

For sources indexed with GraphRAG, the graph view shows the entities and relations the extraction pass found: the structure the retriever traverses when a question spans many documents. Until a source's graph is built, it answers through classic vector retrieval.

entities · relations · built at ingest or later · personalized pagerank

Graph viewentities · relations · personalized pagerank
GraphRAG entity graph for one source, one node selectedAn entity graph built at ingest for one GraphRAG source: entities such as the agreement, the counterparty, the addendum and its clauses are nodes; the relations extracted between them are edges. Selecting a node lists the documents that mention it, and questions that span several documents are answered by traversing the graph with Personalized PageRank.Master Services AgreementACME LtdData Processing AddendumRenewal · clause 12.3Termination for conveniencePayment terms · net 45GDPR · art. 28J. Doe · CFOSLA 99.9 %Frankfurt DC

selected node

Master Services Agreement

entity · document

linked documents · 3

  • MSA_ACME_2025.pdfp. 1–34
  • DPA_ACME_v3.docxannex B
  • Renewal notice 2026-03.eml
Text version

An entity graph built at ingest for one GraphRAG source: entities such as the agreement, the counterparty, the addendum and its clauses are nodes; the relations extracted between them are edges. Selecting a node lists the documents that mention it, and questions that span several documents are answered by traversing the graph with Personalized PageRank.

How it runs privately

Retrieval, BM25 and graph traversal run inside your PostgreSQL/pgvector instance, and embeddings are computed locally, by default through FastEmbed on ONNX Runtime, with sentence-transformers still supported. Nothing about how answers are retrieved requires an external service.

Four deployment postures, one code base. Compare deployment options →

Inside your network

  • postgresql / pgvector
  • bm25 · vector · graph traversal
  • fastembed · onnx runtime embeddings
  • context compression

managed · on-premises · air-gapped

Cloud

Arc53 operates the database and embedding service; retrieval runs in Arc53's cloud.

Air-gapped

Identical retrieval on your own PostgreSQL/pgvector with local embeddings and a local LLM, hybrid and GraphRAG included, with no external network.

Example

2.5M+ pages · 6 languages

Multilingual EU-law research over 2.5M+ pages, answers in 6 EU languages with full source citations, 100–200 ms retrieval.

Source: LexEU

Next: how documents get in · embeddings and vector stores · legal research with citations · compare with Glean · deployment options · pricing

Frequently asked questions

How does RAG reduce hallucinations?

The model answers only from passages retrieved from your documents, each answer cites title, source and page, and a per-source score threshold makes the assistant abstain when nothing relevant is found. Prompt patterns instruct the model to say so rather than guess.

What is GraphRAG?

GraphRAG is retrieval over a graph of entities and relations extracted from documents, so a question can follow links across many documents instead of matching one passage. DocsGPT builds that graph with an LLM extraction pass over the source, either at ingest or later on a source already in place, and traverses it with Personalized PageRank for multi-hop questions (v0.18).

Can I turn GraphRAG on for a source I have already ingested?

Yes. Extraction runs over the source from scratch rather than reusing earlier work, and the run can be resumed if it is interrupted. It costs roughly one LLM call per chunk; the source settings show a token estimate before it starts. Until the graph exists, that source is served by classic vector retrieval.

What is hybrid search in RAG?

Hybrid search combines BM25 keyword matching with vector similarity, so exact terms, codes and names are found even when their embedding is weak. In DocsGPT it is a per-source setting on pgvector (v0.18).

Does hybrid search need a special database?

Yes: hybrid and GraphRAG require pgvector (PostgreSQL). The default FAISS store is vector-only; classic retrieval works on any supported vector store.

Can one question search all my sources?

Yes. Cross-source search sends one query across all connected knowledge bases and merges the results into one cited answer, with context compression keeping the merged passages within the model's limit.

See DocsGPT on your documents

A 30-minute demo on your use case, or a free on-premises review with an engineer.