RAG: Giving AI Agents Access to the Knowledge They Need

Utpal Kumar   3 minute read      

Loading likes…

Relevant passages retrieved from a document library flow into an AI agent to support an answer linked to its sources.

Imagine asking an AI assistant why a particular setting was changed in your software last month.

The model may understand the software. It may even explain what that setting does. But the actual reason could be buried in your meeting notes, an email, or a test report. Unless the system has access to that information, it cannot reliably answer your question.

This is where RAG becomes useful.

RAG stands for retrieval-augmented generation. The name sounds complicated, but the idea is simple: find relevant information first, then give it to the model to help generate an answer.

Think about how you work. When someone asks a question about a project, you may check your notes or open a document before replying. RAG gives an AI system a similar ability to look things up.

How does it work?

Let’s say you have a collection of research papers, software documentation, and meeting notes.

A typical RAG system first breaks those documents into smaller sections. It builds a searchable index so it can find useful sections without reading every document from beginning to end each time.

When you ask a question, the system searches that collection and retrieves relevant passages. Those passages are then included with your question in the information given to the language model.

The model uses them to prepare an answer. If the system keeps track of the sources, it can also point you to the original documents.

Many systems use something called embeddings to search by meaning. An embedding represents text as a list of numbers that helps a computer compare related ideas.

For example, a search for “Why is the system missing small earthquakes?” might find a report discussing “reduced detection sensitivity,” even though the wording is different.

Keyword search is still useful, especially for exact names, error messages, and configuration parameters. In practice, a system can combine both approaches.

Importantly, retrieving a document does not retrain the model. It provides information for the task at hand.

What changes when we add an AI agent?

A basic RAG workflow might search once and then answer.

An AI agent can use retrieval as one tool in a larger process. It can decide what to look up, inspect the results, notice something missing, and search again.

Let’s take a hypothetical example from seismic monitoring.

Suppose we ask an agent to investigate why a monitoring system has started reporting fewer earthquakes.

The agent could first retrieve the recent configuration changes. It might find that a detection threshold was increased. It could then search the software documentation to understand that parameter and retrieve a previous test report to see what happened when a similar change was made.

If it also has suitable analysis tools and permission to use them, it could compare event counts before and after the change.

Each result helps guide the next step.

RAG supplies relevant knowledge. The agent connects that knowledge to a sequence of decisions and, where authorized, actions.

Where do the “superpowers” come from?

The first advantage is access to specialized knowledge. An agent can use information from your own project, including material that was never part of the model’s training.

The second is access to updated information. When your documentation changes, the retrieval system can use the new version once its index is updated.

The third is continuity. Past experiments, decisions, and failed approaches can become searchable. An agent may be able to find out why your team rejected an idea instead of suggesting the same thing again.

That last part is particularly interesting to me. A useful agent should be able to build on what we have already learned.

What can still go wrong?

RAG depends on finding the right information. If the search misses an important document, retrieves an outdated version, or removes necessary context, the answer can still be wrong.

The model can also misinterpret a correct passage. A citation makes checking easier, but it does not prove the answer is correct.

We therefore need to evaluate both the retrieval and the final response. We also need access controls so the agent only retrieves information the user is allowed to see.

For important decisions, the system should make its evidence and uncertainty visible.

RAG gives us a practical way to connect AI agents with the knowledge around them. The real value comes when they can find the right evidence, use it carefully, and help us move the work forward.

References and further reading

Lewis, P., Perez, E., Piktus, A., Petroni, F., Karpukhin, V., Goyal, N., Küttler, H., Lewis, M., Yih, W.-t., Rocktäschel, T., Riedel, S., & Kiela, D. (2020). Retrieval-augmented generation for knowledge-intensive NLP tasks. Original RAG paper.

LangChain’s retrieval documentation: implementation guidance on document retrieval, embeddings, and agentic RAG.

KEEP THE CURIOSITY GOING

Found this article useful?

A little appreciation goes a long way.

Loading likes…

Disclaimer of liability

The information provided by the Earth Inversion is made available for educational purposes only.

Whilst we endeavor to keep the information up-to-date and correct. Earth Inversion makes no representations or warranties of any kind, express or implied about the completeness, accuracy, reliability, suitability or availability with respect to the website or the information, products, services or related graphics content on the website for any purpose.

UNDER NO CIRCUMSTANCE SHALL WE HAVE ANY LIABILITY TO YOU FOR ANY LOSS OR DAMAGE OF ANY KIND INCURRED AS A RESULT OF THE USE OF THE SITE OR RELIANCE ON ANY INFORMATION PROVIDED ON THE SITE. ANY RELIANCE YOU PLACED ON SUCH MATERIAL IS THEREFORE STRICTLY AT YOUR OWN RISK.


Leave a comment