# Gorilla

Gorilla 是加州大学伯克利分校 Sky Computing Lab 于 2023 年 5 月开发的大型语言模型，从 LLaMA-7B 微调而来，用于编写准确的 API 调用，同时提出了检索感知训练方法和 APIBench 基准测试，相关论文为《Gorilla：连接海量 API 的大型语言模型》（arXiv 2305.15334）。<sup>[1](https://arxiv.org/html/2305.15334v1)</sup> 该论文后来通过同行评审，发表于 NeurIPS 2024。<sup>[2](https://proceedings.neurips.cc/paper_files/paper/2024/hash/e4c61f578ff07830f5c37378dd3ecb0d-Abstract-Conference.html)</sup> 该项目发展成为一个函数调用模型系列、伯克利函数调用排行榜，以及面向 LLM 智能体的相关工具。<sup>[3](https://github.com/ShishirPatil/gorilla)</sup>

| 关键事实 | 内容 |
|---|---|
| 基础模型 | LLaMA-7B，结合文档检索进行微调<sup>[1](https://arxiv.org/html/2305.15334v1)</sup> |
| 首次发布 | 2023 年 5 月（arXiv 2305.15334）；2024 年在 NeurIPS 通过同行评审<sup>[1](https://arxiv.org/html/2305.15334v1)</sup><sup> • </sup><sup>[2](https://proceedings.neurips.cc/paper_files/paper/2024/hash/e4c61f578ff07830f5c37378dd3ecb0d-Abstract-Conference.html)</sup> |
| 基准测试 | APIBench：覆盖约 1,600 个机器学习 API 的 1,645 条 API 调用<sup>[1](https://arxiv.org/html/2305.15334v1)</sup> |
| 头条结果（作者报告） | 零样本准确率比 GPT-4 高 20.43%，比 ChatGPT 高 10.75%<sup>[1](https://arxiv.org/html/2305.15334v1)</sup> |
| 不使用 RAT 时的检索失败 | 使用非最优检索器时，准确率分别下降 21.50%（Torch Hub）和 47.57%（HuggingFace）<sup>[1](https://arxiv.org/html/2305.15334v1)</sup> |
| 许可证 | Apache 2.0，可用于学术和商业用途<sup>[3](https://github.com/ShishirPatil/gorilla)</sup> |
| 发布以来的规模 | 已处理约 50 万次请求（项目报告）<sup>[3](https://github.com/ShishirPatil/gorilla)</sup> |

## Gorilla 是什么

当时最先进的 LLM（包括 GPT-4）经常在编写 API 调用时失败，因为它们不知道哪些 API 存在，也不知道在频繁更新的工具集中如何调用这些 API；它们会生成不准确的输入参数，并因幻觉而生成错误的 API 用法，例如调用不存在的模型。<sup>[2](https://proceedings.neurips.cc/paper_files/paper/2024/hash/e4c61f578ff07830f5c37378dd3ecb0d-Abstract-Conference.html)</sup><sup> • </sup><sup>[4](https://sky.cs.berkeley.edu/project/gorilla/)</sup><sup> • </sup><sup>[5](https://gorilla.cs.berkeley.edu/blogs/1_gorilla_intro.html)</sup> Gorilla 针对这一问题，通过在大量 API 调用示例语料上微调 LLaMA-7B 模型，并在训练期间提供检索到的文档，使模型能够在推理时使用实时文档。<sup>[1](https://arxiv.org/html/2305.15334v1)</sup>

作者报告称，轻量微调的 Gorilla 在 APIBench 上实现了零样本最先进性能，比 GPT-4 高 20.43%，比 ChatGPT 高 10.75%，比开源 LLaMA 高出最多 83%，同时减少了因幻觉而生成的 API 参数。<sup>[1](https://arxiv.org/html/2305.15334v1)</sup> 这些数字来自作者自己的评估；NeurIPS 2024 发表的版本指出 Gorilla 在编写 API 调用方面超越了 GPT-4，但没有重复 20.43% 这一差距。<sup>[2](https://proceedings.neurips.cc/paper_files/paper/2024/hash/e4c61f578ff07830f5c37378dd3ecb0d-Abstract-Conference.html)</sup> 现有记录中没有出现对 APIBench 比较的独立复现，因此所有头条数字都应视为作者报告。<sup>[1](https://arxiv.org/html/2305.15334v1)</sup>

## 检索器感知训练如何工作

检索器感知训练（RAT）在微调期间将检索到的 API 文档直接附加到用户提示中，指令形式为“请参考以下 API 文档：<retrieved_API_doc_JSON>”。<sup>[1](https://arxiv.org/html/2305.15334v1)</sup> 由于训练数据将每次调用与检索到的文档配对，模型学会了判断检索到的文档是否相关，并在训练与测试之间 API 文档发生变化时进行适应。<sup>[1](https://arxiv.org/html/2305.15334v1)</sup> 同行评审论文将 RAT 描述为一种使 LLM 能够在推理时有效利用检索到的 API 文档的技术，同时提高准确性以及对 API 变化的适应能力。<sup>[2](https://proceedings.neurips.cc/paper_files/paper/2024/hash/e4c61f578ff07830f5c37378dd3ecb0d-Abstract-Conference.html)</sup>

这与将检索增强生成（RAG）附加到冻结模型上不同。作者测量了不完美检索的代价：在测试时向非 RAT 模型添加非最优检索器（BM25 或 GPT-Index），性能在 Torch Hub 上下降 21.50%，在 HuggingFace 上下降 47.57%。<sup>[1](https://arxiv.org/html/2305.15334v1)</sup> 论文还承认了一个更广泛的观点：用检索增强 LLM 并不总能提高性能，有时反而会损害性能。<sup>[1](https://arxiv.org/html/2305.15334v1)</sup>

## APIBench 与基于 AST 的评估

APIBench 通过抓取机器学习 API 构建，包含 1,645 条 API 调用：94 条来自 Torch Hub（穷举），626 条来自 TensorFlow Hub v2（穷举），925 条来自 HuggingFace（每个领域的前 20 个模型），覆盖约 1,600 个 API。<sup>[1](https://arxiv.org/html/2305.15334v1)</sup>

评估使用抽象语法树（AST）子树匹配，而非精确字符串匹配。<sup>[1](https://arxiv.org/html/2305.15334v1)</sup><sup> • </sup><sup>[2](https://proceedings.neurips.cc/paper_files/paper/2024/hash/e4c61f578ff07830f5c37378dd3ecb0d-Abstract-Conference.html)</sup> 该框架检查功能正确性，并将幻觉与准确性分开衡量。<sup>[2](https://proceedings.neurips.cc/paper_files/paper/2024/hash/e4c61f578ff07830f5c37378dd3ecb0d-Abstract-Conference.html)</sup>

## 测量结果及注意事项

头条比较是作者报告的：Gorilla 零样本在 APIBench 总体上比 GPT-4 高 20.43%，比 ChatGPT 高 10.75%。<sup>[1](https://arxiv.org/html/2305.15334v1)</sup> 论文还测试了上下文提示作为替代方案：三样本示例提高了 GPT-3.5 和 GPT-4 生成语法正确函数调用的能力，甚至在 Torch Hub 子集上匹配了 Gorilla，但 Gorilla 零样本平均仍优于三样本 GPT 模型。<sup>[1](https://arxiv.org/html/2305.15334v1)</sup> 项目博客还声称相对于 GPT-4、ChatGPT 和 Claude 减少了幻觉错误，代码库声称该项目首次展示了准确调用 1,600+ API 同时减少幻觉；两者均为厂商声称。<sup>[5](https://gorilla.cs.berkeley.edu/blogs/1_gorilla_intro.html)</sup><sup> • </sup><sup>[3](https://github.com/ShishirPatil/gorilla)</sup>

有两处证据缺口值得明确说明。第一，记录中没有任何来源量化幻觉减少的百分比；该声称是定性的。

## 2023 年之后发生了什么

该项目远远超出了原始模型。2023 年 6 月 5 日发布了可商用的 Apache 2.0 Gorilla 模型。<sup>[3](https://github.com/ShishirPatil/gorilla)</sup> Gorilla OpenFunctions-v0 和 v1 于 2023 年 11 月 16 日跟进，为 Apache 2.0 模型，支持并行和多函数调用；OpenFunctions-v2 增加了对并行函数（一次生成多个）、多函数（选择一个或多个）以及 Java、JavaScript 和 REST API 的原生支持，并扩展了数据类型。<sup>[3](https://github.com/ShishirPatil/gorilla)</sup><sup> • </sup><sup>[6](http://gorilla.cs.berkeley.edu/)</sup>

**伯克利函数调用排行榜（BFCL）** 于 2024 年 2 月 26 日启动，包含 2k 个问题-函数-答案对，覆盖 Python、Java、JavaScript 和 REST API，包括函数相关性检测，测试当提供的函数不适合用户问题时模型如何反应。<sup>[3](https://github.com/ShishirPatil/gorilla)</sup><sup> • </sup><sup>[6](http://gorilla.cs.berkeley.edu/)</sup> 后续版本扩大了范围：BFCL V2 Live 于 2024 年 8 月 20 日增加了企业贡献的数据；BFCL V3 于 2024 年 9 月 21 日增加了多轮和多步函数调用，并采用基于状态的评估系统；BFCL V4 Agentic 于 2025 年 7 月 17 日宣布，针对智能体场景中的工具调用，包括网络搜索、多跳推理、错误恢复、[智能体记忆](https://www.edgepedia.org/zh/agent-memory)管理和格式敏感性。<sup>[3](https://github.com/ShishirPatil/gorilla)</sup>

相关发布包括 GoEx（2024 年 4 月 12 日），一个用于 LLM 生成操作的运行时，具有事后验证、撤销和损害限制抽象；支持约 1,500 个 API 的 Gorilla CLI；RAFT 微调；API Zoo 数据集；以及与 [LMSYS Chatbot Arena](https://www.edgepedia.org/zh/lmsys-chatbot-arena) 合作的 Agent Arena（2024 年 10 月 4 日），用于在搜索、金融和 RAG 任务上比较智能体。<sup>[3](https://github.com/ShishirPatil/gorilla)</sup> 项目报告自首次发布以来已处理约 50 万次请求。<sup>[3](https://github.com/ShishirPatil/gorilla)</sup>

## 许可与可用性

Gorilla 采用 Apache 2.0 许可，适用于学术和商业用途，模型已公开发布；OpenFunctions 系列同样采用 Apache 2.0，适用于学术和商业用途。<sup>[3](https://github.com/ShishirPatil/gorilla)</sup>

## References

1. Gorilla: Large Language Model Connected with Massive APIs (arXiv, May 2023). https://arxiv.org/html/2305.15334v1
2. Gorilla: Large Language Model Connected with Massive APIs (NeurIPS 2024 proceedings). https://proceedings.neurips.cc/paper_files/paper/2024/hash/e4c61f578ff07830f5c37378dd3ecb0d-Abstract-Conference.html
3. ShishirPatil/gorilla (official project repository and changelog). https://github.com/ShishirPatil/gorilla
4. Gorilla – UC Berkeley Sky Computing Lab. https://sky.cs.berkeley.edu/project/gorilla/
5. Introduction to Gorilla LLM (project blog). https://gorilla.cs.berkeley.edu/blogs/1_gorilla_intro.html
6. Gorilla project site / Berkeley Function-Calling Leaderboard (UC Berkeley Sky Computing Lab). http://gorilla.cs.berkeley.edu/

---
*Initially written Sep 17, 2026 · Edited: Oct 11, 2026; Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 现代人工智能：基础模型、生成式人工智能与人工智能产业 › Foundation-model methods and training › Prompting, reasoning, and agents

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/gorilla-ep3w0b6sf1

English original: https://www.edgepedia.org/gorilla-ep3w0b6sf1
