code-act
收藏魔搭社区2025-11-15 更新2024-06-22 收录
下载链接:
https://modelscope.cn/datasets/thomas/code-act
下载链接
链接失效反馈官方服务:
资源简介:
<h1 align="center"> Executable Code Actions Elicit Better LLM Agents </h1>
<p align="center">
<a href="https://github.com/xingyaoww/code-act">💻 Code</a>
•
<a href="https://arxiv.org/abs/2402.01030">📃 Paper</a>
•
<a href="https://huggingface.co/datasets/xingyaoww/code-act" >🤗 Data (CodeActInstruct)</a>
•
<a href="https://huggingface.co/xingyaoww/CodeActAgent-Mistral-7b-v0.1" >🤗 Model (CodeActAgent-Mistral-7b-v0.1)</a>
•
<a href="https://chat.xwang.dev/">🤖 Chat with CodeActAgent!</a>
</p>
We propose to use executable Python **code** to consolidate LLM agents’ **act**ions into a unified action space (**CodeAct**).
Integrated with a Python interpreter, CodeAct can execute code actions and dynamically revise prior actions or emit new actions upon new observations (e.g., code execution results) through multi-turn interactions.

## Why CodeAct?
Our extensive analysis of 17 LLMs on API-Bank and a newly curated benchmark [M<sup>3</sup>ToolEval](docs/EVALUATION.md) shows that CodeAct outperforms widely used alternatives like Text and JSON (up to 20% higher success rate). Please check our paper for more detailed analysis!

*Comparison between CodeAct and Text / JSON as action.*

*Quantitative results comparing CodeAct and {Text, JSON} on M<sup>3</sup>ToolEval.*
## 📁 CodeActInstruct
We collect an instruction-tuning dataset CodeActInstruct that consists of 7k multi-turn interactions using CodeAct. Dataset is release at [huggingface dataset 🤗](https://huggingface.co/datasets/xingyaoww/code-act). Please refer to the paper and [this section](#-data-generation-optional) for details of data collection.

*Dataset Statistics. Token statistics are computed using Llama-2 tokenizer.*
## 🪄 CodeActAgent
Trained on **CodeActInstruct** and general conversaions, **CodeActAgent** excels at out-of-domain agent tasks compared to open-source models of the same size, while not sacrificing generic performance (e.g., knowledge, dialog). We release two variants of CodeActAgent:
- **CodeActAgent-Mistral-7b-v0.1** (recommended, [model link](https://huggingface.co/xingyaoww/CodeActAgent-Mistral-7b-v0.1)): using Mistral-7b-v0.1 as the base model with 32k context window.
- **CodeActAgent-Llama-7b** ([model link](https://huggingface.co/xingyaoww/CodeActAgent-Llama-2-7b)): using Llama-2-7b as the base model with 4k context window.

*Evaluation results for CodeActAgent. ID and OD stand for in-domain and out-of-domain evaluation correspondingly. Overall averaged performance normalizes the MT-Bench score to be consistent with other tasks and excludes in-domain tasks for fair comparison.*
Please check out [our paper](TODO) and [code](https://github.com/xingyaoww/code-act) for more details about data collection, model training, and evaluation.
## 📚 Citation
```bibtex
@misc{wang2024executable,
title={Executable Code Actions Elicit Better LLM Agents},
author={Xingyao Wang and Yangyi Chen and Lifan Yuan and Yizhe Zhang and Yunzhu Li and Hao Peng and Heng Ji},
year={2024},
eprint={2402.01030},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
```
<h1 align="center"> 可执行代码动作助力更优秀的大语言模型智能体 </h1>
<p align="center">
<a href="https://github.com/xingyaoww/code-act">💻 代码</a>
•
<a href="https://arxiv.org/abs/2402.01030">📃 论文</a>
•
<a href="https://huggingface.co/datasets/xingyaoww/code-act" >🤗 数据集(CodeActInstruct)</a>
•
<a href="https://huggingface.co/xingyaoww/CodeActAgent-Mistral-7b-v0.1" >🤗 模型(CodeActAgent-Mistral-7b-v0.1)</a>
•
<a href="https://chat.xwang.dev/">🤖 与CodeActAgent对话!</a>
</p>
我们提出使用可执行Python代码,将大语言模型智能体的动作整合至统一的动作空间(CodeAct)。借助Python解释器,CodeAct可执行代码动作,并通过多轮交互基于新观测结果(如代码执行结果)动态修正先前动作或生成新动作。

## 为何选择CodeAct?
我们针对API-Bank与全新构建的基准测试M³ToolEval,对17款大语言模型展开了全面分析,结果显示CodeAct的表现优于文本、JSON等主流动作表示方案,成功率最高可提升20%。更多详细分析请参阅我们的论文!

*以文本/JSON作为动作表示时,与CodeAct的性能对比*

*CodeAct与{文本、JSON}在M³ToolEval上的量化对比结果*
## 📁 CodeActInstruct
我们构建了指令微调数据集CodeActInstruct,该数据集包含7000条基于CodeAct的多轮交互样本。数据集已发布至🤗 Hugging Face数据集平台:https://huggingface.co/datasets/xingyaoww/code-act。数据集构建细节请参阅论文及[本节](#-data-generation-optional)内容。

*数据集统计信息。Token统计结果基于Llama-2分词器计算得出*
## 🪄 CodeActAgent
基于CodeActInstruct数据集与通用对话语料训练得到的CodeActAgent,在同尺寸开源模型中,域外智能体任务性能表现突出,同时并未牺牲通用能力(如知识问答、对话交互)。我们推出了两款CodeActAgent变体:
- **CodeActAgent-Mistral-7b-v0.1**(推荐使用,[模型链接](https://huggingface.co/xingyaoww/CodeActAgent-Mistral-7b-v0.1)):以Mistral-7b-v0.1作为基座模型,支持32k上下文窗口。
- **CodeActAgent-Llama-2-7b**([模型链接](https://huggingface.co/xingyaoww/CodeActAgent-Llama-2-7b)):以Llama-2-7b作为基座模型,支持4k上下文窗口。

*CodeActAgent的评估结果。ID与OD分别代表域内与域外评估。总体平均性能对MT-Bench分数做了归一化处理,以适配其他任务,并剔除域内任务以保证评估公平性*
如需了解数据集构建、模型训练与评估的更多细节,请查阅[我们的论文](TODO)与[代码仓库](https://github.com/xingyaoww/code-act)。
## 📚 引用
bibtex
@misc{wang2024executable,
title={Executable Code Actions Elicit Better LLM Agents},
author={Xingyao Wang and Yangyi Chen and Lifan Yuan and Yizhe Zhang and Yunzhu Li and Hao Peng and Heng Ji},
year={2024},
eprint={2402.01030},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
提供机构:
maas
创建时间:
2024-06-05



