DEV Community

Cover image for RAG FOR DUMMIES
Icefloqx Brian
Icefloqx Brian

Posted on • Edited on

RAG FOR DUMMIES

What is RAG?

Retrieval-augmented generation, or RAG, is a framework that combines the strengths of retrieval-based systems and generation-based models to produce more accurate & contextualized relevant responses. It does this through the following core components:

Retrieval: relevant data is identified & retrieved from an external data source based on a user query.

Augmentation: the retrieved data and the user query are combined into a prompt to provide the model with context for the generation step.

Generation: the model generates output from the augmented prompt, using the context to drive a more accurate and relevant response.

How RAG functions.

The first thing RAG does is take all the data and break them down into pages that we call “chunks”.

These chunks are then be converted into searchable dimensions/vectors by a process known as embedding which are then stored in a vector database.

After taken to the database which is more like our knowledge base, we smart fill the system that will always find the similar content when asked a question.

We will build the system that will only answer questions from the given document.

The RAG magic: Instead of just guessing, the system will first search your documents for relevant information, then use that information to generate accurate answers.

We'll then ask it questions. If it answers questions within the context then we'll conclude by saying the RAG is functioning.

Top comments (0)