From the course: Advanced RAG Applications with Vector Databases

Demo: Metadata

From the course: Advanced RAG Applications with Vector Databases

Demo: Metadata

- [Instructor] This section is about storing metadata with our chunk data. We'll start from the exact same place we left off in the last video. There's only a small change to make here. In link chain, metadata is stored within the document object. Last time we stored the chunks in the page content parameter. To store metadata, all we need to do is add a metadata parameter. Metadata is stored as a dictionary. You can define the metadata that you want to store. One of the most common pieces of metadata to store is the title of the document. For this example, we store this under doc title. We'll also store the chunk number. This tells us where in the document the chunk was taken from. Other than adding the metadata parameter to the last co snippet, there's another change to make here as well. We enumerate through the list instead of just looping through it. This is so we can access the chunk number and know where in the document the chunk was taken from. Let's take a look at our page content and metadata. See here that with this file text, we now have the chunk number as well as the title of the document that it came from.

Contents