用检索增强生成解决大模型工具选择时提示词过长问题
RAG-MCP: Mitigating Prompt Bloat in LLM Tool Selection via Retrieval-Augmented Generation
- 先通过语义检索从外部索引中找最相关工具,再让大模型处理
- 提示词长度减少超50%,工具选择准确率提升至43.13%(基线13.62%)
- 适合需要高效调用大量外部工具的智能系统开发者
大型语言模型在使用日益增多的外部工具(如由模型上下文协议MCP定义的工具)时,常因提示词过长和选择复杂而表现不佳。本文提出RAG-MCP,一种基于检索增强生成的框架,通过将工具发现任务外化来缓解该问题。RAG-MCP利用语义检索从外部索引中为给定查询识别最相关的MCP,仅将选中的工具描述传递给大模型,大幅降低提示词规模并简化决策过程。实验包括MCP压力测试,结果表明RAG-MCP显著减少提示词令牌数(例如减少超过50%),并在基准任务上将工具选择准确率从13.62%提升至43.13%。RAG-MCP实现了大模型对工具的可扩展且精准集成。
原文摘要 · Abstract (English)
Large language models (LLMs) struggle to effectively utilize a growing number of external tools, such as those defined by the Model Context Protocol (MCP)\cite{IntroducingMCP}, due to prompt bloat and selection complexity. We introduce RAG-MCP, a Retrieval-Augmented Generation framework that overcomes this challenge by offloading tool discovery. RAG-MCP uses semantic retrieval to identify the most relevant MCP(s) for a given query from an external index before engaging the LLM. Only the selected tool descriptions are passed to the model, drastically reducing prompt size and simplifying decision-making. Experiments, including an MCP stress test, demonstrate RAG-MCP significantly cuts prompt tokens (e.g., by over 50%) and more than triples tool selection accuracy (43.13% vs 13.62% baseline) on benchmark tasks. RAG-MCP enables scalable and accurate tool integration for LLMs.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。