Blog

What is RAG? AI that answers from your own documents

What is RAG? A plain explanation of how AI answers from your own documents, when you need it and when uploading files to ChatGPT or Claude is enough.

AI agents Walldy · · 8 min

What is RAG? Explained without jargon

RAG stands for retrieval-augmented generation. The idea is simple. Instead of the AI answering from memory, it first looks up relevant parts of your documents and then writes an answer based on what it found.

Compare it with two employees. One answers a customer question from what they remember. The other opens the staff handbook, finds the right section and answers from that. RAG lets the AI work the second way.

The technique was described in a research paper by Lewis and colleagues in 2020, and it has since become a common way to connect language models to a company's own knowledge. You do not need to understand the technique in detail to make decisions about it, but it helps to know what it does.

Keep in mind that RAG is not a product but a way of building. There are many ways to do it, and the quality of the result varies a great deal depending on how well the parts are made. When someone says a solution ”uses RAG”, that therefore says little about how good it is.

How RAG works, step by step

First the documents are prepared. They are split into smaller pieces, for example sections or paragraphs, and each piece is converted into a numerical pattern that captures its meaning. The patterns are stored in a searchable database. This is done once and updated when the documents change.

When someone asks a question, the same conversion is applied to the question. The system looks up the pieces whose meaning is closest to the question. So it can find the right section even when the question uses different words from the document.

Then the language model receives the question together with the selected pieces and the task of answering from them. A well-built system also asks it to state which sources the answer rests on and to say so if the material is not enough. That is why RAG solutions can give answers with references that can be checked.

This also explains why answers are sometimes wrong even though the documents are right. If the search does not find the relevant passage, the AI does not get the material it needs, and then it guesses or answers from something else. The fault then lies in the retrieval and not in the language model itself.

  • Split the documents into smaller pieces, for example sections.
  • Convert each piece into a searchable pattern and store it in a database.
  • Apply the same conversion to the question when someone asks it.
  • Retrieve the pieces closest to the question.
  • Let the language model answer from the pieces and state the sources.

RAG or uploading files to ChatGPT: what is the difference?

Even when you upload files in a tool such as ChatGPT or Claude, the tool may work in a similar way behind the scenes, so there is no sharp line between ”uploaded files” and ”RAG”. The difference lies in how much control you have and how large a volume is to be handled.

With uploaded files in a project it is easy to get started. You pick a few documents, write instructions and start asking. It suits cases where the material is small and current and a handful of people use it.

A custom RAG solution gives you control over how documents are split and searched, who may see what, how often the material is updated and how answers are logged. It can also be connected to your systems, for example an intranet, a case-handling system or a website.

A third option is to give the model the entire set of documents in a single call, which works for short texts but becomes expensive, slow and uncertain as the volume grows. RAG is a way of handling that by sending only what is needed.

When do you need RAG, and when are simpler solutions enough?

Always start with the simplest solution that works. If you have ten documents and five users, a project in an ordinary AI tool is probably enough. You get a quick start and learn which questions people ask.

It is when needs grow that RAG becomes interesting. A few signs that it is time follow below.

A simple way to decide is to try first and see where it chafes. If you notice that answers miss documents, that people miss source references or that permissions become a problem, you have probably reached the limit of the simple solution.

  • The volume of documents is large, hundreds or thousands of files, and it changes often.
  • Different people should see different things, and permissions must carry through into the answers.
  • Answers should be drawn from several sources, such as an intranet, a ticketing system, a contract archive and a knowledge base.
  • You want a chatbot or assistant that customers or external partners use.
  • You need logging, source references and the ability to follow up what the AI has answered.
  • The assistant should also do things, such as create a ticket or pass a draft on.

Examples: what RAG can do in different businesses

Imagined examples show what it can look like, and they are not descriptions of real customers. An accounting firm can let staff ask about internal routines, templates and earlier decisions instead of searching shared folders. The answer shows which document it was taken from, so the person asking can check.

A construction company can gather self-inspection templates, health and safety routines, product sheets and supplier information, and let site managers ask questions from their phones. A municipal company can let case officers search guidelines and decision material and get a summary with a reference.

An e-commerce business can connect a chatbot on its website to product information, shipping terms and returns policy, so the customer gets answers around the clock that rest on what actually applies. What the examples have in common is that answers should rest on the company's own knowledge and that it should be possible to see where they come from.

Common to all the examples is that you first need to decide what the assistant should not answer. An assistant for case officers should not, for example, give rulings in individual cases, and a chatbot on an e-commerce site should hand over to a person for complaints. The limits are part of the solution.

Why RAG fails: documents, splitting and permissions

Most problems with RAG are about the source material and not the AI. Outdated documents give outdated answers. Two documents that say different things give contradictory answers. And a PDF that is a scanned image, with no readable text, cannot be searched at all.

How the documents are split also matters. If the text is split in the wrong place, an explanation ends up in one passage and its exception in another, and the AI only gets half the picture. Tables, appendices and cross-references between documents need particular care.

Permissions are the third pitfall. If the system searches all documents without checking who is asking, sensitive information can turn up in the wrong answers. So check access already in the search and not only in the answer.

The tools also come with limitations of their own. Questions that require the AI to calculate on figures across several documents, or to compile information from the whole archive at once, work worse with simple RAG than with a solution that calls the right system directly. That is a different kind of problem, and sometimes an AI agent with tools is the right route.

TipTest with fifty real questions and mark each answer as right, partly right or wrong. Wrong answers almost always point to a document that needs correcting or an instruction that needs tightening.

How to get started, and how Walldy can help

The first step is to choose a narrow area where the knowledge is already written down and where many people ask the same questions. Go through the documents, remove what is outdated and decide who owns them. Then test with a project in an ordinary AI tool to see which questions come up.

Walldy runs training and workshops where you build a first assistant on your own documents and learn where the limits are. When the need grows, we build AI agents and chatbots with RAG that connect to your systems and follow your permissions. We gladly do a first review of which documents and use cases are closest.

FAQ

What does RAG mean in AI?

RAG is short for retrieval-augmented generation. The AI first retrieves relevant parts of a collection of documents and then writes its answer based on them. That lets answers rest on current, internal information and point to their sources.

Can AI answer from our own documents?

Yes. It can be done by uploading files to a project in tools such as ChatGPT or Claude, or through a custom RAG solution connected to your systems. The first suits small collections, the second when volume, permissions or connections grow.

Can you build a chatbot that answers from your own documents?

Yes, a chatbot can be connected to a knowledge base with RAG so that it answers from your documents and says where the answer comes from. The quality and upkeep of the documents decide how good it becomes, so ownership of the content matters.

What does it take to start with a RAG knowledge base?

Current documents in a readable format, a narrow area of use and someone who owns the content. Start with a small selection and test with real questions before you build out.

AI solutions Want help building it? Tell us what you would rather not do by hand, and we will propose an AI agent or automation that fits your systems. See what we build →
More posts

Keep reading.

Next step

What do you want to automate?

One line is enough. We normally reply within one working day and book a first call.

Newsletter

Stay up to date on AI in practice.

Guides, tips and news about AI for businesses, straight to your inbox. You can unsubscribe at any time.

We only use your details for the newsletter and never share them with anyone else. Read how we handle your data in our privacy policy.