From the course: Hands-On AI: Build a RAG Model from Scratch with Open Source

Unlock this course with a free trial

Join today to access over 24,900 courses taught by industry experts.

Preparing context, part 2

Preparing context, part 2

- [Instructor] And we're back. In the previous video, we covered the first half of this function, search by query, and in this video we're gonna cover the second half, really focusing on this function, get surrounding sentences. So first we're gonna create entry IDs and file names, which are the entry IDs from the filtered matches, just pulling the zero elements of the elements of this list, and doing the same for file names, pulling the third element, and those are just the file names. So let's go ahead and look at the function surrounding sentences, and what exactly it will be doing for us. We're gonna go ahead and scroll up, and put it right above this function, defined by query. And let's take a quick look. It takes these entry IDs and file names in, as well as a group window size and a session, which is just to connect to our database. And it then utilizes a few functions, group entries, consolidate groupings,…

Contents