Skip to content

feat: add query_transformer parameter to BaseRAGQuestionAnswerer#209

Open
srishti-1935 wants to merge 1 commit intopathwaycom:mainfrom
srishti-1935:feature/query-transformer-baseragqa
Open

feat: add query_transformer parameter to BaseRAGQuestionAnswerer#209
srishti-1935 wants to merge 1 commit intopathwaycom:mainfrom
srishti-1935:feature/query-transformer-baseragqa

Conversation

@srishti-1935
Copy link
Copy Markdown

Closes #67

What this PR does

Adds a query_transformer parameter to BaseRAGQuestionAnswerer.__init__()
that allows users to set query transformation behaviour before retrieval.

Changes

  • Added query_transformer parameter (defaults to None to skip transformation)
  • Stored as self.query_transformer in the class
  • Applied transformation in answer_query() before retrieval if not None

Usage example

from pathway.xpacks.llm.prompts import prompt_query_rewrite
rag = BaseRAGQuestionAnswerer(
    llm=chat,
    indexer=vector_server,
    query_transformer=prompt_query_rewrite,
)

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 5, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Copy Markdown
Contributor

@szymondudycz szymondudycz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow setting query transformers in the BaseRAGQA

3 participants