Fix RAG retrieval silent failure and question key mismatch (#130) - #161
Open
rahulkate173 wants to merge 1 commit into
Open
Fix RAG retrieval silent failure and question key mismatch (#130)#161rahulkate173 wants to merge 1 commit into
rahulkate173 wants to merge 1 commit into
Conversation
Contributor
|
i went through both PR 160 and PR 161, and they look like two different solutions for the same current retrieval issue. am i missing some difference between them, or is PR 161 meant to replace PR 160? |
Author
|
Yes pr 161 is meant to replace pr 160 |
Contributor
|
Then you should close pr 160 , so it doesn't create confusion |
Author
|
Done Pr 160 closed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fix for Defect 1 (Core Retrieval Bug)
self.retrievertoself.vector_storeto store the raw FAISS index instead of the LangChainVectorStoreRetrieverwrapper.setup_vectorstore(): Removed the.as_retriever()call and now assigns the FAISS object directly toself.vector_store.get_relevant_document():Noneguard to handle cases where the vector store hasn't been initialized.self.vector_store.similarity_search_with_score(query, k=1)directly to retrieve(Document, float)tuples (where the float is the L2 distance).1.0 / (1.0 + distance). This ensures the threshold comparison works as expected (higher score = more similar).Note Regarding Defect 2
The reported wrong-key bug (
"query"vs"question") appears to have been resolved in a prior refactor. Therun()method no longer uses a LangChain chain withRunnablePassthrough. Instead, it already formats the prompt directly viaself.prompt_template.format(question=..., context=...)and callsself.provider.generate(). No further changes were required for this defect.Closes #130