arXiv:2601.10398cs.AI2026-01ACL被引 1

通过分析模型中间激活信号,提前识别无法回答的文本转SQL查询。

LatentRefusal: Latent-Signal Refusal for Unanswerable Text-to-SQL Queries

  • 从模型隐藏层激活中提取线索,判断查询是否可答。
  • 在4个基准上提升平均F1至88.5%,仅增加2毫秒延迟。
  • 适合需要安全可靠的SQL生成系统的开发者使用。

在基于大语言模型的文本转SQL系统中,无法回答或表述不全的用户查询可能生成错误文本及可执行程序,导致误导性结果或违反安全约束,严重阻碍安全部署。现有拒绝策略要么依赖输出层面的指令遵循(易受幻觉影响),要么估算输出不确定性(增加复杂度与开销)。为此,我们将文本转SQL中的安全拒绝形式化为可回答性门控问题,提出LatentRefusal——一种从大语言模型中间隐藏激活中预测查询可回答性的潜在信号拒绝机制。引入轻量级三残差门控编码器,抑制模式噪声并放大提示-模式不匹配的稀疏局部信号,以指示不可回答性。在多种模糊和不可回答场景下的广泛实验评估,结合消融研究与可解释性分析,验证了该方法的有效性。结果显示,LatentRefusal在两个骨干模型上均将平均F1提升至88.5%,仅增加约2毫秒探测开销,可作为文本转SQL系统的即插即用高效安全层。

原文摘要 · Abstract (English)

In LLM-based text-to-SQL systems, unanswerable and underspecified user queries may generate not only incorrect text but also executable programs that yield misleading results or violate safety constraints, posing a major barrier to safe deployment. Existing refusal strategies for such queries either rely on output-level instruction following, which is brittle due to model hallucinations, or estimate output uncertainty, which adds complexity and overhead. To address this challenge, we formalize safe refusal in text-to-SQL systems as an answerability-gating problem and propose LatentRefusal, a latent-signal refusal mechanism that predicts query answerability from intermediate hidden activations of a large language model. We introduce the Tri-Residual Gated Encoder, a lightweight probing architecture, to suppress schema noise and amplify sparse, localized cues of question-schema mismatch that indicate unanswerability. Extensive empirical evaluations across diverse ambiguous and unanswerable settings, together with ablation studies and interpretability analyses, demonstrate the effectiveness of the proposed approach and show that LatentRefusal provides an attachable and efficient safety layer for text-to-SQL systems. Across four benchmarks, LatentRefusal improves average F1 to 88.5 percent on both backbones while adding approximately 2 milliseconds of probe overhead.

文本转SQL安全机制大模型推理

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。