technovangelist / tryingsqr

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Self Query Retrieval

Introduction

Retrieval Augmented Generation (RAG) is what developers usually reach for when they want to ask questions to all of their notes. But often it doesn't give the results you need. And that's because there is still too much information. And frequently it's the wrong information. When you ask a question, RAG will retrieve a set of documents that are relevant to the question and then hand them off to the LLM. It will find the right documents or sub-documents based on a similarity search. What documents are similar to your question.

But often the question includes information that is better suited to a traditional database search of structured data. The purpose of Self Query Retrieval is to use those more traditional structured queries to narrow down the set of documents that RAG can then do its similarity search on.

How it works

There are a few things you need to do to enable Self Query Retrieval. First, there needs to be additional metadata about your content in the database. The examples in the Langchain documentation are based on movies, and the metadata includes the year, the director's name, the genre, etc. And then you need to pass the schema to the query to help it get the right documents.

The code

There are two main parts to the code. First there is a GenerateSource.ts file and then there is a FindArt.ts file. Let's look at GenerateSource first.

GenerateSource

t

About


Languages

Language:TypeScript 100.0%