Influence of Prompt Engineering on Small Language Models for Guarded Query Routing
Richard Šléher, William Brach, Kristián Košťál, Lukas Galke Poech
Abstract
We study the problem of guarded query routing, where we assume that a user query first meets a router that either determines the ideal endpoint for in-distribution queries or rejects out-of-distribution queries that are potentially unsafe or out of the system's scope. We investigate whether compact open-weight Small Language Models (SLMs) can jointly handle both tasks under latency constraints. We evaluate 22 models on GQR-Bench and score them with the harmonic mean of in-distribution and out-of-distribution accuracy. We find that mid-scale SLMs come close to frontier model routing quality at much lower latency. Still, many compact models fail because they do not reliably follow the required output format. However, our results show that prompt optimization techniques enable SLMs to handle such cases gracefully, without changing the models' weights. Moreover, few-shot prompt optimization raises Mistral 7B from 81.79 to 90.87 GQR-Score and lifts Qwen3.5 9B to 95.74, the best optimized score in our study and within 0.3 points of the strongest unoptimized larger model: Gemma 3 27B at 96.01. The bare DSPy signature, without in-context exemplars, is the most effective strategy for Granite 4 Tiny, raising its score from 54.29 to 83.05. These results show that prompt optimization is a useful first step for guarded query routing, while weaker models may still need weight-level adaptation or schema-aware training
Create a lesson
Metadata
- Categories
- cs.IR, cs.CL
Related papers
What Do Chinese-Language Generative Search Engines Cite and Surface? A Large-Scale Empirical Study
Shared title terminologycs.IRTao Zhen, Yue Liu, Gege Zhang et al.
Query Language Sensitivity in Automated Sentiment Scores of LLM Responses
Shared title terminologycs.IRDmitrij Żatuchin
OneQuery: Unified Sequence-to-Structure Generation for Multilingual E-commerce Query Understanding
Shared title terminologycs.IRMingyu Zhang, Jiejie Qin, Jianhui Ji et al.
Query Obfuscation with Embedding-Optimized Noise (EON): A Representational Blindspot in Agentic Retrieval
Shared title terminologycs.IRAnkit Gupta, Christoph Adami, Emily Dolson
Ask Again: Answer-List Instability in Generative Engines
Shared title terminologycs.IRBjörn Busch-Geertsema, David Antony Selby, Sebastian Vollmer
DM-Lab at TREC 2026 RAG: Multi-Query Retrieval, Ensemble Judging, and Claim-Pack Generation
Shared title terminologycs.IRElyas Irankhah, Muhammad Arif, Sreeraj Ramachandran et al.