---
title: "Retrieval that cites its sources and respects who is asking"
url: https://soliditylabs.tech/services/ai-development/rag-ai-system-development/
description: "Retrieval-augmented generation that answers from your documents with citations, respects each user’s permissions and is measured with an evaluation set."
source: Solidity Labs (https://soliditylabs.tech)
---

AI Development · Generative AI

# Retrieval that _cites its sources_ and respects who is asking

Knowledge assistants and RAG features that answer from your documents, show where each answer came from, filter by each user’s permissions and say “I don’t know” when the documents don’t say.

[Get a quote](/contact/get-a-quote/) [Book a free call](/contact/book-consultation/)

Free discovery callNDA on requestFixed proposal after scoping

1.  **Real questions**from your users
2.  **Permission check**nothing the asker can't see
3.  **Retrieval**were the passages found?
4.  **Recall**needed passages found
5.  **Reranking**best passages first
6.  **Precision**irrelevant passages out
7.  **Answer**only from passages
8.  **Faithfulness**no claim beyond sources
9.  **Citations**each claim sourced
10.  **Citation accuracy**source supports the claim

Fig. 1 — Each stage has its own measure on a set of real questions: did retrieval find the passages needed, were irrelevant ones kept out, does the answer stay within its sources, and does each citation support its claim.

In short

Retrieval-augmented generation (RAG) is a pattern where a language model answers from passages retrieved from your own documents instead of from memory. Solidity Labs builds RAG systems end to end: ingestion and structure-aware chunking, hybrid search, permission filtering, reranking, cited answers, an evaluation set that measures retrieval and faithfulness, and monitoring once it is live.

Definition

## What is retrieval-augmented generation?

**RAG gives a model the right pages to read.** Fine-tuning changes how a model writes. Most knowledge problems need the first, not the second.

A language model knows a lot about the world and nothing about your contracts, policies, product manuals or tickets. RAG closes that gap at question time: the system searches your content for the passages most likely to contain the answer, places them in the prompt, and asks the model to answer only from them, with references.

A demo that works on a handful of questions is easy to build. Production RAG is harder because the failure modes are quiet: the right passage is never retrieved, a table is split in half during chunking, an outdated version outranks the current one, or a user sees an answer drawn from a document they are not allowed to open. Our work is mostly about those details, and about measuring them, so quality is a number you can track rather than an impression.

If you are deciding between RAG and training your own model, our comparison of [RAG and fine-tuning](/blog/rag-vs-fine-tuning/) explains when each fits. The short version: use retrieval for knowledge that changes, and fine-tuning for behavior and format.

Problems we solve

## Problems RAG solves well

1.  ### People can’t find what the company already knows
    
    Policies, specifications and past decisions live in drives, wikis and inboxes. A cited answer with a link beats a search results page.
    
2.  ### Answers differ depending on who you ask
    
    When everyone gets the answer from the same approved source, consistency follows, and the source gets fixed when it is wrong.
    
3.  ### Generic chatbots invent answers
    
    Answering only from retrieved passages, and declining when nothing relevant is found, cuts unsupported answers. A citation that doesn’t back its sentence makes the rest easy to spot.
    
4.  ### Sensitive documents can’t go into a public tool
    
    Permission filtering at retrieval time, private deployment options and redaction keep restricted content restricted.
    

What we build

## What we build

### Ingestion pipeline

Connectors for SharePoint, Google Drive, Confluence, Notion, ticketing systems and databases, with parsing that keeps headings, tables and page numbers.

### Hybrid retrieval

Vector and keyword search combined, metadata filters and a reranker, tuned on your real questions.

### Permission filtering

Each user only retrieves passages from documents they can open in the source system.

### Cited answers

Every claim linked to a passage, with “I don’t know” when the retrieved context doesn’t support an answer.

### Evaluation set

Questions with expected sources and answers, scored for retrieval recall and faithfulness on every change.

### Freshness and versions

Incremental re-indexing, deleted documents removed, and superseded versions down-ranked or excluded.

### Monitoring

Traces, unanswered questions, user feedback and cost per answer, reviewed with your team on a schedule you agree.

Use cases

## Where RAG pays off

### Internal knowledge assistant

Policies, procedures and product knowledge answered with citations for staff, filtered by department and role.

### Customer support deflection

Help-center and documentation answers inside the support bot, with hand-off when the answer isn’t there.

### Contract and policy review

Find the clause, compare versions and summarize obligations, with every statement traceable to a page.

### Technical documentation search

Engineers and field teams ask in plain language and get the exact section of a manual or runbook.

### Sales and RFP answers

Draft responses from approved past answers and product documentation, for a person to check.

### Regulated research

Analysts query filings, reports and internal research, with sources recorded for audit.

How it works

## How a production RAG system is put together

Ingestion runs ahead of time. At question time, retrieval is filtered by the asker’s permissions before the model sees anything.

1.  **Sources**PDFs · wiki · tickets
2.  **Parse & chunk**structure-aware
3.  **Embed**\+ metadata & ACLs
4.  **Hybrid index**vector + keyword
5.  **Question**with user identity
6.  **Retrieve**filtered by permission
7.  **Rerank**top passages
8.  **Language model**grounded prompt
9.  **Evaluation set & tracing**faithfulness · recall · cost
10.  **Cited answer**or “I don’t know”

Fig. 2 — Documents are parsed, chunked and indexed ahead of time. At question time, retrieval is filtered by the asker's permissions, reranked, and the model answers with citations.

Sources

Connectors pull documents with their metadata and access-control lists, on a schedule or on change events.

Parsing and chunking

Structure-aware splitting by heading, table and section, so a chunk is a meaningful unit with its page and version.

Index

Embeddings plus a keyword index, with permissions stored per chunk: PostgreSQL with pgvector and its built-in full-text search, Qdrant with dense and sparse vectors, OpenSearch hybrid queries, or a managed search service.

Retrieval

Hybrid search, permission filter, metadata filters (date, product, region) and a reranker choose the passages.

Generation

A grounded prompt asks the model to answer only from the passages and cite them, or to say it doesn’t know.

Evaluation and monitoring

An evaluation set gates every change; production traces and feedback feed the next round of fixes.

Quality

## What we measure, and why

RAG quality is several numbers, not one. We score retrieval separately from the answer, because each points at a different fix.

Measure

Question it answers

Typical fix when it is low

**Retrieval recall**

Did the right passage reach the model?

Chunking, hybrid search weights, query rewriting, metadata

**Context precision**

Were irrelevant passages kept out, with the best ones first?

A reranker, fewer passages, tighter metadata filters

**Faithfulness**

Is every statement supported by the retrieved passages?

Prompt constraints, smaller context, a stronger model

**Citation accuracy**

Does each cited passage support the sentence it is attached to?

Citation format in the prompt, passage-level IDs, citation checks in the evaluation set

**Answer relevance**

Does it answer the question that was asked?

Query understanding, clarifying questions

**Refusal accuracy**

Does it say “I don’t know” when it should?

Thresholds on retrieval scores, refusal examples in the evaluation set

**Permission leakage**

Did anyone see content they can’t open?

Filtering before generation; tested with role-based cases

**Latency and cost**

Is it fast and affordable at your volume?

Caching, smaller models for routing, fewer passages

Design choices

## The decisions that matter most, and how we make them

If the right passage isn’t retrieved, no prompt or model change will fix that answer. That is why we measure retrieval first.

-   **Add keyword search next to vector search when people ask with exact terms.** Clause numbers, product codes, error codes and names are often missed by embeddings alone. Hybrid search finds both the exact term and the paraphrase.
-   **Add a reranker when the right passage is found but ranked too low.** A reranker scores the top results against the question before they reach the model. If recall is already low, fix chunking and search first; a reranker can’t promote a passage that was never retrieved.
-   **Chunk by the document’s own structure.** A clause, a table or a procedure step should stay in one chunk with its heading, page and version. Fixed-size chunks split tables and drop the exceptions that matter.
-   **Filter by permission before generation, never after.** The model should never see a passage the asker can’t open. Filtering the answer afterwards, or caching answers across users, leaks content.
-   **Decline rather than guess.** When retrieval finds nothing relevant, the system says it doesn’t know and, where it fits, offers a hand-off to a person.

Before a RAG system goes to its pilot group, we check that:

-   **Every role has negative tests**: questions it must not be able to answer, with the result proven, not assumed.
-   **The evaluation set includes unanswerable questions**, questions whose answer changed between versions, and questions about tables and scanned pages.
-   **Retrieval and answers pass the targets agreed in the proposal**, scored separately on the same evaluation set.
-   **Documents are screened for hidden instructions** at ingestion, and the system is tested against them. Indirect prompt injection (LLM01) and vector and embedding weaknesses (LLM08) are both on the OWASP Top 10 for LLM Applications, 2025 edition.
-   **Deleted and superseded documents are gone from the index**, and a test question proves it.

Our [comparison of RAG and fine-tuning](/blog/rag-vs-fine-tuning/) covers how RAG fails and how to spot each failure in more depth.

Process

## How we run it

1.  ### Collect real questions
    
    We gather questions people actually ask, with the documents that answer them. They become the evaluation set.
    
    Free call
    
2.  ### Content audit
    
    We check sources for duplicates, outdated versions, scanned PDFs and permission models before indexing anything.
    
    Audit
    
3.  ### Scope and proposal
    
    Sources, permissions, channels, evaluation targets and hosting, in a fixed proposal with milestone-based payments agreed in it.
    
    Fixed proposal
    
4.  ### Build and measure
    
    Demos with evaluation scores, at a cadence agreed in the proposal, so you see quality move, not only features.
    
    Regular demos
    
5.  ### Pilot and launch
    
    A pilot group first, with feedback buttons and trace review, then wider rollout and handover, with source code and IP transferred on final payment and a support period agreed in the proposal.
    
    Handover
    

Technology

## Tools we use for this

### Models

-   OpenAI
-   Anthropic Claude
-   Google Gemini
-   Open-weight models

### Retrieval

-   PostgreSQL + pgvector
-   Qdrant
-   OpenSearch
-   Cohere Rerank

### Frameworks

-   LangChain
-   LangGraph
-   LlamaIndex

### Parsing

-   Unstructured
-   Apache Tika
-   OCR for scanned documents

### Evaluation

-   Ragas
-   Promptfoo
-   LangSmith
-   Custom evaluation sets

Scope drivers

## What shapes scope

We don’t publish prices or week counts, because they depend on scope. These are the factors that actually move them.

01

### Number and type of sources

Each connector, file format and permission model is its own piece of work. Scanned PDFs and complex tables need extra parsing.

02

### Permission model

Mirroring document-level access from the source system is more work than a single shared index, and essential when content is sensitive.

03

### Content quality

Duplicates, outdated versions and contradictions need clean-up rules or a content owner’s decisions before indexing.

04

### Evaluation depth

A larger, carefully labeled evaluation set takes effort up front, and it is what tells you whether each later change helped or hurt.

05

### Hosting and data boundary

Using a model provider’s API is simpler than private deployment inside your infrastructure.

06

### Channels

A web interface, Slack or Teams bot, API or an embedded feature in your product each adds integration work.

### Every engagement includes

-   Source code & IP transfer
-   Documentation
-   Handover session
-   Post-launch support as agreed
-   Demos at an agreed cadence

**We give a fixed proposal after a free discovery call and a written scope of work.** [Prepare a brief with the Project Planner](/resources/project-planner/)

Comparison

## Search, RAG or fine-tuning?

Enterprise search

RAG

Fine-tuning

Answers in natural language

Shows sources

Links only

✓ cited passages

Stays current as documents change

✓ re-index

Needs retraining

Respects document permissions

✓ if designed in

Changes style or format

Limited

Best for

Finding documents

Answering from documents

Consistent behavior and format

Honest guidance

## When not to choose this

When not to use this

-   **The answers live in a database, not in documents.** Use a structured query or an [agent with a database tool](/services/ai-development/ai-agent-development/); retrieval over table exports is fragile.
-   **The content is small and stable.** A few pages fit in a prompt, or a well-organized FAQ does the job.
-   **Nobody owns the content.** RAG makes outdated or contradictory documents more visible; someone must fix them.
-   **Every answer needs a legal or medical judgment.** RAG can find and quote the source; a qualified person must interpret it.

Scope boundary

## What we engineer, and what others provide

### We engineer

-   Ingestion, retrieval, generation and evaluation
-   Permission filtering and data-boundary design
-   Interfaces, integrations and monitoring

### You provide

-   Access to sources and an owner for each collection
-   Real questions and expected answers for the evaluation set
-   Decisions on retention and acceptable use

### Licensed partners & providers

-   Model and embedding providers under their data terms
-   Vector database or cloud provider
-   Your identity provider for permissions

Security & quality

## How we keep it safe and correct

-   Permission filtering before generation, tested with role-based evaluation cases
-   Model plans whose terms exclude training on your data (paid API tiers), or self-hosted models; retention configured per provider
-   Prompt-injection tests for retrieved content, and screening for hidden text such as instructions in white-on-white type
-   Personal data redaction in logs and traces
-   Audit trail of questions, retrieved sources and answers where required

Engineering example

## Permission-aware knowledge assistant

The same question answered for three roles: retrieval filters what each one may see, cites its sources, and escalates when it can’t answer.

Illustrative engineering example: synthetic data, not a client project. Verified case studies will appear here when consented ones exist.

FAQ

## Questions buyers ask us

Not covered here? [Ask us directly](/contact/) — a person reads every message.

### ### What is a RAG system?

A system that answers questions by first retrieving relevant passages from your documents and then asking a language model to answer only from those passages, with citations.

### ### How do you stop a RAG system from hallucinating?

By measuring it. We constrain the model to cite retrieved passages, refuse when retrieval finds nothing relevant, and test faithfulness and citation accuracy on an evaluation set before every release. No RAG system is free of hallucinations; the aim is that unsupported answers are rare, caught by the evaluation set before release, and visible through citations and traces after it.

### ### Can different users see different answers?

Yes. Retrieval is filtered by each user’s permissions in the source system, so people only get answers from documents they can already open.

### ### Which vector database do you use?

Often PostgreSQL with pgvector, because many teams already run PostgreSQL, and its built-in full-text search covers the keyword side of hybrid search. Qdrant, OpenSearch or a managed service fit larger or more specialized loads. We choose after looking at volume, filters and hosting.

### ### Can it work with scanned PDFs and tables?

Yes, with OCR and table-aware parsing. Scanned and table-heavy documents need more parsing work and more evaluation cases, so we test them early.

### ### Can the system run without sending data to OpenAI or other providers?

Yes. Open-weight models and embeddings can run in your own cloud or infrastructure. See private AI systems for the trade-offs.

### ### How much does RAG development cost?

It depends on the number of sources, the permission model, content quality, evaluation depth, hosting and channels. We don’t publish prices. After a free discovery call and a written scope, we send a fixed proposal with milestone-based payments agreed in it.

### ### How do you keep answers up to date?

Incremental re-indexing when documents change, removal of deleted documents, and version rules so superseded content doesn’t outrank the current version.

Keep exploring

## Related services and reading

-   [Generative AI DevelopmentCustom GenAI apps with evals and cost control](/services/ai-development/generative-ai-development/)
-   [AI Chatbot DevelopmentChatbots grounded in your content, with hand-off](/services/ai-development/ai-chatbot-development/)
-   [AI Agent DevelopmentAgents that own one job end to end](/services/ai-development/ai-agent-development/)

### From the blog

![](/assets/img/r/rag-vs-fine-tuning-480.png)

AI & Machine Learning

### [RAG vs Fine-Tuning: How to Choose](/blog/rag-vs-fine-tuning/)

Retrieval-augmented generation gives a model your facts at answer time; fine-tuning changes how the model behaves. Most business problems need RAG first, some need fine-tuning, and a few need both. Here is how to tell which.

Solidity Labs · October 16, 2026 · 7 min read

![](/assets/img/r/ai-agent-vs-chatbot-vs-automation-480.png)

AI & Machine Learning

### [AI Agent vs Chatbot vs Automation: Which One Do You Need?](/blog/ai-agent-vs-chatbot-vs-automation/)

Chatbots answer, automations follow fixed steps, and agents decide their own steps. Picking the wrong one wastes money or adds risk. Here is a decision guide with examples, trade-offs and the questions to ask.

Solidity Labs · October 16, 2026 · 6 min read

![](/assets/img/r/securing-ai-agents-480.png)

AI & Machine Learning

### [Securing AI Agents: Prompt Injection, Data Leakage and Guardrails](/blog/securing-ai-agents/)

An AI agent reads untrusted text and can take actions, so a malicious email or web page can try to steer it. Here are the main risks, prompt injection, data leakage and excessive agency, and the controls that actually reduce them.

Solidity Labs · October 16, 2026 · 7 min read

Last reviewed: November 2026 Reviewed by our independent expert review under our [editorial policy](/editorial-policy/)
