Loading video player…

Coding Indexing

00:00 So in the previous lesson, you created a reader object and you called the load_data() method on that reader object to load the company policy into a list called documents, a list that holds document objects.

00:16 Now the next step is to index that list of document objects. Now what is an index? Well, an index is actually what provides the extra context or content to the AI model. So it’s going to have to somehow link to that list of document objects from line 5.

00:35 So keep that in mind. Now the index you will be using is the VectorStoreIndex class. And just as a little bit of background information, so a VectorStoreIndex splits your document objects into nodes and generates vector embeddings for those nodes. Now what are embeddings?

00:58 Well, embeddings are numerical representations of your text. So they are numbers, numbers that represent text. And the key here is that these numbers capture semantic meaning.

01:10 In other words, they represent what words mean.

01:15 That’s interesting, but it’s also very much beyond the scope of this course into the realms of how LLMs work, etc. So I’ll leave this with you, this little bit of extra background information.

01:28 But at the end of the course, I’ll show you how you can investigate nodes and embeddings. With all that said, please go to line 1 and import the VectorStoreIndex class from llama_index.core.

01:44 So line 1, comma, and then VectorStoreIndex.

01:51 Then go to line 8 and type index equals and then VectorStoreIndex.from_documents(). So call the method on the VectorStoreIndex.

02:05 And then this is where you feed in the documents list from line 5. So just type documents.

02:14 So that’s it. That’s all it takes to create an index. The next step would be to persist this index. Now for this basic example, you’re not going to do that.

02:24 You can skip that for now, but later in the course, you’ll cover persisting. For now, let’s move on to querying in the next lesson.

Become a Member to join the conversation.