arXiv:2508.14323cs.CL2025-08

通过行为对齐检索,减少大模型误调用外部API

Beyond Semantic Similarity: Reducing Unnecessary API Calls via Behavior-Aligned Retriever

  • 基于行为一致性设计检索相似度,避免语义相近却行为相反的示例干扰
  • 在14个大模型和3个数据集上,显著降低错误调用率
  • 无需预判调用标签,兼容多种检索模型,适合工具增强型LLM研发

工具增强型大模型通过调用外部函数扩展能力,但调用决策错误(如无需调用却调用,或应调用却未调用)会导致输出不可靠并增加成本。现有方法仅通过语义相似度检索示例作为上下文引导,但语义相近的查询可能需相反行为,导致检索示例行为不一致,误导模型。本文提出行为对齐检索(BAR),一种与主干无关的训练方法,使密集检索器学习行为感知的相似性——仅当工具使用行为兼容时,语义相关的候选才被保持接近。BAR不预测调用标签,而是保留最终决策给LLM。在BERT、Contriever及Qwen-based等多个检索主干上应用,BAR在14个LLMs和3个基准测试中均显著提升调用可靠性,减少不必要的API调用。

原文摘要 · Abstract (English)

Tool-augmented LLMs invoke external functions to extend their capabilities, but errors in the invocation decision, such as calling a tool when none is needed or omitting a needed call, can produce unreliable outputs and unnecessary cost. A lightweight remedy is to prepend retrieved examples so LLMs decide tool use in context. However, existing retrievers rank examples by semantic similarity alone. Lexically close or semantically close queries can require opposite behavior, so the retrieved examples may be behaviorally inconsistent and silently mislead the model. We propose Behavior Aligned Retrieval (BAR), a backbone-agnostic training recipe that teaches a dense retriever a behavior-aware similarity, keeping semantically related candidates close only when their tool-use behavior is compatible. BAR does not predict invocation labels; instead, it ranks demonstrations while leaving the final tool-use decision to the LLM. Applied to multiple retrieval backbones, including BERT, Contriever, and Qwen-based representation backbone, BAR consistently improves invocation reliability and reduces unnecessary API calls across 14 LLMs and 3 benchmarks.

工具调用检索增强行为对齐大模型优化

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