Repository navigation
query2e: remove chat-model framing from LLM output - #43
Merged
Merged
Conversation
Chat-tuned models wrap the Q2E keyword list in introductory text, markdown headings, category labels and <think> traces, which ended up in the expanded query. - Query2E cleans the LLM output before keyword parsing, controlled by a new clean_output param (default true). clean_output=false parses the raw output exactly as before. Prompts are unchanged. - Cleanup metadata (unclosed_think, truncated_at_query, cleanup_fallback, cleanup_empty) is recorded per query. - Add BaseReformulator.effective_params(); Query2E records clean_output: true when enabled, so cleaned runs get their own params_hash. - Pipeline records effective params, keeps empty recorded params, and reuses the recorded configuration when the reformulate step is skipped. - Add strip_think_trace() helper and --clean-output/--no-clean-output CLI flag. Query2E version 2.0. Fixes #42 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 #42
Summary
Chat-tuned models wrap the Query2E keyword list in introductory sentences, markdown headings, category labels and
<think>reasoning traces, which ended up in the expanded query. Query2E now cleans the LLM output before keyword parsing. The prompts are unchanged.Changes
querygym/methods/query2e.py: newclean_outputparam (defaultTrue). Removes<think>traces, lead-in/closing sentences, markdown headings, rules, code fences, category labels and term descriptions; keeps keyword lists, table cells, HTML/JSON lists; truncates extraQuery:/Keywords:pairs in few-shot mode. Falls back to the raw output only when it is itself a plain keyword list. Per-query metadata:clean_output,unclosed_think,truncated_at_query,cleanup_fallback,cleanup_empty.clean_output=Falseparses the raw output exactly as before. Method version 2.0.querygym/core/utils.py:strip_think_trace()helper.querygym/core/base.py:BaseReformulator.effective_params()— the JSON-serializable method params that identify a run. Query2E recordsclean_output: truewhen enabled, so cleaned runs get their ownparams_hash; other methods' recorded params are unchanged.querygym/cli.py:--clean-output/--no-clean-outputflag.examples/querygym_pyserini/: reformulation metadata recordseffective_params(); run summaries keep recorded empty params; when the reformulate step is skipped, the recorded configuration of the existing reformulated queries is reused (method/model must match).Testing
tests/test_methods_query2e.py: cleanup cases across output styles, think traces, few-shot truncation, fallback/empty handling,effective_params.reproducibility/tests/test_repro_schema.py: withclean_output=False, committed Query2E runs reproduce their recordedparams_hash; the default yields a different hash. Empty recorded method params are preserved in run summaries.clean_output=Falseoutput and metadata are identical tomain.🤖 Generated with Claude Code