Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,198 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: cc-by-nc-4.0
|
3 |
+
datasets:
|
4 |
+
- Salesforce/xlam-function-calling-60k
|
5 |
+
language:
|
6 |
+
- en
|
7 |
+
pipeline_tag: text-generation
|
8 |
+
tags:
|
9 |
+
- function-calling
|
10 |
+
- LLM Agent
|
11 |
+
- tool-use
|
12 |
+
- llama
|
13 |
+
- qwen
|
14 |
+
- pytorch
|
15 |
+
- LLaMA-factory
|
16 |
+
library_name: transformers
|
17 |
+
---
|
18 |
+
|
19 |
+
<p align="center">
|
20 |
+
<img width="500px" alt="xLAM" src="https://huggingface.co/datasets/jianguozhang/logos/resolve/main/xlam-no-background.png">
|
21 |
+
</p>
|
22 |
+
|
23 |
+
|
24 |
+
<p align="center">
|
25 |
+
<a href="https://apigen-mt.github.io/">[Homepage]</a> |
|
26 |
+
<a href="https://github.com/SalesforceAIResearch/xLAM">[Github]</a> |
|
27 |
+
<a href="https://blog.salesforceairesearch.com/large-action-model-ai-agent/">[Blog]</a>
|
28 |
+
</p>
|
29 |
+
<hr>
|
30 |
+
|
31 |
+
# Welcome to the xLAM-2 Model Family!
|
32 |
+
|
33 |
+
[Large Action Models (LAMs)](https://blog.salesforceairesearch.com/large-action-models/) are advanced language models designed to enhance decision-making by translating user intentions into executable actions. As the **brains of AI agents**, LAMs autonomously plan and execute tasks to achieve specific goals, making them invaluable for automating workflows across diverse domains.
|
34 |
+
**This model release is for research purposes only.**
|
35 |
+
|
36 |
+
The new **xLAM-2** series, built on our most advanced data synthesis, processing, and training pipelines, marks a significant leap in **multi-turn conversation** and **tool usage**. Trained using our novel APIGen-MT framework, which generates high-quality training data through simulated agent-human interactions. Our models achieve state-of-the-art performance on **BFCL** and **Ï„-bench** benchmarks, outperforming frontier models like GPT-4o and Claude 3.5. Notably, even our smaller models demonstrate superior capabilities in multi-turn scenarios while maintaining exceptional consistency across trials.
|
37 |
+
|
38 |
+
We've also refined the **chat template** and **vLLM integration**, making it easier to build advanced AI agents. Compared to previous xLAM models, xLAM-2 offers superior performance and seamless deployment across applications.
|
39 |
+
|
40 |
+
<p align="center">
|
41 |
+
<img width="100%" alt="Model Performance Overview" src="img/model_board.png">
|
42 |
+
<br>
|
43 |
+
<small><i>Comparative performance of larger xLAM-2-fc-r models (8B-70B, trained with APIGen-MT data) against state-of-the-art baselines on function-calling (BFCL v3, as of date 04/02/2025) and agentic (Ï„-bench) capabilities.</i></small>
|
44 |
+
</p>
|
45 |
+
|
46 |
+
|
47 |
+
## Table of Contents
|
48 |
+
- [Model Series](#model-series)
|
49 |
+
- [Benchmark Results](#benchmark-results)
|
50 |
+
- [Usage](#usage)
|
51 |
+
- [Basic Usage with Huggingface Chat Template](#basic-usage-with-huggingface-chat-template)
|
52 |
+
- [License](#license)
|
53 |
+
- [Citation](#citation)
|
54 |
+
|
55 |
+
## Model Series
|
56 |
+
|
57 |
+
We provide a series of xLAMs in different sizes to cater to various applications, including those optimized for multi-turn conversation and tool usage:
|
58 |
+
|
59 |
+
| Model | # Total Params | Context Length | Release Date | Base Model | Category | Download Model | Download GGUF files |
|
60 |
+
|------------------------------|----------------|----------------|--------------|-----------------|---------------------------------------------|------------------------------------------------------------------------------|---------------------|
|
61 |
+
| Salesforce/Llama-xLAM-2-70b-fc-r | 70B | 128k | Mar. 26, 2025 | Llama 3.1/3.2 | Multi-turn Conversation, Tool-usage | [🤗 Link](https://huggingface.co/Salesforce/Llama-xLAM-2-70b-fc-r) | NA |
|
62 |
+
| Salesforce/Llama-xLAM-2-8b-fc-r | 8B | 128k | Mar. 26, 2025 |Llama 3.1/3.2 | Multi-turn Conversation, Tool-usage | [🤗 Link](https://huggingface.co/Salesforce/Llama-xLAM-2-8b-fc-r) | [🤗 Link](https://huggingface.co/Salesforce/Llama-xLAM-2-8b-fc-r-gguf) |
|
63 |
+
| Salesforce/xLAM-2-32b-fc-r | 32B | 32k (max 128k)* | Mar. 26, 2025 | Qwen 2.5 | Multi-turn Conversation, Tool-usage | [🤗 Link](https://huggingface.co/Salesforce/xLAM-2-32b-fc-r) | NA |
|
64 |
+
| Salesforce/xLAM-2-3b-fc-r | 3B | 32k (max 128k)* | Mar. 26, 2025 | Qwen 2.5 | Multi-turn Conversation, Tool-usage | [🤗 Link](https://huggingface.co/Salesforce/xLAM-2-3b-fc-r) | [🤗 Link](https://huggingface.co/Salesforce/xLAM-2-3b-fc-r-gguf) |
|
65 |
+
| Salesforce/xLAM-2-1b-fc-r | 1B | 32k (max 128k)* | Mar. 26, 2025 | Qwen 2.5 | Multi-turn Conversation, Tool-usage, Lightweight | [🤗 Link](https://huggingface.co/Salesforce/xLAM-2-1b-fc-r) | [🤗 Link](https://huggingface.co/Salesforce/xLAM-2-1b-fc-r-gguf) |
|
66 |
+
|
67 |
+
***Note:** The default context length for Qwen-2.5-based models is 32k, but you can use techniques like YaRN (Yet Another Recursive Network) to achieve maximum 128k context length. Please refer to [here](https://huggingface.co/Qwen/Qwen2.5-32B-Instruct#processing-long-texts) for more details.
|
68 |
+
|
69 |
+
## Usage
|
70 |
+
|
71 |
+
### Framework versions
|
72 |
+
|
73 |
+
- Transformers 4.46.1 (or later)
|
74 |
+
- PyTorch 2.5.1+cu124 (or later)
|
75 |
+
- Datasets 3.1.0 (or later)
|
76 |
+
- Tokenizers 0.20.3 (or later)
|
77 |
+
|
78 |
+
### Basic Usage with Huggingface Chat Template
|
79 |
+
|
80 |
+
The new xLAM models are designed to work seamlessly with the Hugging Face Transformers library and utilize natural chat templates for an easy and intuitive conversational experience. Below are examples of how to use these models.
|
81 |
+
|
82 |
+
```python
|
83 |
+
import torch
|
84 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
85 |
+
|
86 |
+
tokenizer = AutoTokenizer.from_pretrained("Salesforce/Llama-xLAM-2-3b-fc-r")
|
87 |
+
model = AutoModelForCausalLM.from_pretrained("Salesforce/Llama-xLAM-2-3b-fc-r", torch_dtype=torch.bfloat16, device_map="auto")
|
88 |
+
|
89 |
+
# Example conversation with a tool call
|
90 |
+
messages = [
|
91 |
+
{"role": "user", "content": "Hi, how are you?"},
|
92 |
+
{"role": "assistant", "content": "Thanks. I am doing well. How can I help you?"},
|
93 |
+
{"role": "user", "content": "What's the weather like in London?"},
|
94 |
+
]
|
95 |
+
|
96 |
+
tools = [
|
97 |
+
{
|
98 |
+
"name": "get_weather",
|
99 |
+
"description": "Get the current weather for a location",
|
100 |
+
"parameters": {
|
101 |
+
"type": "object",
|
102 |
+
"properties": {
|
103 |
+
"location": {"type": "string", "description": "The city and state, e.g. San Francisco, CA"},
|
104 |
+
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"], "description": "The unit of temperature to return"}
|
105 |
+
},
|
106 |
+
"required": ["location"]
|
107 |
+
}
|
108 |
+
}
|
109 |
+
]
|
110 |
+
|
111 |
+
print("====== prompt after applying chat template ======")
|
112 |
+
print(tokenizer.apply_chat_template(messages, tools=tools, add_generation_prompt=True, tokenize=False))
|
113 |
+
|
114 |
+
inputs = tokenizer.apply_chat_template(messages, tools=tools, add_generation_prompt=True, return_dict=True, return_tensors="pt")
|
115 |
+
input_ids_len = inputs["input_ids"].shape[-1] # Get the length of the input tokens
|
116 |
+
inputs = {k: v.to(model.device) for k, v in inputs.items()}
|
117 |
+
print("====== model response ======")
|
118 |
+
outputs = model.generate(**inputs, max_new_tokens=256)
|
119 |
+
generated_tokens = outputs[:, input_ids_len:] # Slice the output to get only the newly generated tokens
|
120 |
+
print(tokenizer.decode(generated_tokens[0], skip_special_tokens=True))
|
121 |
+
```
|
122 |
+
|
123 |
+
<!-- ### Using vLLM for Inference
|
124 |
+
|
125 |
+
The xLAM models can also be efficiently served using vLLM for high-throughput inference. Please refer to the vLLM documentation for detailed instructions on how to deploy and use these models. You can typically start the vLLM service with the model name:
|
126 |
+
|
127 |
+
```bash
|
128 |
+
vllm serve Salesforce/xLAM-2-3b-fc-r
|
129 |
+
```
|
130 |
+
|
131 |
+
And then interact with the model using your preferred method for querying a vLLM endpoint. -->
|
132 |
+
|
133 |
+
|
134 |
+
|
135 |
+
<!-- ## Benchmark Results
|
136 |
+
Note: **Bold** and <u>Underline</u> results denote the best result and the second best result for Success Rate, respectively.
|
137 |
+
|
138 |
+
### Berkeley Function-Calling Leaderboard (BFCL)
|
139 |
+

|
140 |
+
*Table 1: Performance comparison on BFCL-v2 leaderboard (cutoff date 09/03/2024). The rank is based on the overall accuracy, which is a weighted average of different evaluation categories. "FC" stands for function-calling mode in contrast to using a customized "prompt" to extract the function calls.* -->
|
141 |
+
|
142 |
+
|
143 |
+
## Benchmark Results
|
144 |
+
|
145 |
+
### Berkeley Function-Calling Leaderboard (BFCL v3)
|
146 |
+
<p align="center">
|
147 |
+
<img width="80%" alt="BFCL Results" src="img/bfcl-result.png">
|
148 |
+
<br>
|
149 |
+
<small><i>Performance comparison of different models on BFCL leaderboard. The rank is based on the overall accuracy, which is a weighted average of different evaluation categories. "FC" stands for function-calling mode in contrast to using a customized "prompt" to extract the function calls.</i></small>
|
150 |
+
</p>
|
151 |
+
|
152 |
+
### Ï„-bench Benchmark
|
153 |
+
<p align="center">
|
154 |
+
<img width="100%" alt="Pass^k curves" src="img/pass_k_curves_retail_airline.png">
|
155 |
+
<br>
|
156 |
+
<small><i>Pass^k curves measuring the probability that all 5 independent trials succeed for a given task, averaged across all tasks for Ï„-retail (left) and Ï„-airline (right) domains. Higher values indicate better consistency of the models.</i></small>
|
157 |
+
</p>
|
158 |
+
|
159 |
+
|
160 |
+
## Ethical Considerations
|
161 |
+
|
162 |
+
This release is for research purposes only in support of an academic paper. Our models, datasets, and code are not specifically designed or evaluated for all downstream purposes. We strongly recommend users evaluate and address potential concerns related to accuracy, safety, and fairness before deploying this model. We encourage users to consider the common limitations of AI, comply with applicable laws, and leverage best practices when selecting use cases, particularly for high-risk scenarios where errors or misuse could significantly impact people's lives, rights, or safety. For further guidance on use cases, refer to our AUP and AI AUP.
|
163 |
+
|
164 |
+
### Model Licenses
|
165 |
+
|
166 |
+
For all Llama relevant models, please also follow corresponding Llama license and terms. Meta Llama 3 is licensed under the Meta Llama 3 Community License, Copyright © Meta Platforms, Inc. All Rights Reserved.
|
167 |
+
|
168 |
+
<!-- ## Citation
|
169 |
+
|
170 |
+
If you find this repo helpful, please consider to cite our papers:
|
171 |
+
|
172 |
+
```bibtex
|
173 |
+
@article{zhang2024xlam,
|
174 |
+
title={xLAM: A Family of Large Action Models to Empower AI Agent Systems},
|
175 |
+
author={Zhang, Jianguo and Lan, Tian and Zhu, Ming and Liu, Zuxin and Hoang, Thai and Kokane, Shirley and Yao, Weiran and Tan, Juntao and Prabhakar, Akshara and Chen, Haolin and others},
|
176 |
+
journal={arXiv preprint arXiv:2409.03215},
|
177 |
+
year={2024}
|
178 |
+
}
|
179 |
+
```
|
180 |
+
|
181 |
+
```bibtex
|
182 |
+
@article{liu2024apigen,
|
183 |
+
title={Apigen: Automated pipeline for generating verifiable and diverse function-calling datasets},
|
184 |
+
author={Liu, Zuxin and Hoang, Thai and Zhang, Jianguo and Zhu, Ming and Lan, Tian and Kokane, Shirley and Tan, Juntao and Yao, Weiran and Liu, Zhiwei and Feng, Yihao and others},
|
185 |
+
journal={arXiv preprint arXiv:2406.18518},
|
186 |
+
year={2024}
|
187 |
+
}
|
188 |
+
```
|
189 |
+
|
190 |
+
```bibtex
|
191 |
+
@article{zhang2024agentohana,
|
192 |
+
title={AgentOhana: Design Unified Data and Training Pipeline for Effective Agent Learning},
|
193 |
+
author={Zhang, Jianguo and Lan, Tian and Murthy, Rithesh and Liu, Zhiwei and Yao, Weiran and Tan, Juntao and Hoang, Thai and Yang, Liangwei and Feng, Yihao and Liu, Zuxin and others},
|
194 |
+
journal={arXiv preprint arXiv:2402.15506},
|
195 |
+
year={2024}
|
196 |
+
}
|
197 |
+
``` -->
|
198 |
+
|