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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
library_name: transformers
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
<p align="center">
|
| 19 |
+
<img width="500px" alt="xLAM" src="https://huggingface.co/datasets/jianguozhang/logos/resolve/main/xlam-no-background.png">
|
| 20 |
+
</p>
|
| 21 |
+
<p align="center">
|
| 22 |
+
<a href="https://www.salesforceairesearch.com/projects/xlam-large-action-models">[Homepage]</a> |
|
| 23 |
+
<a href="https://github.com/SalesforceAIResearch/xLAM">[Github]</a> |
|
| 24 |
+
<a href="https://blog.salesforceairesearch.com/large-action-model-ai-agent/">[Blog]</a>
|
| 25 |
+
</p>
|
| 26 |
+
<hr>
|
| 27 |
+
|
| 28 |
+
# Welcome to the xLAM-2 Model Family!
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
[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.
|
| 32 |
+
**This model release is for research purposes only.**
|
| 33 |
+
|
| 34 |
+
The new **xLAM-2** series, built on our most advanced data synthesis, processing, and training pipelines, marks a significant leap in **multi-turn reasoning** and **tool usage**. It achieves state-of-the-art performance on function-calling benchmarks like **BFCL** and **tau-bench**.
|
| 35 |
+
|
| 36 |
+
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.
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
## Table of Contents
|
| 40 |
+
- [Model Series](#model-series)
|
| 41 |
+
- [Usage](#usage)
|
| 42 |
+
- [Basic Usage with Huggingface Chat Template](#basic-usage-with-huggingface-chat-template)
|
| 43 |
+
- [License](#license)
|
| 44 |
+
- [Citation](#citation)
|
| 45 |
+
|
| 46 |
+
## Model Series
|
| 47 |
+
|
| 48 |
+
We provide a series of xLAMs in different sizes to cater to various applications, including those optimized for multi-turn conversation and tool usage:
|
| 49 |
+
|
| 50 |
+
| Model | # Total Params | Context Length | Release Date | Base Model | Category | Download Model | Download GGUF files |
|
| 51 |
+
|------------------------------|----------------|----------------|--------------|-----------------|---------------------------------------------|------------------------------------------------------------------------------|---------------------|
|
| 52 |
+
| 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 |
|
| 53 |
+
| 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) |
|
| 54 |
+
| 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 |
|
| 55 |
+
| 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) |
|
| 56 |
+
| 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) |
|
| 57 |
+
|
| 58 |
+
***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.
|
| 59 |
+
|
| 60 |
+
### Framework versions
|
| 61 |
+
|
| 62 |
+
- Transformers 4.46.1 (or later)
|
| 63 |
+
- PyTorch 2.5.1+cu124 (or later)
|
| 64 |
+
- Datasets 3.1.0 (or later)
|
| 65 |
+
- Tokenizers 0.20.3 (or later)
|
| 66 |
+
|
| 67 |
+
## Usage
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
### Basic Usage with Huggingface Chat Template
|
| 71 |
+
|
| 72 |
+
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.
|
| 73 |
+
|
| 74 |
+
### Using Hugging Face Transformers and Chat Template
|
| 75 |
+
|
| 76 |
+
This example demonstrates a basic multi-turn conversation and tool-usage with one of the Llama-based models:
|
| 77 |
+
|
| 78 |
+
```python
|
| 79 |
+
import torch
|
| 80 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 81 |
+
|
| 82 |
+
tokenizer = AutoTokenizer.from_pretrained("Salesforce/Llama-xLAM-2-3b-fc-r")
|
| 83 |
+
model = AutoModelForCausalLM.from_pretrained("Salesforce/Llama-xLAM-2-3b-fc-r", torch_dtype=torch.bfloat16, device_map="auto")
|
| 84 |
+
|
| 85 |
+
# Example conversation with a tool call
|
| 86 |
+
messages = [
|
| 87 |
+
{"role": "user", "content": "Hi, how are you?"},
|
| 88 |
+
{"role": "assistant", "content": "Thanks. I am doing well. How can I help you?"},
|
| 89 |
+
{"role": "user", "content": "What's the weather like in London?"},
|
| 90 |
+
]
|
| 91 |
+
|
| 92 |
+
tools = [
|
| 93 |
+
{
|
| 94 |
+
"name": "get_weather",
|
| 95 |
+
"description": "Get the current weather for a location",
|
| 96 |
+
"parameters": {
|
| 97 |
+
"type": "object",
|
| 98 |
+
"properties": {
|
| 99 |
+
"location": {"type": "string", "description": "The city and state, e.g. San Francisco, CA"},
|
| 100 |
+
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"], "description": "The unit of temperature to return"}
|
| 101 |
+
},
|
| 102 |
+
"required": ["location"]
|
| 103 |
+
}
|
| 104 |
+
}
|
| 105 |
+
]
|
| 106 |
+
|
| 107 |
+
print("====== prompt after applying chat template ======")
|
| 108 |
+
print(tokenizer.apply_chat_template(messages, tools=tools, add_generation_prompt=True, tokenize=False))
|
| 109 |
+
|
| 110 |
+
inputs = tokenizer.apply_chat_template(messages, tools=tools, add_generation_prompt=True, return_dict=True, return_tensors="pt")
|
| 111 |
+
input_ids_len = inputs["input_ids"].shape[-1] # Get the length of the input tokens
|
| 112 |
+
inputs = {k: v.to(model.device) for k, v in inputs.items()}
|
| 113 |
+
print("====== model response ======")
|
| 114 |
+
outputs = model.generate(**inputs, max_new_tokens=256)
|
| 115 |
+
generated_tokens = outputs[:, input_ids_len:] # Slice the output to get only the newly generated tokens
|
| 116 |
+
print(tokenizer.decode(generated_tokens[0], skip_special_tokens=True))
|
| 117 |
+
```
|
| 118 |
+
|
| 119 |
+
<!-- ### Using vLLM for Inference
|
| 120 |
+
|
| 121 |
+
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:
|
| 122 |
+
|
| 123 |
+
```bash
|
| 124 |
+
vllm serve Salesforce/xLAM-2-3b-fc-r
|
| 125 |
+
```
|
| 126 |
+
|
| 127 |
+
And then interact with the model using your preferred method for querying a vLLM endpoint. -->
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
<!-- ## Benchmark Results
|
| 132 |
+
Note: **Bold** and <u>Underline</u> results denote the best result and the second best result for Success Rate, respectively.
|
| 133 |
+
|
| 134 |
+
### Berkeley Function-Calling Leaderboard (BFCL)
|
| 135 |
+

|
| 136 |
+
*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.* -->
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
## Ethical Considerations
|
| 140 |
+
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.
|
| 141 |
+
|
| 142 |
+
### Model Licenses
|
| 143 |
+
|
| 144 |
+
For all Llama relevant models, please also follow cooresponding Llama license and terms. Meta Llama 3 is licensed under the Meta Llama 3 Community License, Copyright © Meta Platforms, Inc. All Rights Reserved.
|
| 145 |
+
|
| 146 |
+
<!-- ## Citation
|
| 147 |
+
|
| 148 |
+
If you find this repo helpful, please consider to cite our papers:
|
| 149 |
+
|
| 150 |
+
```bibtex
|
| 151 |
+
@article{zhang2024xlam,
|
| 152 |
+
title={xLAM: A Family of Large Action Models to Empower AI Agent Systems},
|
| 153 |
+
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},
|
| 154 |
+
journal={arXiv preprint arXiv:2409.03215},
|
| 155 |
+
year={2024}
|
| 156 |
+
}
|
| 157 |
+
```
|
| 158 |
+
|
| 159 |
+
```bibtex
|
| 160 |
+
@article{liu2024apigen,
|
| 161 |
+
title={Apigen: Automated pipeline for generating verifiable and diverse function-calling datasets},
|
| 162 |
+
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},
|
| 163 |
+
journal={arXiv preprint arXiv:2406.18518},
|
| 164 |
+
year={2024}
|
| 165 |
+
}
|
| 166 |
+
```
|
| 167 |
+
|
| 168 |
+
```bibtex
|
| 169 |
+
@article{zhang2024agentohana,
|
| 170 |
+
title={AgentOhana: Design Unified Data and Training Pipeline for Effective Agent Learning},
|
| 171 |
+
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},
|
| 172 |
+
journal={arXiv preprint arXiv:2402.15506},
|
| 173 |
+
year={2024}
|
| 174 |
+
}
|
| 175 |
+
``` -->
|
| 176 |
+
|