提示工程对小型语言模型在受控查询路由中的影响 Influence of Prompt Engineering on Small Language Models for Guarded Query Routing 预印本

⚠️ 本文为 预印本(arXiv 公开版本),尚未经过正式同行评审。作者自发公开,结论未经期刊审稿验证,阅读时请知悉。
发布时间:2026-07-06
👁️ 预览文献
💡 AI 中文简介
研究让小型开源语言模型同时完成两项任务:为正常问题找到合适回答入口,并拒绝不安全或超范围的问题。在22个模型上测试发现,中等规模小模型路由质量接近大模型且延迟更低,但很多小模型因不遵守输出格式而失败。通过提示优化(不改模型参数),Mistral 7B得分从81.79升至90.87,Qwen3.5 9B达到95.74,接近最强未优化大模型Gemma 3 27B的96.01。
领域自然语言处理 / 高效语言模型与提示工程
适合谁读需要一定专业背景(了解语言模型、提示工程基本概念)
核心贡献1. 系统评估了22个小型语言模型在受控查询路由任务上的表现,揭示了格式遵循是主要瓶颈;2. 证明无需修改模型权重,仅通过提示优化(如少样本示例或DSPy签名)即可大幅提升小模型的路由与拒绝能力。
关键数据Mistral 7B从81.79提升至90.87 GQR-Score;Qwen3.5 9B达到95.74,接近Gemma 3 27B的96.01(差0.3分);Granite 4 Tiny从54.29提升至83.05;评估了22个模型。
推荐理由如果你关心如何用低成本小模型替代大模型做安全路由,这篇论文用扎实的实验告诉你:提示优化能解决大部分问题,值得一读。
关键词["提示工程", "小型语言模型", "查询路由", "分布外检测", "少样本提示优化", "延迟约束"]

原文摘要

查看英文原文摘要

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