Prakash Chaulagain
2 min readMay 17, 2024

Understanding key stages of RAG with ‘SODHPUCHH(सोधपुछ):A query engine built with Llamaindex’ (Part — I)

Why RAG?

LLMs come pre-trained on huge amounts of publicly available data, which is why it may not be wise to use them directly for solving our domain-specific problems. Furthermore, we may want LLMs to generate only the authentic sequence of tokens according to our private data. This is where RAG comes in as a savior.

How RAG works?

In RAG, our data is loaded and prepared for queries or “indexed”. User queries act on the index, which filters the data down to the most relevant context. This context and our query then go to the LLM along with a prompt, and the LLM provides a response.

Image Source: https://docs.llamaindex.ai/en/stable/getting_started/concepts/

What is Llamaindex?

LlamaIndex is a framework for building applications of any use case that applies LLMs on top of our own private data. LlamaIndex provides tools to enable Retrieval-Augmented Generation (RAG), which combines context with LLMs at inference time. In this series of article, we will be leveraging the following tools provided by Llamaindex:

  • Data connectors: To ingest our existing data(PDFs) from their native source and format.
  • Data indexes: To structure our data in intermediate representations that are easy and performant for LLMs to consume.
  • Query Engines: A powerful interfaces for question-answering.
  • Agents: LLM-powered knowledge workers augmented by tools.

What are the key stages of RAG?

Image Source: https://docs.llamaindex.ai/en/stable/getting_started/concepts/

We will learn in brief about each of these stages in the next article:)

What is ‘SODHPUCHH(सोधपुछ):A query engine built with Llamaindex?

→Yes👍

We are going to build a query engine, basically a simple use case of RAG that answers the questions related to several laws, acts and constitution of Nepal. The data is downloaded from Nepal Law Commission (Existing Laws).

In the next article we will be going through each stages of RAG and implement them using the tools provided by Llamaindex.