Improve RAG responses via source backfilling #1477
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
resolves #1240
Pull Request Type
Warning
This PR enables
queryto work with chat history now but only in the app. Behavior in the embed is the same.In an effort to improve RAG results without adding unwarranted or "conditional" middleware like ReRankers, there is a lot of room for improvement of the traditional RAG pipeline AnythingLLM uses. This PR includes the ability to backfill sources during a chat session.
What is backfilling?
Currently, AnythingLLM will append
Contextsnippets to thesystemprompt on each chat. These contexts come from the attached VectorStores.similaritySearchmethod. While this works for direct questions this does not scale well as chat's become higher context or more vague. This leads to a bad RAG experience in a traditional chat, but is far worse inquerywhere a follow-up query, that is contextually relevant, is deemed irrelevant.Example
prompt 1: "What is anythingllm?"
prompt 2: "Tell me some features"
introduced in this pr
prompt 1: "What is anythingllm?"
prompt 2: "Tell me some features"
With this, we can now ensure that follow-up questions will be more relevant and contextually pertinent as a conversation continues.
"What if the contextual topic changes"?