Nexolve

Architecture · Knowledge

RAG Architecture: Grounding Language Models In Your Own Data

The short answer

Retrieval-augmented generation (RAG) answers questions from your own documents instead of the model's memory. An ingestion pipeline parses, chunks and indexes your sources; at question time, a retriever finds the most relevant passages, a reranker orders them, and the model writes an answer using only those passages, with citations. It keeps answers current and checkable without retraining a model.

By Maitreya Kulkarni · Updated · 11 min read

01 · The architecture

How Is A RAG System Wired?

As two pipelines that meet at the index. Ingestion turns your sources into searchable chunks ahead of time. At question time, the query skips straight to retrieval, the best passages are reranked, and the model answers from them. Evaluation results feed back into how documents are chunked.

NX-AR-04 · Architecture

Retrieval-augmented generation

  • Outside world
  • Data & integration
  • AI agent
  • System of record
  1. L1

    Sources

    (Outside world)
    • Documents and PDFs

      . Hands work to: Parse and chunk.
    • Wikis and tickets

      . Hands work to: Parse and chunk.
    • Databases

      . Hands work to: Parse and chunk.
    • User question

      At query time

      . Hands work to: Hybrid retrieval.
  2. L2

    Ingestion

    (Data & integration)
    • Parse and chunk

      Structure-aware, with permissions

      . Hands work to: Vector index, Keyword index.
  3. L3

    Index

    (Data & integration)
    • Vector index

      Embeddings, pgvector

      . Hands work to: Hybrid retrieval.
    • Keyword index

      BM25 full-text

      . Hands work to: Hybrid retrieval.
  4. L4

    Retrieve

    (AI agent)
    • Hybrid retrieval

      Both indexes, permission filter

      . Hands work to: Grounded generation.
    • Reranker

      Orders passages by relevance

      . Hands work to: Grounded generation.
  5. L5

    Generate

    (AI agent)
    • Grounded generation

      Answers only from passages

      . Hands work to: Answer with citations, Evaluation.
  6. L6

    Output

    (System of record)
    • Answer with citations

    • Evaluation

      Faithfulness, recall

      . Hands work to: Parse and chunk.
Permissions travel with every chunk, so retrieval only ever returns passages the asking user is allowed to see. The model is instructed to answer from the passages alone and to say when they don't contain the answer.

02 · Why RAG

Why Use RAG Instead Of Fine-Tuning Or A Long Prompt?

Because most business questions need facts that change, that must be cited, and that only some users may see. RAG handles all three. Fine-tuning changes behaviour rather than adding facts, and pasting everything into a long prompt gets slow, expensive and less accurate as the corpus grows.

Ways to give a model your knowledge
Best forRAGFacts, documents, Q&AFine-tuningBehaviour, format, styleLong contextA few documents at once
FreshnessRAGUpdate the indexFine-tuningRetrainLong contextRe-send every time
CitationsRAGNaturalFine-tuningHardLong contextPossible
PermissionsRAGFilter per userFine-tuningNoneLong contextManual
Cost at scaleRAGLowFine-tuningTraining plus hostingLong contextHigh per request

03 · Chunking

How Should Documents Be Chunked?

Along their structure, not at a fixed character count. Good chunks are self-contained passages that keep headings, tables and references intact, carry metadata about where they came from, and are small enough to be precise but large enough to make sense on their own.

01

Structure-aware splitting

Split at headings, sections and list boundaries; keep tables whole.

02

Context in every chunk

Prefix each chunk with its document title and section, or a generated summary, so it is findable out of context.

03

Metadata

Source, date, author and access rights travel with every chunk for filtering and citation.

04

Measure, then tune

Chunk size and overlap are tuned against retrieval metrics on real questions, not guessed.

04 · Retrieval

How Does Retrieval Find The Right Passages?

By combining meaning and wording. Vector search finds passages with similar meaning; keyword search finds exact terms such as product codes and names. Results from both are merged, filtered by permissions, and reranked by a model that reads each passage against the question.

01

Embeddings

A model turns text into vectors so that similar meanings sit close together.

02

Hybrid search

Vector and keyword results are fused, because each misses what the other catches.

03

Reranking

A cross-encoder scores each candidate against the question, sharply improving the top results.

04

Query rewriting

Vague or conversational questions are rewritten, or split into sub-questions, before searching.

05 · Grounding

How Do You Stop A RAG System From Making Things Up?

Instruct, constrain and measure. The model is told to answer only from the passages and to say when they don't contain the answer; every claim carries a citation; and faithfulness is measured on a test set so regressions are caught.

01

Answer only from context

Clear instructions and a refusal path when retrieval comes back empty.

02

Citations

Each statement links to the passage it came from, so a reader can check it.

03

Evaluation

Faithfulness, answer relevance and context recall scored on real questions.

04

Advanced patterns

Agentic RAG lets the model search repeatedly; graph RAG adds entity relationships for questions that span documents.

The ecosystem

  • pgvector
  • Supabase
  • OpenAI embeddings
  • Claude
  • LangChain
  • Hugging Face

Build it with us

We Build This For Real Businesses.

The services where this architecture does the work, designed, built and handed over by Nexolve.

FAQ

Questions About RAG Architecture.

Still unsure about something? Ask us

A store that indexes embeddings so you can find the nearest vectors to a query quickly. It can be a dedicated service or an extension such as pgvector inside the Postgres database you already run.

It reduces them substantially when retrieval is good, but does not remove them. Citations, refusal paths and faithfulness evaluation are what make the remaining errors visible and rare.

Yes, and it should: access rights are stored with each chunk and retrieval filters on the asking user's permissions before the model sees anything.

From a handful of documents to many millions of chunks. Scale changes the indexing and infrastructure choices, not the architecture.

Contact

Want This Architecture Built For You?

A 20-minute call. We'll listen to the problem, tell you honestly whether we're the right team for it, and outline what the build would look like.

  1. 01Tell us the problemA 20-minute call. Rough is fine.
  2. 02Get a scoped planWhat we'd build and what it takes, within 48 hours.
  3. 03Start on your timelineOnce the scope is signed off, we build in milestones.