Resource mentioned in this lesson: Single and Double Underscore Naming Conventions in Python
Investigating Documents and Index
00:00
When I was prepping for this course, I got really curious about the document objects and its attributes, and the embeddings and the nodes in the index. Now, it is a bit outside of the scope of this course, so I’m not going to spend too long on it. I’ll leave this with you to investigate further if you’re interested, but I just wanted to show you how you could do that and how to get you on your way. So what you would do is you would need to change the code in policy_bot.py to this piece of code, so effectively take away the user input, the prompts, if you like, and so create the documents and the index.
00:38
And then in your REPL, you can import policy_bot as pb and then investigate the documents. So Document list and the elements of the list, which are your document objects, and you can pull attributes through such as text and metadata.
00:55
If you’re interested in the nodes, just a reminder of what the nodes are and then code on how you can investigate those. And then for embeddings, just a word of warning, the code I will show you in a second uses a non-public attribute, _data, so it starts with an underscore, so is not part of the public interface.
01:17 If you want to find out more about that, I’ll include a link to a course that talks about the use of underscores in Python. But the key here being that something that is not public, or that is not part of the public interface, will not be guaranteed to be supported.
01:34
And so in this particular case, the internals around vector_store._data have indeed shifted between different LlamaIndex releases. So if it doesn’t work, you might have to use a different release of LlamaIndex. But of course, never use non-public objects in production code because they are not supported.
01:55 With all that said, this is the code and a reminder of what embeddings are.
02:01 And that does take us to the end of the course. All that’s left to do now is to give you a quick summary of what you have learned and to point out some resources for you to investigate further.
Become a Member to join the conversation.
