Add comprehensive model card for Chain-of-Agents (AFM)

#1
by nielsr HF Staff - opened
Files changed (1) hide show
  1. README.md +111 -0
README.md ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ library_name: transformers
4
+ pipeline_tag: text-generation
5
+ tags:
6
+ - agents
7
+ - foundation-model
8
+ - multi-agent
9
+ - reinforcement-learning
10
+ - code-generation
11
+ - web-browsing
12
+ - large-language-model
13
+ ---
14
+
15
+ # Chain-of-Agents: End-to-End Agent Foundation Models via Multi-Agent Distillation and Agentic RL
16
+
17
+ This repository contains an **Agent Foundation Model (AFM)** based on the paper [Chain-of-Agents: End-to-End Agent Foundation Models via Multi-Agent Distillation and Agentic RL](https://huggingface.co/papers/2508.13167).
18
+
19
+ <div align="center">
20
+ <a href='https://chain-of-agents-afm.github.io/'><img src='https://img.shields.io/badge/Project-Homepage-blue?logo=github&logoColor=white'></a>
21
+ <a href='https://huggingface.co/papers/2508.13167'><img src='https://img.shields.io/badge/Paper-HuggingFace-d63031?logo=huggingface&logoColor=white'></a>
22
+ <a href='https://github.com/OPPO-PersonalAI/Agent_Foundation_Models'><img src='https://img.shields.io/badge/Code-GitHub-red?logo=github&logoColor=white'></a>
23
+ <a href='https://huggingface.co/collections/PersonalAILab/afm-689200e11d0b21a67c015ba8'><img src='https://img.shields.io/badge/%F0%9F%A4%97%20Models-Huggingface-yellow'></a>
24
+ <a href='https://huggingface.co/collections/PersonalAILab/afm-datasets-6892140eaad360ea5ccdcde1'><img src='https://img.shields.io/badge/%F0%9F%A4%97%20Datasets-Huggingface-yellow'></a>
25
+ </div>
26
+
27
+ ## Overview
28
+
29
+ Recent advances in large language models (LLMs) and multi-agent systems have demonstrated remarkable capabilities in complex problem-solving tasks. However, most existing multi-agent systems rely on manual prompt/workflow engineering, making them computationally inefficient and less adaptable.
30
+
31
+ This work introduces **Chain-of-Agents (CoA)**, a novel paradigm of LLM reasoning that enables native end-to-end complex problem-solving by simulating multi-agent collaboration within a single model. The model dynamically activates different tool agents and role-playing agents to achieve multi-turn problem-solving. To elicit these abilities, a multi-agent distillation framework is used to distill state-of-the-art multi-agent systems into chain-of-agents trajectories for agentic supervised fine-tuning. This is further improved by agentic reinforcement learning on verifiable tasks. The resulting models are called **Agent Foundation Models (AFMs)**.
32
+
33
+ Empirical studies demonstrate that AFM establishes new state-of-the-art performance across diverse benchmarks in both web agent and code agent settings.
34
+
35
+ <div align="center">
36
+ <img src="https://github.com/OPPO-PersonalAI/Agent_Foundation_Models/raw/main/assets/afm.png" width="85%" height="auto" alt="Chain-of-Agents Overview"/>
37
+ </div>
38
+
39
+ ## Key Features
40
+
41
+ * **Core Paradigm**: Chain-of-Agents (CoA) for end-to-end problem-solving within a single model, simulating multi-agent collaboration via dynamic activation of tool and role-playing agents.
42
+ * **Training Framework**: Utilizes a Multi-Agent Distillation pipeline and Agentic Reinforcement Learning, supporting mask fine-tuning for selective learning.
43
+ * **Agent Capabilities**: Excels in Web interaction (Web Agent), Multi-hop Question Answering (MHQA Agent), and Code Execution (Code Agent).
44
+ * **Tool Integration**: Features web search and crawling servers, a secure code sandbox (via nsjail), and configurable multi-tool collaboration.
45
+
46
+ ## Quick Start (with `transformers`)
47
+
48
+ This section provides general instructions on how to load and use an Agent Foundation Model for inference using the Hugging Face `transformers` library. Please note that specific models from the AFM collection (e.g., different sizes or SFT/RL checkpoints) may have specific requirements or optimized usage patterns.
49
+
50
+ First, ensure you have the necessary `transformers` library installed:
51
+ ```bash
52
+ pip install transformers
53
+ ```
54
+
55
+ For detailed installation instructions, environment setup, and advanced usage (including training and evaluation scripts, and specific tool integration), please refer to the [official GitHub repository](https://github.com/OPPO-PersonalAI/Agent_Foundation_Models).
56
+
57
+ Here's an example of how to load and use a generic AFM for text generation:
58
+
59
+ ```python
60
+ from transformers import AutoModelForCausalLM, AutoTokenizer
61
+ import torch
62
+
63
+ # Replace 'your-model-name' with the actual model ID you wish to use from the AFM collection,
64
+ # e.g., "PersonalAILab/afm-qwen2.5-7b-sft" or "PersonalAILab/afm-qwen2.5-32b-sft"
65
+ model_name = "your-model-name"
66
+
67
+ # Load tokenizer and model
68
+ tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
69
+ model = AutoModelForCausalLM.from_pretrained(
70
+ model_name,
71
+ torch_dtype=torch.bfloat16,
72
+ device_map="auto",
73
+ trust_remote_code=True
74
+ )
75
+
76
+ # Example: Ask the agent to perform a task or answer a question
77
+ prompt = "Act as a web agent. Find the current temperature in Paris, France."
78
+
79
+ # Prepare inputs
80
+ inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
81
+
82
+ # Generate response
83
+ # Adjust generation parameters (max_new_tokens, temperature, etc.) as needed for your task.
84
+ # The model's behavior is agentic, so it might output tool calls or multi-turn reasoning.
85
+ output = model.generate(
86
+ **inputs,
87
+ max_new_tokens=512,
88
+ temperature=0.7,
89
+ do_sample=True,
90
+ eos_token_id=tokenizer.eos_token_id
91
+ )
92
+ response = tokenizer.decode(output[0], skip_special_tokens=True)
93
+
94
+ print(response)
95
+ ```
96
+
97
+ ## Citation
98
+
99
+ If you find `AFM` useful in your research or applications, we would appreciate it if you could cite our work:
100
+
101
+ ```bibtex
102
+ @misc{li2025chainofagentsendtoendagentfoundation,
103
+ title={Chain-of-Agents: End-to-End Agent Foundation Models via Multi-Agent Distillation and Agentic RL},
104
+ author={Weizhen Li and Jianbo Lin and Zhuosong Jiang and Jingyi Cao and Xinpeng Liu and Jiayu Zhang and Zhenqiang Huang and Qianben Chen and Weichen Sun and Qiexiang Wang and Hongxuan Lu and Tianrui Qin and Chenghao Zhu and Yi Yao and Shuying Fan and Xiaowan Li and Tiannan Wang and Pai Liu and King Zhu and He Zhu and Dingfeng Shi and Piaohong Wang and Yeyi Guan and Xiangru Tang and Minghao Liu and Yuchen Eleanor Jiang and Jian Yang and Jiaheng Liu and Ge Zhang and Wangchunshu Zhou},
105
+ year={2025},
106
+ eprint={2508.13167},
107
+ archivePrefix={arXiv},
108
+ primaryClass={cs.AI},
109
+ url={https://arxiv.org/abs/2508.13167},
110
+ }
111
+ ```