TL;DR
Multi-stage Prompt Refinement (MPR) is a lightweight, model-agnostic framework that uses specialized Small Language Models (SLMs) to clean and enrich poorly formulated user prompts before they reach a Large Language Model (LLM). By systematically correcting typos, grammatical errors, and ambiguous terms upfront, MPR achieves an average win rate of over 85% in reducing LLM hallucinations and improving output accuracy.
What Problem Does This Paper Address?
Large Language Models (LLMs) are notorious for "hallucinating"—generating text that sounds plausible but is factually incorrect. While substantial research focuses on fixing hallucinations by modifying model architectures or verifying outputs post-generation (post-hoc mitigation), the quality of the initial user prompt is often overlooked.
In the real world, user prompts are frequently "ill-formed," containing typos, poor punctuation, grammatical errors, or ambiguous jargon. These deficiencies confuse LLMs and directly trigger hallucinations. Existing prompt-optimization techniques typically rely on computationally expensive large models or manual human intervention, making them impractical for real-time, resource-constrained applications. MPR addresses this gap by providing an automated, efficient, and lightweight pre-processing pipeline to fix bad prompts before they cause trouble.
Methods
MPR introduces a three-stage pipeline powered by specialized SLMs (ranging from 2B to 7B parameters) fine-tuned using 4-bit Quantized Low-Rank Adaptation (QLoRA) to keep computational overhead minimal.
The framework operates as follows:
- Stage 1: Punctuation and Capitalization Correction: An initial classification SLM detects the types of errors present. Basic syntax and formatting issues (e.g., "what is the caPital of fRAnce?") are corrected to ensure syntactic clarity.
- Stage 2: Typographical and Syntactical Error Correction: Specialized SLMs identify and fix misspelled words or incorrect word choices (e.g., correcting "GAM" to "GAN").
- Stage 3: Semantic Alignment and Iterative Description Generation: The prompt is paraphrased to better align with user intent. If the prompt contains ambiguous technical terms or abbreviations (like "ViT"), a description SLM generates supplementary context (e.g., explaining that ViT stands for Vision Transformer). This stage includes a self-reflection mechanism where the SLM evaluates if the context is sufficient, ranks the generated descriptions using perplexity scores, and appends the highest-quality context to the final prompt.
Datasets
The authors utilized distinct datasets for both training the specialized SLMs and evaluating the overall framework:
- For Fine-Tuning SLMs:
- Online Language Modeling (OLM) Wikipedia dataset: Used to train models on punctuation and grammar correction.
- Grammarly CoEdIT dataset: Utilized for stylistic and grammatical refinement.
- Multi-domain Question Rewriting (MQR) dataset: Used to teach models nuanced paraphrasing and semantic equivalence.
- Magpie-Pro-300K-Filtered dataset: Leveraged to train models to generate concise definitions for technical keywords and abbreviations.
- For Evaluation:
- The framework was stress-tested using the Google Well-formed Query dataset, GSM8K (math reasoning), SQuAD (reading comprehension), and Natural Questions (NQ). The authors intentionally "sabotaged" these datasets by introducing three tiers of errors (punctuation, typos, and corrupted technical terms) to evaluate MPR's robustness.
Key Insights and Ideas
- "Garbage In, Garbage Out" is Preventable at Low Cost: Instead of relying on massive LLMs to rephrase prompts, small, highly specialized models (SLMs) can handle text normalization and contextual enrichment remarkably well, saving significant compute.
- Plug-and-Play Synergy: MPR acts as a frontend filter. Because it modifies the input prompt rather than the model itself, it can be seamlessly combined with existing post-hoc hallucination mitigation frameworks (like SelfCheckGPT or CoVE).
- SLMs are Capable of Self-Reflection: The paper demonstrates that even small models, when properly fine-tuned, can successfully execute iterative self-reflection and perplexity-based ranking to filter out low-quality or irrelevant contextual descriptions.
Key Results
The authors evaluated MPR across several popular SLMs, including LLaMA-2 (7B), Phi-3 (3.8B), and Qwen-2.5 (3B).
- Win Rate (WR): Prompts refined by MPR achieved an average win rate of 86% on the Well-formed Queries dataset compared to their original, unrefined forms.
- Hallucination Reduction: MPR significantly lowered the Hallucination Index (HI) across all datasets. For instance, on the Well-formed Queries dataset, the average HI dropped from a baseline of 0.81 down to 0.37.
- Efficiency: MPR added minimal latency, with a processing time of approximately 1215 ms, making it faster than several post-hoc verification methods while delivering superior or complementary accuracy boosts.
Limitations and Future Work
While MPR is highly effective, the authors note a few limitations:
- Domain-Specific Jargon: Because the SLMs were trained on general-purpose datasets, MPR may underperform in highly specialized fields like legal or medical sectors that use niche terminology.
- Lack of Human-in-the-Loop: The system is entirely automated; incorporating human feedback could help capture complex nuances more effectively.
- Evaluation Metrics: The metrics used (HI, Content Quality Score, Win Rate) primarily measure factual accuracy and relevance, but do not fully account for conversational fluency or subjective user satisfaction.
Future work will focus on developing domain-specific fine-tuning strategies for medicine and law, as well as extending the framework to multi-modal environments.
Summary updated