arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2512.11986cs.LG
收藏

学习提取上下文以实现上下文感知的LLM推理

Learning to Extract Context for Context-Aware LLM Inference

Microsoft Research(微软研究院)

Minseon Kim, Lucas Caccia, Zhengyan Shi, Matheus Pereira, Marc-Alexandre Côté, Xingdi Yuan, Alessandro Sordoni

AI总结:

本文提出通过提取上下文信息提升LLM推理的安全性,减少有害输出并提高合规性。

摘要:

用户对大型语言模型(LLM)的提示通常模糊或不明确,微妙的上下文线索由用户意图、先前知识和风险因素塑造,强烈影响构成适当响应的内容。误解意图或风险可能导致不安全的输出,而过度谨慎的解释可能导致对良性请求的不必要拒绝。在本文中,我们质疑传统框架,即LLM在不考虑更广泛上下文因素的情况下生成即时响应。用户请求处于更广泛的上下文中,如意图、知识和先前经验,这些因素强烈影响构成适当回答的内容。我们提出一个框架,从用户提示本身提取并利用此类上下文信息。具体而言,一个基于强化学习的上下文生成器,以自编码器的方式设计,被训练以推断基于提示的上下文信号,并使用它们指导响应生成。这种方法对于安全任务尤为重要,其中模糊的请求可能绕过安全措施,而良性但令人困惑的请求可能触发不必要的拒绝。实验显示,我们的方法在SafetyInstruct数据集上,针对多个基础模型,平均减少了有害响应5.6%,并在XSTest和WildJailbreak上将攻击成功率和合规性的调和平均值提高了6.2%。这些结果证明了上下文提取在更安全和可靠LLM推理中的有效性。

英文摘要:

User prompts to large language models (LLMs) are often ambiguous or under-specified, and subtle contextual cues shaped by user intentions, prior knowledge, and risk factors strongly influence what constitutes an appropriate response. Misinterpreting intent or risks may lead to unsafe outputs, while overly cautious interpretations can cause unnecessary refusal of benign requests. In this paper, we question the conventional framework in which LLMs generate immediate responses to requests without considering broader contextual factors. User requests are situated within broader contexts such as intentions, knowledge, and prior experience, which strongly influence what constitutes an appropriate answer. We propose a framework that extracts and leverages such contextual information from the user prompt itself. Specifically, a reinforcement learning based context generator, designed in an autoencoder-like fashion, is trained to infer contextual signals grounded in the prompt and use them to guide response generation. This approach is particularly important for safety tasks, where ambiguous requests may bypass safeguards while benign but confusing requests can trigger unnecessary refusals. Experiments show that our method reduces harmful responses by an average of 5.6% on the SafetyInstruct dataset across multiple foundation models and improves the harmonic mean of attack success rate and compliance on benign prompts by 6.2% on XSTest and WildJailbreak. These results demonstrate the effectiveness of context extraction for safer and more reliable LLM inferences.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑