Now booking discovery calls

Book a call

Global delivery

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.

Free discovery callNDA on requestFixed proposal after scoping

How a RAG system is measuredReal questions from your users are asked with the asker's identity, and a permission check keeps out anything they may not see. Retrieval is measured by recall, the share of needed passages found. Reranking is measured by precision, how well irrelevant passages are kept out. The answer is measured by faithfulness: no claim beyond the retrieved sources. Citations are measured by accuracy: each cited source supports the claim it is attached to. Real questionsfrom your usersRetrievalwere the passagesfound?Rerankingbest passages firstAnsweronly from passagesCitationseach claim sourcedPermission checknothing the askercan't seeRecallneeded passages foundPrecisionirrelevant passagesoutFaithfulnessno claim beyondsourcesCitation accuracysource supports theclaim
  1. Real questionsfrom your users
  2. Permission checknothing the asker can't see
  3. Retrievalwere the passages found?
  4. Recallneeded passages found
  5. Rerankingbest passages first
  6. Precisionirrelevant passages out
  7. Answeronly from passages
  8. Faithfulnessno claim beyond sources
  9. Citationseach claim sourced
  10. Citation accuracysource 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 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.

Retrieval-augmented generation pipelineIngestion: sources, parse and chunk, embed, index in a vector plus keyword store. Query time: question, hybrid retrieval with access filtering, reranking, language model, cited answer. An evaluation set and tracing check quality. INGESTIONQUERY TIMESourcesPDFs · wiki · ticketsParse & chunkstructure-awareEmbed+ metadata & ACLsHybrid indexvector + keywordQuestionwith user identityRetrievefiltered by permissionReranktop passagesLanguage modelgrounded promptCited answeror “I don’t know”Evaluation set & tracingfaithfulness · recall · cost
  1. SourcesPDFs · wiki · tickets
  2. Parse & chunkstructure-aware
  3. Embed+ metadata & ACLs
  4. Hybrid indexvector + keyword
  5. Questionwith user identity
  6. Retrievefiltered by permission
  7. Reranktop passages
  8. Language modelgrounded prompt
  9. Evaluation set & tracingfaithfulness · recall · cost
  10. Cited answeror “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.

MeasureQuestion it answersTypical fix when it is low
Retrieval recallDid the right passage reach the model?Chunking, hybrid search weights, query rewriting, metadata
Context precisionWere irrelevant passages kept out, with the best ones first?A reranker, fewer passages, tighter metadata filters
FaithfulnessIs every statement supported by the retrieved passages?Prompt constraints, smaller context, a stronger model
Citation accuracyDoes 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 relevanceDoes it answer the question that was asked?Query understanding, clarifying questions
Refusal accuracyDoes it say “I don’t know” when it should?Thresholds on retrieval scores, refusal examples in the evaluation set
Permission leakageDid anyone see content they can’t open?Filtering before generation; tested with role-based cases
Latency and costIs 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 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

Comparison

Search, RAG or fine-tuning?

CriterionEnterprise searchRAGFine-tuning
Answers in natural languageNoYesYes
Shows sourcesLinks only✓ cited passagesNo
Stays current as documents changeYes✓ re-indexNeeds retraining
Respects document permissionsYes✓ if designed inNo
Changes style or formatNoLimitedYes
Best forFinding documentsAnswering from documentsConsistent behavior and format

Honest guidance

When not to choose this

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 — 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

From the blog

AI & Machine Learning

RAG vs Fine-Tuning: How to Choose

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 · · 7 min read

AI & Machine Learning

AI Agent vs Chatbot vs Automation: Which One Do You Need?

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 · · 6 min read

AI & Machine Learning

Securing AI Agents: Prompt Injection, Data Leakage and Guardrails

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 · · 7 min read

Last reviewed: Reviewed by our independent expert review under our editorial policy

Get a quote WhatsApp

Have a build in mind? Let’s scope it properly.

Free discovery call · NDA on request

WhatsApp