No One Size Fits All: QueryBandits for Hallucination Mitigation
Organizations: JPMorgan AI Research, New York, NY, USA
Abstract
Advanced reasoning capabilities in Large Language Models (LLMs) have led to more frequent hallucinations; yet most mitigation work focuses on open-source models for post-hoc detection and parameter editing. The dearth of studies focusing on hallucinations in closed-source models is especially concerning, as they constitute the vast majority of models in institutional deployments. We introduce QueryBandits, a model-agnostic contextual bandit framework that adaptively learns online to select the optimal query-rewrite strategy by leveraging an empirically validated and calibrated reward function. Across 16 QA scenarios, our top QueryBandit (Thompson Sampling) achieves an 87.5% win rate over a No-Rewrite baseline and outperforms zero-shot static policies (e.g., Paraphrase or Expand) by 42.6% and 60.3%, respectively. Moreover, all contextual bandits outperform vanilla bandits across all datasets, with higher feature variance coinciding with greater variance in arm selection. This substantiates our finding that there is no single rewrite policy optimal for all queries. We also discover that certain static policies incur higher cumulative regret than No-Rewrite, indicating that an inflexible query-rewriting policy can worsen hallucinations. Thus, learning an online policy over semantic features with QueryBandits can shift model behavior purely through forward-pass mechanisms, enabling its use with closed-source models and bypassing the need for retraining or gradient-based adaptation.
Figures & tables
Appendix figures & tables22 assets
Supplementary material from the paper’s appendix.
Appendix
| Dataset | Scenario | Domain | License | Count | Citation |
| SQuADv2 | E, A | Wikipedia | CC BY-SA 4.0 | 86K | Rajpurkar et al. (2016) ; Rajpurkar et al. (2018) |
| TruthfulQA | M, A | General Knowledge | Apache-2.0 | 807 | Lin et al. (2022) |
| SciQ | M, A | Science | CC BY-NC 3.0 | 13K | Johannes Welbl (2017) |
| MMLU | M | Various | MIT | 15K | Hendrycks et al. (2021) |
| PIQA | M | Physical Commonsense | AFL-3.0 | 17K | Bisk et al. (2020) |
| BoolQ | M | Yes/No Questions | CC BY-SA 3.0 | 13K | Clark et al. (2019) ; Wang et al. (2019) |
| Model A | Model B | % Agree | Cohen’s | MCC |
| gpt-5-2025-08-07 | gpt-5-mini-2025-08-07 | 0.960 | 0.916 | 0.916 |
| gpt-4.1-2025-04-14 | gpt-4o-2024-11-20 | 0.925 | 0.826 | 0.826 |
| gpt-4o-2024-11-20 | gpt-5-2025-08-07 | 0.909 | 0.802 | 0.810 |
| gpt-4.1-2025-04-14 | gpt-5-2025-08-07 | 0.906 | 0.794 | 0.807 |
| gpt-4o-2024-11-20 | gpt-5-mini-2025-08-07 | 0.903 | 0.790 | 0.801 |
| gpt-4.1-2025-04-14 | gpt-5-mini-2025-08-07 | 0.900 | 0.782 | 0.798 |
| Stage | Median Tokens | Mean Tokens |
| Original query (input) | 16 | 19.3 |
| Feature-tagger output | 110 | 110.0 |
| Rewrite input | 26 | 29.3 |
| Rewrite output | 18 | 28.1 |
| Answer input | 64 | 91.3 |
| Answer output | 70 | 157.8 |
| Arm | Interpretation | Interpretation | ||
| Disambiguate | Subordination (100 %) | Long or nested clauses benefit from targeted disambiguation, which isolates and clarifies the core semantic relation. | Polysemy (0 %) | Highly polysemous terms lead disambiguation to pick the wrong sense, degrading downstream reward. |
| Simplify | Pragmatics (100 %) | Pragmatic cues (e.g. discourse markers, politeness) guide safe simplification without loss of meaning. | Superlative (0 %) | Stripping superlative constructions removes essential comparative context, hurting reward. |
| Expand | Constraints (100 %) | Queries already rich in constraints (time, location, numeric bounds) gain precision when expanded with further qualifiers. | Ambiguity (0 %) | Underspecified queries offer no detail to expand, so further addition of terms only introduces noise. |
| Paraphrase | Answerability (100 %) | Paraphrasing queries that are already answerable refreshes wording while preserving solvability, boosting LLM performance. | Presupposition (0 %) | Altering queries with strong presuppositions can break implied assumptions, reducing effective reward. |
| Clarify Terms | Rarity (100 %) | Defining rare or domain-specific terms anchors the LLM’s understanding of technical queries. | Subordination (0 %) | Clarifications in convoluted sentences can introduce further parsing difficulty, impeding reward. |
| ID | Arm | System prompt template |
| Paraphrase | You are a rewriting module. You will be given a user query: {original_query} . Rephrase it to improve clarity and introduce lexical diversity while strictly preserving semantic meaning, entities (including casing/accents), numbers, units, and constraints. Do not add or remove information. Output only the rewritten query. | |
| Simplify | You are a rewriting module. You will be given a user query: {original_query} . Simplify it by removing nested clauses and complex syntax. Use short, concrete phrasing (S–V–O order), keep all entities, numbers, units, and constraints, and avoid changing intent. Do not invent details. Output only the simplified query. | |
| Disambiguate | You are a rewriting module. You will be given a user query: {original_query} . Resolve vague references by replacing ambiguous pronouns (e.g., it/they/this) and temporal expressions with explicit, context-grounded referents and normalized dates. If a referent cannot be determined from the query alone, insert a bracketed placeholder (e.g., [ENTITY], [DATE]) rather than guessing. Preserve the original intent. Output only the disambiguated query. | |
| Expand | You are a rewriting module. You will be given a user query: {original_query} . Expand it by making implicit context explicit and adding salient, non-speculative attributes (e.g., scope, timeframe, location, units) that are entailed by the query. If crucial specifics are missing, insert neutral bracketed placeholders (e.g., [TIMEFRAME], [LOCATION]) instead of fabricating facts. Preserve the original intent and constraints. Output only the expanded query. | |
| Clarify Terms | You are a rewriting module. You will be given a user query: {original_query} . Identify domain-specific jargon or terms of art and add concise parenthetical glosses (e.g., “term (brief definition)”) where the meaning is standard and unambiguous. If uncertain, use a bracketed clarification placeholder (e.g., [DEFINE: TERM]) rather than guessing. Do not alter intent, entities, or constraints. Output only the clarified query. |
| Feature | Description | Citation |
| Structural Features | ||
| Anaphora | Contains anaphoric references (e.g., it , this ) | Schuster (1988) ; Chen et al. (2018) |
| Subordination | Contains multiple subordinate clauses (multi-clause structure) | Jeong et al. (2024) ; Blevins et al. (2023) |
| Scenario-Based Features | ||
| Mismatch | Question–task mismatch (e.g., open-ended query against retrieval-style task) | Gao et al. (2024) ; Kamath et al. (2024) |
| Presupposition | Assumptions within the query are implicitly regarded as truthful | Karttunen (2016) ; Levinson (1983) |
| Feature | Definition | Example | |
| Structural | Anaphora | Presence of pronouns or references requiring external context. | ”What about that one?” (Unclear reference) |
| Subordination | Measures the presence of multiple subordinate clauses | ”While I was walking home, I saw a cat that looked just like my friend’s.” | |
| Scenario-Based | Mismatch | Mismatch between the query’s intended output and its actual structure. | ”Find me this paragraph in this document” (When document isn’t given, this query cannot be answered) |
| Presupposition | Unstated assumptions embedded in the query. | ”Who is the musician that developed neural networks?” (Assumes such a musician exists) | |
| Pragmatics | Captures context-dependent meanings beyond literal interpretation. | ”Can you pass the salt?” (A request, not a literal ability) | |
| Lexical | Rarity | Use of rare or niche terminology. | ”What are the ramifications of quantum decoherence?” (Uses low-frequency terms) |
LLM Hallucination Mitigation
Large language model hallucination mitigation develops ways to detect and reduce unsupported, fabricated, or inconsistent outputs.
See all 178 papers