feat: add query_transformer parameter to BaseRAGQuestionAnswerer#209
Open
srishti-1935 wants to merge 1 commit intopathwaycom:mainfrom
Open
feat: add query_transformer parameter to BaseRAGQuestionAnswerer#209srishti-1935 wants to merge 1 commit intopathwaycom:mainfrom
srishti-1935 wants to merge 1 commit intopathwaycom:mainfrom
Conversation
szymondudycz
reviewed
Apr 9, 2026
Contributor
szymondudycz
left a comment
There was a problem hiding this comment.
This PR doesn't do what it's supposed to do. Query transformer prompts need to be sent to LLM to be rewritten. The result of query transformer should only be used for the sake of document retrieval, answering should be based on the original quesion.
Comment on lines
+647
to
+650
| if self.query_transformer is not None: | ||
| pw_ai_queries += pw_ai_queries.select( | ||
| prompt=self.query_transformer(pw.this.prompt) | ||
| ) |
Contributor
There was a problem hiding this comment.
pathway.xpacks.llm.prompts.prompt_query_rewrite and `pathway.xpacks.llm.prompts.prompt_query_rewrite_hyde`` are just prompts to be sent to an llm to ask to rewrite a question for the sake of retrieval. Replacing a question to RAG with these prompt makes the RAG completely wrong
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.
Closes #67
What this PR does
Adds a
query_transformerparameter toBaseRAGQuestionAnswerer.__init__()that allows users to set query transformation behaviour before retrieval.
Changes
query_transformerparameter (defaults toNoneto skip transformation)self.query_transformerin the classanswer_query()before retrieval if notNoneUsage example