Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Self correction loop for RAG when "answer is not possible given context" #5988

Closed
Timoeller opened this issue Oct 6, 2023 · 5 comments · Fixed by #6420
Closed

Self correction loop for RAG when "answer is not possible given context" #5988

Timoeller opened this issue Oct 6, 2023 · 5 comments · Fixed by #6420
Assignees
Labels
2.x Related to Haystack v2.0 P1 High priority, add to the next sprint type:feature New feature or request
Milestone

Comments

@Timoeller
Copy link
Contributor

Timoeller commented Oct 6, 2023

Is your feature request related to a problem? Please describe.
In RAG it can happen that requested information is not present in the given context documents.
Then the generative model is instructed to say: "answer is not possible given context".
But maybe the answer is present in documents that were not given to the generative model.

Please also look at deepset-ai/haystack-demos#23 and their insights into what is missing for implementing looping in a 2.0 pipeline.

Describe the solution you'd like
A loop passing retrieved documents, in order of relevance, until an answer is found or another stopping criterion is met.

Additional context
This feature is important to showcase how loops enhance RAG in a meaningful way.

@Timoeller Timoeller added type:feature New feature or request 2.x Related to Haystack v2.0 labels Oct 6, 2023
@Timoeller Timoeller added this to the 2.0-beta milestone Oct 6, 2023
@Timoeller Timoeller added P3 Low priority, leave it in the backlog P2 Medium priority, add to the next sprint if no P1 available and removed P3 Low priority, leave it in the backlog labels Oct 9, 2023
@DomEscobar
Copy link

The challenge is rly if we have to iterate over all documents or if the confidence is high enough to answer and stop🤔

@Timoeller Timoeller added P1 High priority, add to the next sprint and removed P2 Medium priority, add to the next sprint if no P1 available labels Oct 12, 2023
@Timoeller
Copy link
Contributor Author

Good point.

I agree that iterating over all documents is not something you want to do in any realistic scenario. We will have a max_iterations counter that stops the looping.

Relying on the confidence score to stop might be tricky since neither sparse, dense, or a combination thereof produces meaningful confidence scores to the best of my knowledge. You can easily get stuck in endless loops then. Or do you know more on this?

@TuanaCelik
Copy link
Member

Hey @Timoeller and @vblagoje to me it sounds like these 2 issues are solving similar situations: #6109

I may be totally off. But I want to add my 2 cents here too just in case.
I think the global issue we're trying to solve is having a 'decision' node, or a 'router' as Vladimir puts it. What happens based on that decision should be up to the user. For example, I'm trying to build a demo where 'if the answer is not provided, do websearch'. For Timo's scenario it's 'try again' and so on.

Would it make sense to combine these 2 efforts? Seems to me they might be going in a similar direction, with different implementation.

@ZanSara
Copy link
Contributor

ZanSara commented Oct 20, 2023

I think this one kind of depends on @vblagoje's issue. This one is oriented towards making a running example showcasing this feature, so imho it makes sense to keep both. Of course I'm gonna use the feature from that PR rather than implementing my own competing solution.

@TuanaCelik
Copy link
Member

If it's any help, here's my implementation: https://colab.research.google.com/drive/1LSrAnsL5yLzmrXE1JVBdagPLCUHEOPKO?usp=sharing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.x Related to Haystack v2.0 P1 High priority, add to the next sprint type:feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants