[GH-ISSUE #4071] [FEAT]: RAG retrieval process misses reference to chat history #2596

Closed
opened 2026-02-22 18:30:23 -05:00 by yindo · 1 comment
Owner

Originally created by @Alminc91 on GitHub (Jun 30, 2025).
Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/4071

What would you like to see?

Dear AnythingLLM team,

I have a feeling that the RAG pipeline does not reference the chat history the LLM model is aware of.

For example, imagine that I have fed data into my chatbot for an online course adviser. Let's assume that I have multiple sports courses in my repertoire.
When I ask for sports courses, the chatbot lists three courses.

However, if I then ask for more, the sources provided are completely irrelevant to my previous request. The LLM knows the chat history, but the RAG pipeline for retrieving suitable sources does not reference it.

My example:

Here, I ask for sports courses in German. The sources and the answer are relevant and relate to the request.

Image

Now, I ask for some more courses (related to the last request).

Image

In this case, the LLM tries to recommend additional sports courses that do not exist. Therefore, it hallucinates easily. This is because the sources are arbitrary; in my case, some random computer courses are retrieved.

This makes the chatbot far less useful for real conversations as I cannot really refer to previous requests using RAG.
I think it would be a valuable addition to AnythingLLM. Would this be very difficult? If there are any suggestions on how to do it, I could try to approach the problem.

Or is it just a user error on my part?

Thank you very much for your help and for the great software!

Originally created by @Alminc91 on GitHub (Jun 30, 2025). Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/4071 ### What would you like to see? Dear AnythingLLM team, I have a feeling that the RAG pipeline does not reference the chat history the LLM model is aware of. For example, imagine that I have fed data into my chatbot for an online course adviser. Let's assume that I have multiple sports courses in my repertoire. When I ask for sports courses, the chatbot lists three courses. However, if I then ask for more, the sources provided are completely irrelevant to my previous request. The LLM knows the chat history, but the RAG pipeline for retrieving suitable sources does not reference it. My example: Here, I ask for sports courses in German. The sources and the answer are relevant and relate to the request. ![Image](https://github.com/user-attachments/assets/b8ebebe6-8f1a-4ce7-b91d-f01f739c7ff7) Now, I ask for some more courses (related to the last request). ![Image](https://github.com/user-attachments/assets/19931748-3065-4802-8d53-c4cd253d266c) In this case, the LLM tries to recommend additional sports courses that do not exist. Therefore, it hallucinates easily. This is because the sources are arbitrary; in my case, some random computer courses are retrieved. This makes the chatbot far less useful for real conversations as I cannot really refer to previous requests using RAG. I think it would be a valuable addition to AnythingLLM. Would this be very difficult? If there are any suggestions on how to do it, I could try to approach the problem. Or is it just a user error on my part? Thank you very much for your help and for the great software!
yindo added the enhancementfeature request labels 2026-02-22 18:30:23 -05:00
yindo closed this issue 2026-02-22 18:30:23 -05:00
Author
Owner

@timothycarambat commented on GitHub (Jun 30, 2025):

This isn't user error nor an issue with the system, this is a model issue! The hallunications are the model behavior, likely the model is too small or over-quantized to get coherent results. In general, small over-quantized models get worse the longer a chat goes as the context window fills up.

As for RAG results, each query gets its own results. If none are found, previous citations will backfill this. Then, on top of this, the chat history is always included. However this is all assuming your context window is not tiny. To not overflow the context window, crashing the model, we will auto-prune the history. If the context window for your model is set to a low value youll see behavior like this.

You didnt mention what provider or model or system specs so I am making assumptions that usually explain the above for most people

@timothycarambat commented on GitHub (Jun 30, 2025): This isn't user error nor an issue with the system, this is a model issue! The hallunications are the model behavior, likely the model is too small or over-quantized to get coherent results. In general, small over-quantized models get _worse_ the longer a chat goes as the context window fills up. As for RAG results, each query gets its own results. If none are found, previous citations will backfill this. Then, on top of this, the chat history is always included. **However** this is all assuming your context window is not tiny. To not overflow the context window, crashing the model, we will auto-prune the history. If the context window for your model is set to a low value youll see behavior like this. You didnt mention what provider or model or system specs so I am making assumptions that usually explain the above for most people
yindo changed title from [FEAT]: RAG retrieval process misses reference to chat history to [GH-ISSUE #4071] [FEAT]: RAG retrieval process misses reference to chat history 2026-06-05 14:47:27 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#2596