RichardErkhov commited on
Commit
a6961a5
·
verified ·
1 Parent(s): ef89c09

uploaded readme

Browse files
Files changed (1) hide show
  1. README.md +518 -0
README.md ADDED
@@ -0,0 +1,518 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Quantization made by Richard Erkhov.
2
+
3
+ [Github](https://github.com/RichardErkhov)
4
+
5
+ [Discord](https://discord.gg/pvy7H8DZMG)
6
+
7
+ [Request more models](https://github.com/RichardErkhov/quant_request)
8
+
9
+
10
+ xLAM-7b-r - GGUF
11
+ - Model creator: https://huggingface.co/Salesforce/
12
+ - Original model: https://huggingface.co/Salesforce/xLAM-7b-r/
13
+
14
+
15
+ | Name | Quant method | Size |
16
+ | ---- | ---- | ---- |
17
+ | [xLAM-7b-r.Q2_K.gguf](https://huggingface.co/RichardErkhov/Salesforce_-_xLAM-7b-r-gguf/blob/main/xLAM-7b-r.Q2_K.gguf) | Q2_K | 2.53GB |
18
+ | [xLAM-7b-r.IQ3_XS.gguf](https://huggingface.co/RichardErkhov/Salesforce_-_xLAM-7b-r-gguf/blob/main/xLAM-7b-r.IQ3_XS.gguf) | IQ3_XS | 2.81GB |
19
+ | [xLAM-7b-r.IQ3_S.gguf](https://huggingface.co/RichardErkhov/Salesforce_-_xLAM-7b-r-gguf/blob/main/xLAM-7b-r.IQ3_S.gguf) | IQ3_S | 2.96GB |
20
+ | [xLAM-7b-r.Q3_K_S.gguf](https://huggingface.co/RichardErkhov/Salesforce_-_xLAM-7b-r-gguf/blob/main/xLAM-7b-r.Q3_K_S.gguf) | Q3_K_S | 2.95GB |
21
+ | [xLAM-7b-r.IQ3_M.gguf](https://huggingface.co/RichardErkhov/Salesforce_-_xLAM-7b-r-gguf/blob/main/xLAM-7b-r.IQ3_M.gguf) | IQ3_M | 3.06GB |
22
+ | [xLAM-7b-r.Q3_K.gguf](https://huggingface.co/RichardErkhov/Salesforce_-_xLAM-7b-r-gguf/blob/main/xLAM-7b-r.Q3_K.gguf) | Q3_K | 3.28GB |
23
+ | [xLAM-7b-r.Q3_K_M.gguf](https://huggingface.co/RichardErkhov/Salesforce_-_xLAM-7b-r-gguf/blob/main/xLAM-7b-r.Q3_K_M.gguf) | Q3_K_M | 3.28GB |
24
+ | [xLAM-7b-r.Q3_K_L.gguf](https://huggingface.co/RichardErkhov/Salesforce_-_xLAM-7b-r-gguf/blob/main/xLAM-7b-r.Q3_K_L.gguf) | Q3_K_L | 3.56GB |
25
+ | [xLAM-7b-r.IQ4_XS.gguf](https://huggingface.co/RichardErkhov/Salesforce_-_xLAM-7b-r-gguf/blob/main/xLAM-7b-r.IQ4_XS.gguf) | IQ4_XS | 3.67GB |
26
+ | [xLAM-7b-r.Q4_0.gguf](https://huggingface.co/RichardErkhov/Salesforce_-_xLAM-7b-r-gguf/blob/main/xLAM-7b-r.Q4_0.gguf) | Q4_0 | 3.83GB |
27
+ | [xLAM-7b-r.IQ4_NL.gguf](https://huggingface.co/RichardErkhov/Salesforce_-_xLAM-7b-r-gguf/blob/main/xLAM-7b-r.IQ4_NL.gguf) | IQ4_NL | 3.87GB |
28
+ | [xLAM-7b-r.Q4_K_S.gguf](https://huggingface.co/RichardErkhov/Salesforce_-_xLAM-7b-r-gguf/blob/main/xLAM-7b-r.Q4_K_S.gguf) | Q4_K_S | 3.86GB |
29
+ | [xLAM-7b-r.Q4_K.gguf](https://huggingface.co/RichardErkhov/Salesforce_-_xLAM-7b-r-gguf/blob/main/xLAM-7b-r.Q4_K.gguf) | Q4_K | 4.07GB |
30
+ | [xLAM-7b-r.Q4_K_M.gguf](https://huggingface.co/RichardErkhov/Salesforce_-_xLAM-7b-r-gguf/blob/main/xLAM-7b-r.Q4_K_M.gguf) | Q4_K_M | 4.07GB |
31
+ | [xLAM-7b-r.Q4_1.gguf](https://huggingface.co/RichardErkhov/Salesforce_-_xLAM-7b-r-gguf/blob/main/xLAM-7b-r.Q4_1.gguf) | Q4_1 | 4.24GB |
32
+ | [xLAM-7b-r.Q5_0.gguf](https://huggingface.co/RichardErkhov/Salesforce_-_xLAM-7b-r-gguf/blob/main/xLAM-7b-r.Q5_0.gguf) | Q5_0 | 4.65GB |
33
+ | [xLAM-7b-r.Q5_K_S.gguf](https://huggingface.co/RichardErkhov/Salesforce_-_xLAM-7b-r-gguf/blob/main/xLAM-7b-r.Q5_K_S.gguf) | Q5_K_S | 4.65GB |
34
+ | [xLAM-7b-r.Q5_K.gguf](https://huggingface.co/RichardErkhov/Salesforce_-_xLAM-7b-r-gguf/blob/main/xLAM-7b-r.Q5_K.gguf) | Q5_K | 4.78GB |
35
+ | [xLAM-7b-r.Q5_K_M.gguf](https://huggingface.co/RichardErkhov/Salesforce_-_xLAM-7b-r-gguf/blob/main/xLAM-7b-r.Q5_K_M.gguf) | Q5_K_M | 4.78GB |
36
+ | [xLAM-7b-r.Q5_1.gguf](https://huggingface.co/RichardErkhov/Salesforce_-_xLAM-7b-r-gguf/blob/main/xLAM-7b-r.Q5_1.gguf) | Q5_1 | 5.07GB |
37
+ | [xLAM-7b-r.Q6_K.gguf](https://huggingface.co/RichardErkhov/Salesforce_-_xLAM-7b-r-gguf/blob/main/xLAM-7b-r.Q6_K.gguf) | Q6_K | 5.53GB |
38
+ | [xLAM-7b-r.Q8_0.gguf](https://huggingface.co/RichardErkhov/Salesforce_-_xLAM-7b-r-gguf/blob/main/xLAM-7b-r.Q8_0.gguf) | Q8_0 | 7.17GB |
39
+
40
+
41
+
42
+
43
+ Original model description:
44
+ ---
45
+ extra_gated_heading: >-
46
+ Acknowledge to follow corresponding license to access the
47
+ repository
48
+ extra_gated_button_content: Agree and access repository
49
+ extra_gated_fields:
50
+ First Name: text
51
+ Last Name: text
52
+ Country: country
53
+ Affiliation: text
54
+ license: cc-by-nc-4.0
55
+ datasets:
56
+ - Salesforce/xlam-function-calling-60k
57
+ language:
58
+ - en
59
+ pipeline_tag: text-generation
60
+ tags:
61
+ - function-calling
62
+ - LLM Agent
63
+ - tool-use
64
+ - mistral
65
+ - pytorch
66
+ ---
67
+
68
+ <p align="center">
69
+ <img width="500px" alt="xLAM" src="https://huggingface.co/datasets/jianguozhang/logos/resolve/main/xlam-no-background.png">
70
+ </p>
71
+ <p align="center">
72
+ <a href="https://www.salesforceairesearch.com/projects/xlam-large-action-models">[Homepage]</a> |
73
+ <a href="https://arxiv.org/abs/2409.03215">[Paper]</a> |
74
+ <a href="https://github.com/SalesforceAIResearch/xLAM">[Github]</a> |
75
+ <a href="https://blog.salesforceairesearch.com/large-action-model-ai-agent/">[Blog]</a> |
76
+ <a href="https://huggingface.co/spaces/Tonic/Salesforce-Xlam-7b-r">[Community Demo]</a>
77
+ </p>
78
+ <hr>
79
+
80
+
81
+ Welcome to the xLAM model family! [Large Action Models (LAMs)](https://blog.salesforceairesearch.com/large-action-models/) are advanced large language models designed to enhance decision-making and translate user intentions into executable actions that interact with the world. LAMs autonomously plan and execute tasks to achieve specific goals, serving as the brains of AI agents. They have the potential to automate workflow processes across various domains, making them invaluable for a wide range of applications.
82
+ **The model release is exclusively for research purposes. A new and enhanced version of xLAM will soon be available exclusively to customers on our Platform.**
83
+
84
+ ## Table of Contents
85
+ - [Model Series](#model-series)
86
+ - [Repository Overview](#repository-overview)
87
+ - [Benchmark Results](#benchmark-results)
88
+ - [Usage](#usage)
89
+ - [Basic Usage with Huggingface](#basic-usage-with-huggingface)
90
+ - [License](#license)
91
+ - [Citation](#citation)
92
+
93
+ ## Model Series
94
+
95
+ We provide a series of xLAMs in different sizes to cater to various applications, including those optimized for function-calling and general agent applications:
96
+
97
+ | Model | # Total Params | Context Length | Download Model | Download GGUF files |
98
+ |------------------------|----------------|----------------|----------------|----------|
99
+ | xLAM-1b-fc-r | 1.35B | 16k | [🤗 Link](https://huggingface.co/Salesforce/xLAM-1b-fc-r) | [🤗 Link](https://huggingface.co/Salesforce/xLAM-1b-fc-r-gguf) |
100
+ | xLAM-7b-fc-r | 6.91B | 4k | [🤗 Link](https://huggingface.co/Salesforce/xLAM-7b-fc-r) | [🤗 Link](https://huggingface.co/Salesforce/xLAM-7b-fc-r-gguf) |
101
+ | xLAM-7b-r | 7.24B | 32k | [🤗 Link](https://huggingface.co/Salesforce/xLAM-7b-r) | -- |
102
+ | xLAM-8x7b-r | 46.7B | 32k | [🤗 Link](https://huggingface.co/Salesforce/xLAM-8x7b-r) | -- |
103
+ | xLAM-8x22b-r | 141B | 64k | [🤗 Link](https://huggingface.co/Salesforce/xLAM-8x22b-r) | -- |
104
+
105
+
106
+
107
+
108
+
109
+
110
+ For our Function-calling series (more details are included at [here](https://huggingface.co/Salesforce/xLAM-7b-fc-r)), we also provide their quantized [GGUF](https://huggingface.co/docs/hub/en/gguf) files for efficient deployment and execution. GGUF is a file format designed to efficiently store and load large language models, making GGUF ideal for running AI models on local devices with limited resources, enabling offline functionality and enhanced privacy.
111
+
112
+ For more details, check our [GitHub](https://github.com/SalesforceAIResearch/xLAM) and [paper]().
113
+
114
+
115
+ ## Repository Overview
116
+
117
+ This repository is about the general tool use series. For more specialized function calling models, please take a look into our `fc` series [here](https://huggingface.co/Salesforce/xLAM-7b-fc-r).
118
+
119
+ The instructions will guide you through the setup, usage, and integration of our model series with HuggingFace.
120
+ ### Framework Versions
121
+
122
+ - Transformers 4.41.0
123
+ - Pytorch 2.3.0+cu121
124
+ - Datasets 2.19.1
125
+ - Tokenizers 0.19.1
126
+
127
+ ## Usage
128
+
129
+ ### Basic Usage with Huggingface
130
+
131
+ To use the model from Huggingface, please first install the `transformers` library:
132
+ ```bash
133
+ pip install transformers>=4.41.0
134
+ ```
135
+
136
+ Please note that, our model works best with our provided prompt format.
137
+ It allows us to extract JSON output that is similar to the [function-calling mode of ChatGPT](https://platform.openai.com/docs/guides/function-calling).
138
+
139
+ We use the following example to illustrate how to use our model for 1) single-turn use case, and 2) multi-turn use case
140
+
141
+ #### 1. Single-turn use case
142
+
143
+ ````python
144
+ import json
145
+ import torch
146
+ from transformers import AutoModelForCausalLM, AutoTokenizer
147
+
148
+ torch.random.manual_seed(0)
149
+
150
+ model_name = "Salesforce/xLAM-7b-r"
151
+ model = AutoModelForCausalLM.from_pretrained(model_name, device_map="auto", torch_dtype="auto", trust_remote_code=True)
152
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
153
+
154
+ # Please use our provided instruction prompt for best performance
155
+ task_instruction = """
156
+ Based on the previous context and API request history, generate an API request or a response as an AI assistant.""".strip()
157
+
158
+ format_instruction = """
159
+ The output should be of the JSON format, which specifies a list of generated function calls. The example format is as follows, please make sure the parameter type is correct. If no function call is needed, please make
160
+ tool_calls an empty list "[]".
161
+ ```
162
+ {"thought": "the thought process, or an empty string", "tool_calls": [{"name": "api_name1", "arguments": {"argument1": "value1", "argument2": "value2"}}]}
163
+ ```
164
+ """.strip()
165
+
166
+ # Define the input query and available tools
167
+ query = "What's the weather like in New York in fahrenheit?"
168
+
169
+ get_weather_api = {
170
+ "name": "get_weather",
171
+ "description": "Get the current weather for a location",
172
+ "parameters": {
173
+ "type": "object",
174
+ "properties": {
175
+ "location": {
176
+ "type": "string",
177
+ "description": "The city and state, e.g. San Francisco, New York"
178
+ },
179
+ "unit": {
180
+ "type": "string",
181
+ "enum": ["celsius", "fahrenheit"],
182
+ "description": "The unit of temperature to return"
183
+ }
184
+ },
185
+ "required": ["location"]
186
+ }
187
+ }
188
+
189
+ search_api = {
190
+ "name": "search",
191
+ "description": "Search for information on the internet",
192
+ "parameters": {
193
+ "type": "object",
194
+ "properties": {
195
+ "query": {
196
+ "type": "string",
197
+ "description": "The search query, e.g. 'latest news on AI'"
198
+ }
199
+ },
200
+ "required": ["query"]
201
+ }
202
+ }
203
+
204
+ openai_format_tools = [get_weather_api, search_api]
205
+
206
+ # Helper function to convert openai format tools to our more concise xLAM format
207
+ def convert_to_xlam_tool(tools):
208
+ ''''''
209
+ if isinstance(tools, dict):
210
+ return {
211
+ "name": tools["name"],
212
+ "description": tools["description"],
213
+ "parameters": {k: v for k, v in tools["parameters"].get("properties", {}).items()}
214
+ }
215
+ elif isinstance(tools, list):
216
+ return [convert_to_xlam_tool(tool) for tool in tools]
217
+ else:
218
+ return tools
219
+
220
+ def build_conversation_history_prompt(conversation_history: str):
221
+ parsed_history = []
222
+ for step_data in conversation_history:
223
+ parsed_history.append({
224
+ "step_id": step_data["step_id"],
225
+ "thought": step_data["thought"],
226
+ "tool_calls": step_data["tool_calls"],
227
+ "next_observation": step_data["next_observation"],
228
+ "user_input": step_data['user_input']
229
+ })
230
+
231
+ history_string = json.dumps(parsed_history)
232
+ return f"\n[BEGIN OF HISTORY STEPS]\n{history_string}\n[END OF HISTORY STEPS]\n"
233
+
234
+
235
+ # Helper function to build the input prompt for our model
236
+ def build_prompt(task_instruction: str, format_instruction: str, tools: list, query: str, conversation_history: list):
237
+ prompt = f"[BEGIN OF TASK INSTRUCTION]\n{task_instruction}\n[END OF TASK INSTRUCTION]\n\n"
238
+ prompt += f"[BEGIN OF AVAILABLE TOOLS]\n{json.dumps(xlam_format_tools)}\n[END OF AVAILABLE TOOLS]\n\n"
239
+ prompt += f"[BEGIN OF FORMAT INSTRUCTION]\n{format_instruction}\n[END OF FORMAT INSTRUCTION]\n\n"
240
+ prompt += f"[BEGIN OF QUERY]\n{query}\n[END OF QUERY]\n\n"
241
+
242
+ if len(conversation_history) > 0: prompt += build_conversation_history_prompt(conversation_history)
243
+ return prompt
244
+
245
+ # Build the input and start the inference
246
+ xlam_format_tools = convert_to_xlam_tool(openai_format_tools)
247
+
248
+ conversation_history = []
249
+ content = build_prompt(task_instruction, format_instruction, xlam_format_tools, query, conversation_history)
250
+
251
+ messages=[
252
+ { 'role': 'user', 'content': content}
253
+ ]
254
+
255
+ inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to(model.device)
256
+
257
+ # tokenizer.eos_token_id is the id of <|EOT|> token
258
+ outputs = model.generate(inputs, max_new_tokens=512, do_sample=False, num_return_sequences=1, eos_token_id=tokenizer.eos_token_id)
259
+ agent_action = tokenizer.decode(outputs[0][len(inputs[0]):], skip_special_tokens=True)
260
+ ````
261
+
262
+ Then you should be able to see the following output string in JSON format:
263
+
264
+ ```shell
265
+ {"thought": "I need to get the current weather for New York in fahrenheit.", "tool_calls": [{"name": "get_weather", "arguments": {"location": "New York", "unit": "fahrenheit"}}]}
266
+ ```
267
+
268
+ #### 2. Multi-turn use case
269
+
270
+ We also support multi-turn interaction with our model series. Here is the example of next round of interaction from the above example:
271
+
272
+ ````python
273
+ def parse_agent_action(agent_action: str):
274
+ """
275
+ Given an agent's action, parse it to add to conversation history
276
+ """
277
+ try: parsed_agent_action_json = json.loads(agent_action)
278
+ except: return "", []
279
+
280
+ if "thought" not in parsed_agent_action_json.keys(): thought = ""
281
+ else: thought = parsed_agent_action_json["thought"]
282
+
283
+ if "tool_calls" not in parsed_agent_action_json.keys(): tool_calls = []
284
+ else: tool_calls = parsed_agent_action_json["tool_calls"]
285
+
286
+ return thought, tool_calls
287
+
288
+ def update_conversation_history(conversation_history: list, agent_action: str, environment_response: str, user_input: str):
289
+ """
290
+ Update the conversation history list based on the new agent_action, environment_response, and/or user_input
291
+ """
292
+ thought, tool_calls = parse_agent_action(agent_action)
293
+ new_step_data = {
294
+ "step_id": len(conversation_history) + 1,
295
+ "thought": thought,
296
+ "tool_calls": tool_calls,
297
+ "step_id": len(conversation_history),
298
+ "next_observation": environment_response,
299
+ "user_input": user_input,
300
+ }
301
+
302
+ conversation_history.append(new_step_data)
303
+
304
+ def get_environment_response(agent_action: str):
305
+ """
306
+ Get the environment response for the agent_action
307
+ """
308
+ # TODO: add custom implementation here
309
+ error_message, response_message = "", ""
310
+ return {"error": error_message, "response": response_message}
311
+
312
+ # ------------- before here are the steps to get agent_response from the example above ----------
313
+
314
+ # 1. get the next state after agent's response:
315
+ # The next 2 lines are examples of getting environment response and user_input.
316
+ # It is depended on particular usage, we can have either one or both of those.
317
+ environment_response = get_environment_response(agent_action)
318
+ user_input = "Now, search on the Internet for cute puppies"
319
+
320
+ # 2. after we got environment_response and (or) user_input, we want to add to our conversation history
321
+ update_conversation_history(conversation_history, agent_action, environment_response, user_input)
322
+
323
+ # 3. we now can build the prompt
324
+ content = build_prompt(task_instruction, format_instruction, xlam_format_tools, query, conversation_history)
325
+
326
+ # 4. Now, we just retrieve the inputs for the LLM
327
+ messages=[
328
+ { 'role': 'user', 'content': content}
329
+ ]
330
+ inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to(model.device)
331
+
332
+ # 5. Generate the outputs & decode
333
+ # tokenizer.eos_token_id is the id of <|EOT|> token
334
+ outputs = model.generate(inputs, max_new_tokens=512, do_sample=False, num_return_sequences=1, eos_token_id=tokenizer.eos_token_id)
335
+ agent_action = tokenizer.decode(outputs[0][len(inputs[0]):], skip_special_tokens=True)
336
+ ````
337
+
338
+ This would be the corresponding output:
339
+ ```shell
340
+ {"thought": "I need to get the current weather for New York in fahrenheit.", "tool_calls": [{"name": "get_weather", "arguments": {"location": "New York", "unit": "fahrenheit"}}]}
341
+ ```
342
+
343
+ We highly recommend to use our provided prompt format and helper functions to yield the best function-calling performance of our model.
344
+
345
+ #### Example multi-turn prompt and output
346
+
347
+ Prompt:
348
+ ````json
349
+ [BEGIN OF TASK INSTRUCTION]
350
+ Based on the previous context and API request history, generate an API request or a response as an AI assistant.
351
+ [END OF TASK INSTRUCTION]
352
+
353
+ [BEGIN OF AVAILABLE TOOLS]
354
+ [
355
+ {
356
+ "name": "get_fire_info",
357
+ "description": "Query the latest wildfire information",
358
+ "parameters": {
359
+ "location": {
360
+ "type": "string",
361
+ "description": "Location of the wildfire, for example: 'California'",
362
+ "required": true,
363
+ "format": "free"
364
+ },
365
+ "radius": {
366
+ "type": "number",
367
+ "description": "The radius (in miles) around the location where the wildfire is occurring, for example: 10",
368
+ "required": false,
369
+ "format": "free"
370
+ }
371
+ }
372
+ },
373
+ {
374
+ "name": "get_hurricane_info",
375
+ "description": "Query the latest hurricane information",
376
+ "parameters": {
377
+ "name": {
378
+ "type": "string",
379
+ "description": "Name of the hurricane, for example: 'Irma'",
380
+ "required": true,
381
+ "format": "free"
382
+ }
383
+ }
384
+ },
385
+ {
386
+ "name": "get_earthquake_info",
387
+ "description": "Query the latest earthquake information",
388
+ "parameters": {
389
+ "magnitude": {
390
+ "type": "number",
391
+ "description": "The minimum magnitude of the earthquake that needs to be queried.",
392
+ "required": false,
393
+ "format": "free"
394
+ },
395
+ "location": {
396
+ "type": "string",
397
+ "description": "Location of the earthquake, for example: 'California'",
398
+ "required": false,
399
+ "format": "free"
400
+ }
401
+ }
402
+ }
403
+ ]
404
+ [END OF AVAILABLE TOOLS]
405
+
406
+ [BEGIN OF FORMAT INSTRUCTION]
407
+ Your output should be in the JSON format, which specifies a list of function calls. The example format is as follows. Please make sure the parameter type is correct. If no function call is needed, please make tool_calls an empty list '[]'.
408
+ ```{"thought": "the thought process, or an empty string", "tool_calls": [{"name": "api_name1", "arguments": {"argument1": "value1", "argument2": "value2"}}]}```
409
+ [END OF FORMAT INSTRUCTION]
410
+
411
+ [BEGIN OF QUERY]
412
+ User: Can you give me the latest information on the wildfires occurring in California?
413
+ [END OF QUERY]
414
+
415
+ [BEGIN OF HISTORY STEPS]
416
+ [
417
+ {
418
+ "thought": "Sure, what is the radius (in miles) around the location of the wildfire?",
419
+ "tool_calls": [],
420
+ "step_id": 1,
421
+ "next_observation": "",
422
+ "user_input": "User: Let me think... 50 miles."
423
+ },
424
+ {
425
+ "thought": "",
426
+ "tool_calls": [
427
+ {
428
+ "name": "get_fire_info",
429
+ "arguments": {
430
+ "location": "California",
431
+ "radius": 50
432
+ }
433
+ }
434
+ ],
435
+ "step_id": 2,
436
+ "next_observation": [
437
+ {
438
+ "location": "Los Angeles",
439
+ "acres_burned": 1500,
440
+ "status": "contained"
441
+ },
442
+ {
443
+ "location": "San Diego",
444
+ "acres_burned": 12000,
445
+ "status": "active"
446
+ }
447
+ ]
448
+ },
449
+ {
450
+ "thought": "Based on the latest information, there are wildfires in Los Angeles and San Diego. The wildfire in Los Angeles has burned 1,500 acres and is contained, while the wildfire in San Diego has burned 12,000 acres and is still active.",
451
+ "tool_calls": [],
452
+ "step_id": 3,
453
+ "next_observation": "",
454
+ "user_input": "User: Can you tell me about the latest earthquake?"
455
+ }
456
+ ]
457
+
458
+ [END OF HISTORY STEPS]
459
+ ````
460
+
461
+ Output:
462
+ ````json
463
+ {"thought": "", "tool_calls": [{"name": "get_earthquake_info", "arguments": {"location": "California"}}]}
464
+ ````
465
+
466
+ ## Benchmark Results
467
+ Note: **Bold** and <u>Underline</u> results denote the best result and the second best result for Success Rate, respectively.
468
+
469
+ ### Berkeley Function-Calling Leaderboard (BFCL)
470
+ ![xlam-bfcl](media/xlam-bfcl.png)
471
+ *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.*
472
+
473
+ ### Webshop and ToolQuery
474
+ ![xlam-webshop_toolquery](media/xlam-webshop_toolquery.png)
475
+ *Table 2: Testing results on Webshop and ToolQuery. Bold and Underline results denote the best result and the second best result for Success Rate, respectively.*
476
+
477
+ ### Unified ToolQuery
478
+ ![xlam-unified_toolquery](media/xlam-unified_toolquery.png)
479
+ *Table 3: Testing results on ToolQuery-Unified. Bold and Underline results denote the best result and the second best result for Success Rate, respectively. Values in brackets indicate corresponding performance on ToolQuery*
480
+
481
+ ### ToolBench
482
+ ![xlam-toolbench](media/xlam-toolbench.png)
483
+ *Table 4: Pass Rate on ToolBench on three distinct scenarios. Bold and Underline results denote the best result and the second best result for each setting, respectively. The results for xLAM-8x22b-r are unavailable due to the ToolBench server being down between 07/28/2024 and our evaluation cutoff date 09/03/2024.*
484
+
485
+ ## License
486
+ The model is distributed under the CC-BY-NC-4.0 license.
487
+
488
+ ## Citation
489
+
490
+ If you find this repo helpful, please consider to cite our papers:
491
+
492
+ ```bibtex
493
+ @article{zhang2024xlam,
494
+ title={xLAM: A Family of Large Action Models to Empower AI Agent Systems},
495
+ 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},
496
+ journal={arXiv preprint arXiv:2409.03215},
497
+ year={2024}
498
+ }
499
+ ```
500
+
501
+ ```bibtex
502
+ @article{liu2024apigen,
503
+ title={Apigen: Automated pipeline for generating verifiable and diverse function-calling datasets},
504
+ 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},
505
+ journal={arXiv preprint arXiv:2406.18518},
506
+ year={2024}
507
+ }
508
+ ```
509
+
510
+ ```bibtex
511
+ @article{zhang2024agentohana,
512
+ title={AgentOhana: Design Unified Data and Training Pipeline for Effective Agent Learning},
513
+ 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},
514
+ journal={arXiv preprint arXiv:2402.15506},
515
+ year={2024}
516
+ }
517
+ ```
518
+