Loading video player…

Using LlamaIndex for RAG in Python (Overview)

Discover how to use LlamaIndex with practical examples. This framework helps you build retrieval-augmented generation (RAG) apps using Python. LlamaIndex lets you load your data and documents, create and persist searchable indexes, and query an LLM using your data as context.

In this video course, you’ll learn the basics of installing the package, setting AI providers, spinning up a query engine, and running queries against remote or local models.

By the end of this video course, you’ll understand that:

  • You use LlamaIndex to connect your data to LLMs, allowing you to build AI agents, workflows, query engines, and chat engines.
  • You can perform RAG with LlamaIndex to retrieve relevant context at query time, helping the LLM generate grounded answers and minimize hallucinations.

You’ll start by preparing your environment and installing LlamaIndex. From there, you’ll learn how to load your own files, build and save an index, choose different AI providers, and run targeted queries over your data through a query engine.

Download

Course Slides (.pdf)

2.5 MB
Download

Sample Code (.zip)

4.5 KB

00:00 Hey, hello, and welcome to this course where you’ll be using LlamaIndex for RAG in Python. There is a lot of content in this course, and I would argue there are at least two reasons for you to join me.

00:14 Now firstly, as you’ll find out, RAG is quite a crucial component of AI modeling, and it’s just one of those techniques that you really should have in your AI toolkit.

00:26 What RAG is exactly, you’ll cover later in the course, but just to temporarily satisfy your curiosity, RAG stands for Retrieval-Augmented Generation, and what it does, it allows LLMs to consult information they were not trained on.

00:45 Secondly, you will be getting your hands dirty with a real-life example of RAG, and I’m very excited about this course, and if you allow me a minute or two, I’ll share with you the real-life example that got me excited about RAG.

00:58 So, my lovely wife Louise wanted some help coming up with a shopping list based on the recipes of what we were planning on cooking for the coming week, and my first attempt was shot down in flames, I must admit, because I was using online recipes, not my wife’s recipes. My wife is very protective of these recipes, and they are not in the public domain, therefore. And this is exactly where RAG comes in, so a bit later, you’ll find out more about what RAG is exactly, but for now, just know that it allows you to feed secret documents, that being documents that are not in the public domain, into your AI model. Of course, the documents don’t have to be secret.

01:45 The point is that your LLM can consult any external document, secret or otherwise, that it wasn’t trained on. Anyway, with RAG, this app now works beautifully, and my wife’s recipes are still secret. And because they are secret, obviously, I will not be sharing those with you in this course, but you will be creating a real-life kind of company policy app with a secret company policy, and then you will use AI to analyze and interpret that company policy.

02:18 You’ll also learn something about hats and baseball caps. Right, so in this course, you’ll learn how to connect your data to LLMs and how to perform retrieval-augmented generation, because that is what RAG stands for.

02:34 Is there any useful knowledge you should have before starting this course? Well, you need an OpenAI API key if you want to code along. Now, those at the time of recording were not free. At the end of the course, I’ll show you a way of getting a free API key. It’s just not OpenAI, it’s Google, and you can use those, but that will be explained at the end of the course. But if you want to code along with me, you’ll need an OpenAI API key.

03:05 You’ll also need to know about virtual environments, and about persistent environment variables and about the pathlib standard library. Well, pathlib is actually a module that is part of the standard library.

03:19 If these things are new to you, don’t worry. I’ll provide links to courses where you can catch up and you can then therefore get going with this course. And that’s it for this intro.

03:32 My name is Steven Loyens. I’ll be your instructor and I hope you will join me in the next lesson. See you there.

Become a Member to join the conversation.