LlamaIndex RAG: document indexing and OpenAI queries

Learn LlamaIndex's retrieval role and build a basic RAG pipeline with OpenAI models, SimpleDirectoryReader and VectorStoreIndex.

Player not loading? Watch on YouTube

This introduction to LlamaIndex explains how a RAG pipeline retrieves documents and passes relevant context to an LLM. Yash describes the steps involved: loading data, splitting documents into chunks, creating embeddings and querying a searchable index.

The speaker presents LlamaIndex as the retrieval layer and LangChain or LangGraph as orchestration tools for agent state, tool calls and multistep workflows. He treats them as complementary components rather than direct competitors.

The code configures LlamaIndex's global Settings object with OpenAI models. The supplied description identifies them as gpt-4.1-nano and text-embedding-3-small. The example loads an OpenAI API key through load_dotenv, so this walkthrough uses API calls rather than demonstrating how to run models locally.

SimpleDirectoryReader loads files from data/sample_docs, and VectorStoreIndex.from_documents() builds the index. The query engine then answers a question about Naruto's signature technique using the sample documents. A final rerun changes logging from warning to info so viewers can see the embedding requests and chat completion call. The episode demonstrates the complete basic loop; detailed inspection of each retrieval step is left for later lessons.