From the course: Hands-On AI: RAG using LlamaIndex

Setting up your environment - LlamaIndex Tutorial

From the course: Hands-On AI: RAG using LlamaIndex

Setting up your environment

- [Instructor] Now that we have a codespace instance spun up, it's time to set up a development environment. If you are following along on codespaces, then just do everything that I'm doing. If you're following along locally, you're also going to do everything that I'm doing as well. The only time you can skip this lesson is if you're choosing to run all of the notebooks in a Google Colab environment. If that's the case, then fear not as the first cell in every single Google Colab has the first cell of every single notebook that I've created has the necessary installs pin to the version that I'm using. So I'm going to use Conda as the package manager. Conda comes pre-installed on codespaces, which is awesome. I don't know if venv for poetry comes pre-installed on codespaces. I did not bother to check as I don't usually use venv for poetry, but if you like using venv for poetry and you want to do so locally, there's nothing stopping you from doing that. I'm just choosing to use Conda. If you haven't used Conda before ever, well, then head over to the Conda website and follow the instructions, get set up, and download it with Conda and you can come back and follow along. That's only necessary if you're running this locally. All right, so you can verify that this actually has Conda installed by just running Conda on the command line. So you need to first init Conda. So that's the first thing that we need to do. And you can do that by just typing in conda init, all right? So we need to then close this shell and then reopen it. So just hit that X here, and then what you're going to do is hit Control + Shift + backtick, and that opens the terminal up again. And you can see that we have a base Conda environment. Now, let's go ahead and create a new Conda environment. This Conda environment, I'm going to call lil for LinkedIn Learning _llama_index. I'm going to use python==3.10 and also install python-dotenv. If you want to choose to use Python 3.11 or Python 3.12, by all means, go ahead, go for it. In my experience with these newer frameworks and libraries, every time I use Python 3.11 or Python 3.12, I run into some weird issues. Plus, I mean, I've been using Python 3.10 extensively for the last couple of years with no issues, so I'm going to go ahead and use that. So go ahead and run that line of code right here. You can copy and paste it. You can just go ahead and type it out if you'd like, and it'll take about a minute or so to install. Follow along with the prompts here. All right, now that everything has installed, we can go ahead and activate our environment. You can go ahead and just copy and paste this line right here and activate the environment. And we are good. We are now in our LinkedIn Learning LlamaIndex environment. If you're running this locally and you don't have ipython kernel jupyter jupyterlab installed, you can go ahead and run this. If we run conda list here, we can verify what we have installed. We actually don't have these installed in this current environment, so let's go ahead and install them now. It's taking a little bit of time here to download. All right, so all of that has been installed. If you're running this locally, you can verify that JupyterLab was installed by running this line right here. I'm not going to do that at the moment. And now, we can start to install some of the core libraries and packages that we need to get started. If there's anything needed outside of what we are about to install here, I'm going to make sure that I outline that in the cell of every single notebook that we are running through. But for right now, let's just go ahead and install everything that we need. So I'm going to just use the starter package for LlamaIndex right now. So LlamaIndex is nicely separated into numerous small packages, and I'll talk about that in a later module. I'll go ahead and install the starter package. And that's just this right here. We're using the, as of now, most current version of LlamaIndex and that's version 0.10.37. All right, so you can see that we've got all of that installed. So we're working at the edge of technology here. Really, we are. LlamaIndex is changing rapidly. OpenAI, Cohere, all of these libraries are changing rapidly. You better pin the versions of the libraries that I am using as we progress along through this course. Now, don't worry if you're coming back to this course in the future, and LlamaIndex is at version 0.10.55 or 0.10.99, like not too much is going to actually change. The reason LlamaIndex bumps up incrementally for the minor versions like that is because providers are pumping out new models all the time. New large language models, new embedding models, new techniques for vector search, so on and so forth. And so since LlamaIndex is, you know, relying on these frameworks, it needs to grow with it. So if you're coming back in the future and you notice that LlamaIndex is at like 0.10.99, like don't worry. Like this course is still going to be useful for you. What matters are the principles and patterns that we're going to use. All right, so let's go ahead and install Qdrant. Qdrant is going to be the vector database of choice throughout this course. I'll talk about choosing a vector database in a later module, but let's go ahead and just install Qdrant right now. And that's just right here, pip install qdrant to client and it's currently at version 1.9.1 and that's going to go ahead and get installed. And then, we are going to install the LlamaIndex dependencies for working with external files and for working with vector databases like Qdrant. So, as I've mentioned, LlamaIndex is nicely decoupled, like it's got a number of smaller libraries that kind of feed into it. We'll talk about this in a later video. So we'll go ahead and install Qdrant vector store as well as this reader's file, which we're going to need and then we're going to install our LLM libraries. So, throughout this course, I'm going to make use of Cohere and OpenAI. If you want to use any other type of LLM provider, you are more than welcome to do so. LlamaIndex makes it easy to install them. They all kind of follow this general pattern, right? Like, let's say if you wanted to use Mistral, you do llama-index-llms-mistral. And you know, if you wanted to use Hugging Face, it's something similar. So, a lot of these patterns are similar, and I'll talk about LlamaIndex and how it's organized and structured more in just a couple of videos. The first video in the next module is just talking about how LlamaIndex is organized. But for right now, just go ahead and follow along with me, blindly follow along, and then just do the installations and trust that I'm looking out for your best interest. All right, cool. So, let's go ahead and install all of this. So I'm installing Cohere, OpenAI, and these are the base libraries and then I have to do the LlamaIndex integration for each one of those. I'm writing this at a time where the most current Cohere model is the Command R+ and the most recent model from OpenAI is GPT-4o. So we'll be making use of those in this course. Next up is the LlamaIndex integration with OpenAI, so let's go ahead and install all that. We'll install the embeddings and we're also going to use the Cohere postprocessor for reranking, so let's go ahead and install that. All right, so if you're running this locally, you might need to link the IPython kernel to your Conda environment. So if we go here and we open this up, you'll see here it's asking us to select the kernel. All right, so this is just a later notebook. You'll see here that we have to select a kernel and we go to Python Environments and we have lil_llama_index here already for us. So, if you're running this locally and you're trying to select the kernel and you notice that the environment that you just set up is not there, then this is the line of code that you are going to run to attach a environment to your notebook. And that's it. So we are all set up. Our development environment is all good and ready to go. And in the next video, I'm going to talk about how to choose a LLM and embeddings provider.

Contents