Building a RAG systemAI answers from your documents.

A RAG system connects a language model to a search over your own documents. Before each answer the relevant passages are retrieved and handed to the model, so the AI answers from your data and can cite the source. This page explains how such a system is built and what matters during development.

01

How a RAG system is built

A RAG system has two parts. The first runs in advance and prepares the documents: they are read, split into smaller chunks, and an embedding, a vector of numbers describing the content, is computed for each chunk. These vectors are stored with the text in a vector database.

The second part runs for every question. The question is also turned into a vector, the most similar chunks are retrieved and sent to the language model together with the question. The model writes the answer and states which documents it comes from.

02

Development steps

First we agree which sources the AI should know, for example manuals, wiki, tickets, contracts or a database, and who may see which documents. Then come connectors that read the data regularly from PDFs, Word files, SharePoint, Confluence or via API.

Next the search is tuned. Chunk size, the embedding model and whether keyword search and reranking are added decide much of the quality. Finally there is an interface or an API, for example a chat in the intranet, an assistant in the ticket system or an AI agent that works with the answers.

03

Which vector database?

For many companies PostgreSQL with the pgvector extension is enough, especially if Postgres is already in use. With very many documents or special filters, dedicated vector databases such as Qdrant or Weaviate are an option. Access rights and updates matter more than the product.

04

Measure quality instead of guessing

A few test questions do not show whether a RAG system answers well. We build a list of real questions with correct answers together with you and measure whether the right passages are found and whether the answer is correct, again after every change to search, chunks or model.

Typical problems are outdated documents, duplicate versions, tables that break during import and questions the data does not answer. In that case the system should say it found nothing rather than invent something.

05

Privacy and operation

For confidential data the whole system runs on your own server or a server in Germany, with a local language model and local embeddings, so documents never leave the building. If cloud models are acceptable, we use providers with a data processing agreement.

The system takes over the permissions of the source systems: whoever may not see a document gets no answer from it. New and changed documents are loaded automatically, deleted ones disappear from the index.

Next

Related

Our service: AI Agents & RAG

Running it on your own hardware: Local AI Models

Also in this guide series: Training your own AI model

Terms explained: AI glossary

FAQ

Common questions

What is the difference between RAG and fine-tuning?

With RAG the model stays as it is and receives the relevant passages from your documents with each question. With fine-tuning the model itself is retrained, for example to learn your terminology or a fixed format. For knowledge from documents RAG is usually the better choice.

Can a RAG system run fully on premises?

Yes. With an open language model, local embeddings and a vector database such as pgvector, everything runs on your own server without data going to a cloud provider.

Which documents can be connected?

Typically PDFs, Word and Excel files, wikis such as Confluence, SharePoint, ticket systems, email and databases. Scanned documents work too, after text recognition.

Does the system cite the source?

Yes, every answer can link to the documents and passages it comes from, so the answer can be checked.

Ready when you are

Let’s talk.

Describe your project in a few sentences — you’ll get an honest assessment of feasibility, effort and the way forward.

E-Mail
kontakt@quell-code.com
Phone
+49 178 1561134
Response time
usually 2 working days
Languages
Deutsch · English · Türkçe