Improve model card: Add metadata and usage example
#1
by
nielsr
HF Staff
- opened
README.md
CHANGED
|
@@ -1,7 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# Model Introduction
|
| 2 |
We introduce Agent Foundation Models (AFMs), a new family built on Qwen2.5 that natively perform end-to-end, multi-turn, multi-tool problem solving—without external frameworks or manual prompting. Built on the Chain-of-Agents (CoA) paradigm, each AFM dynamically activates specialized tool and role-playing agents inside a single forward pass, emulating the cooperative reasoning of a full multi-agent system. To train these models, we distilled high-performing multi-agent trajectories into agentic supervised-fine-tuning data and further optimized performance with agentic reinforcement learning on verifiable tasks. AFMs set new state-of-the-art results on benchmarks for both web and code agents, and we release all model weights, training code, and datasets to accelerate future research on agentic AI.
|
| 3 |
For more details, please refer to our [Projects](https://chain-of-agents-afm.github.io/), [paper](https://arxiv.org/abs/2508.13167) and [GitHub](https://github.com/OPPO-PersonalAI/Agent_Foundation_Models).
|
| 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
# Model Downloads
|
| 6 |
|
| 7 |
| Model | Download | Backbone Model | License|
|
|
@@ -39,4 +102,4 @@ If you find `AFM` useful in your research or applications, we would appreciate i
|
|
| 39 |
primaryClass={cs.AI},
|
| 40 |
url={https://arxiv.org/abs/2508.13167},
|
| 41 |
}
|
| 42 |
-
```
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
pipeline_tag: text-generation
|
| 4 |
+
library_name: transformers
|
| 5 |
+
tags:
|
| 6 |
+
- agents
|
| 7 |
+
- code-generation
|
| 8 |
+
- tool-use
|
| 9 |
+
- reinforcement-learning
|
| 10 |
+
- qwen2
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
# Model Introduction
|
| 14 |
We introduce Agent Foundation Models (AFMs), a new family built on Qwen2.5 that natively perform end-to-end, multi-turn, multi-tool problem solving—without external frameworks or manual prompting. Built on the Chain-of-Agents (CoA) paradigm, each AFM dynamically activates specialized tool and role-playing agents inside a single forward pass, emulating the cooperative reasoning of a full multi-agent system. To train these models, we distilled high-performing multi-agent trajectories into agentic supervised-fine-tuning data and further optimized performance with agentic reinforcement learning on verifiable tasks. AFMs set new state-of-the-art results on benchmarks for both web and code agents, and we release all model weights, training code, and datasets to accelerate future research on agentic AI.
|
| 15 |
For more details, please refer to our [Projects](https://chain-of-agents-afm.github.io/), [paper](https://arxiv.org/abs/2508.13167) and [GitHub](https://github.com/OPPO-PersonalAI/Agent_Foundation_Models).
|
| 16 |
|
| 17 |
+
## Usage
|
| 18 |
+
|
| 19 |
+
You can use this model with the Hugging Face `transformers` library. Below is a simple example for inference. For more advanced usage, including training and evaluation, please refer to the [official GitHub repository](https://github.com/OPPO-PersonalAI/Agent_Foundation_Models).
|
| 20 |
+
|
| 21 |
+
```python
|
| 22 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 23 |
+
import torch
|
| 24 |
+
|
| 25 |
+
model_id = "PersonalAILab/AFM-CodeAgent-32B-rl" # This is one of the models, adjust as needed
|
| 26 |
+
|
| 27 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
|
| 28 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 29 |
+
model_id,
|
| 30 |
+
torch_dtype=torch.bfloat16, # or torch.float16 depending on your hardware
|
| 31 |
+
device_map="auto",
|
| 32 |
+
trust_remote_code=True
|
| 33 |
+
)
|
| 34 |
+
|
| 35 |
+
# Example for code agent query
|
| 36 |
+
question = "Write a Python function to calculate the N-th Fibonacci number recursively."
|
| 37 |
+
messages = [
|
| 38 |
+
{"role": "user", "content": question}
|
| 39 |
+
]
|
| 40 |
+
|
| 41 |
+
text = tokenizer.apply_chat_template(
|
| 42 |
+
messages,
|
| 43 |
+
tokenize=False,
|
| 44 |
+
add_generation_prompt=True
|
| 45 |
+
)
|
| 46 |
+
|
| 47 |
+
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
|
| 48 |
+
|
| 49 |
+
generated_ids = model.generate(
|
| 50 |
+
**model_inputs,
|
| 51 |
+
max_new_tokens=512,
|
| 52 |
+
do_sample=True,
|
| 53 |
+
temperature=0.7,
|
| 54 |
+
top_k=20,
|
| 55 |
+
top_p=0.8,
|
| 56 |
+
repetition_penalty=1.1
|
| 57 |
+
)
|
| 58 |
+
|
| 59 |
+
generated_ids = [
|
| 60 |
+
output_ids[len(input_ids):]
|
| 61 |
+
for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|
| 62 |
+
]
|
| 63 |
+
|
| 64 |
+
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
| 65 |
+
print(response)
|
| 66 |
+
```
|
| 67 |
+
|
| 68 |
# Model Downloads
|
| 69 |
|
| 70 |
| Model | Download | Backbone Model | License|
|
|
|
|
| 102 |
primaryClass={cs.AI},
|
| 103 |
url={https://arxiv.org/abs/2508.13167},
|
| 104 |
}
|
| 105 |
+
```
|