File size: 9,174 Bytes
07c9805 e83d478 79796b8 b020f5c 07c9805 9a346a0 07c9805 b610f31 07c9805 e83d478 07c9805 e83d478 07c9805 e83d478 07c9805 e83d478 07c9805 e83d478 07c9805 e83d478 07c9805 e83d478 07c9805 e83d478 07c9805 e83d478 b941a5c e83d478 79796b8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
---
base_model:
- Qwen/Qwen2.5-7B-Instruct
language:
- en
library_name: transformers
license: apache-2.0
---
# Model Card for EdgeRunner-Command-Nested
EdgeRunner-Command-Nested is an advanced large language model designed specifically for handling complex nested function calls. Initialized from Qwen2.5-7B-Instruct, further enhanced by the integration of the Hermes function call template and additional training on a specialized dataset (based on TinyAgent). This extra dataset focuses on personal domain applications, providing the model with a robust understanding of nested function scenarios that are typical in complex user interactions.
### Data Processing Process
#### 1. **Data Augmentation:**
- **TinyAgent Augmentation:**
TinyAgent consists of 16 core functions, but each sample only requires a subset of these functions to work. To ensure diversity and avoid overfitting, we used an augmentation technique where each sample is provided with a random superset of functions. This superset covers all the functions that the specific sample requires but is always a subset of the 16 total functions available in TinyAgent. By doing so, we allow the model to generalize across various combinations of functions while still providing the necessary context for each sample to execute correctly.
#### 2. **Additional Data Samples:**
- **GPT-4o Augmented Samples:**
To further enhance the dataset, we used GPT-4 for function synthesis in the personal assistant domain. This was done by using a pipeline that automatically generates function definitions, corresponding queries, and execution plans. After generating the function data, each sample was verified for validity to ensure the correctness of the functional outputs. Through this pipeline, we produced approximately 2,000 additional samples. These samples follow the TinyAgent format but introduce a broader range of new and more complex functions. This expanded set of functions enriches the model's understanding of diverse scenarios, allowing it to handle more varied function calls beyond the synthesis-based functions of TinyAgent, thereby improving its ability to generalize across tasks.
#### 3. **Data Conversion:**
- **Hermes Format Conversion:**
All function call data, including those from TinyAgent, the additional samples generated, and the function call data we had previously, were converted to the Hermes format. In TinyAgent, the Hermes format uses the `$ + number` format to indicate nested use cases. This ensures consistency in data representation while also clearly defining nested function use cases for enhanced interpretability. Standardizing all data in Hermes format allows the model to efficiently process and understand function calls across a variety of scenarios.
### Example Code
```python
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
model_id = "edgerunner-ai/EdgeRunner-Command-Nested"
tokenizer = AutoTokenizer.from_pretrained(model_id)
# You can find the full tools list here https://jsonblob.com/1290566717196328960
tools = [{
"name": "open_and_get_file_path",
"description": "Opens the file and returns its path.",
"parameters": {
"type": "object",
"properties": {
"file_name": {
"type": "str",
"description": "The name of the file to open"
}
},
"required": [
"file_name"
]
}
}, ...]
conversation = [{
"role": "user",
"content": "Send an email to Andrea attached with the file 'report.pdf' and ask when he is available for a meeting."
}]
# Render the tool use prompt as a string:
tool_use_prompt = tokenizer.apply_chat_template(
conversation,
tools=tools,
tokenize=False,
add_generation_prompt=True,
)
inputs = tokenizer(tool_use_prompt, return_tensors="pt")
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16, device_map="auto")
outputs = model.generate(**inputs, max_new_tokens=1000)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
```
# Examples
## Simple function
### Single turn
```markdown
**User:**
How is the weather today in New York?
**Assistant:**
I don't have direct access to real-time data like current weather conditions. However, I can help you find out by performing a web search. Let me do that now.
<tool_call>
{"name": "web_search", "arguments": {"query": "weather today New York"}}
</tool_call>
```
### Multi turn
```markdown
**User:**
I want to search for some information about music, can you help me with that?
**Assistant:**
Of course! What specific information about music are you looking for?
**User:**
I'm looking for information about the history of rock music.
**Assistant:**
<tool_call>
{"name": "web_search", "arguments": {"query": "history of rock music"}}
</tool_call>
```
```markdown
**User:**
I want to search for some information about music, can you help me with that?
**Assistant:**
Of course! What specific information about music are you looking for?
**User:**
I'm looking for information about the history of rock music and also information about Justin Bieber.
**Assistant:**
<tool_call>
{"name": "web_search", "arguments": {"query": "history of rock music"}}
</tool_call>
<tool_call>
{"name": "web_search", "arguments": {"query": "information about Justin Bieber"}}
</tool_call>
```
## Nested functions
### Success
```markdown
**User:**
Create a meeting with Mr.A and Mr.B to discuss Edgerunner on 27/9/2024 at 5:00 PM.
**Assistant:**
<tool_call>
{"name": "get_email_address", "arguments": {"name": "Mr.A"}}
</tool_call>
<tool_call>
{"name": "get_email_address", "arguments": {"name": "Mr.B"}}
</tool_call>
<tool_call>
{"name": "create_calendar_event", "arguments": {"title": "Edgerunner Discussion", "start_date": "2024-09-27 17:00:00", "end_date": "2024-09-27 18:00:00", "location": "", "invitees": ["$1", "$2"], "notes": "", "calendar": null}}
</tool_call>
```
```markdown
**User:**
Generate an image with the prompt 'A beautiful landscape with mountains and a lake' and send it to the Discord server with the message 'Here is a beautiful landscape'.
**Assistant:**
<tool_call>
{"name": "generate_image", "arguments": {"prompt": "A beautiful landscape with mountains and a lake"}}
</tool_call>
<tool_call>
{"name": "send_to_discord", "arguments": {"message": "Here is a beautiful landscape.", "attachments": ["$1"]}}
</tool_call>
```
```markdown
**User:**
Send the directions to the Eiffel Tower from the Louvre Museum to Mr. C and Mr. D with an SMS message.
**Assistant:**
<tool_call>
{"name": "get_phone_number", "arguments": {"name": "Mr.C"}}
</tool_call>
<tool_call>
{"name": "get_phone_number", "arguments": {"name": "Mr.D"}}
</tool_call>
<tool_call>
{"name": "maps_show_directions", "arguments": {"start_location": "Louvre Museum", "end_location": "Eiffel Tower", "transport": "d"}}
</tool_call>
<tool_call>
{"name": "send_sms", "arguments": {"recipients": ["$1", "$2"], "message": "Here are the directions to get from Louvre Museum to Eiffel Tower: $3"}}
</tool_call>
```
```markdown
**User:**
Send an email to Mr. A attached with the file 'report.pdf' and ask when he is available for a meeting.
**Assistant:**
<tool_call>
{"name": "get_email_address", "arguments": {"name": "Mr.A"}}
</tool_call>
<tool_call>
{"name": "open_and_get_file_path", "arguments": {"file_name": "report.pdf"}}
</tool_call>
<tool_call>
{"name": "compose_new_email", "arguments": {"recipients": ["$1"], "cc": [], "subject": "Availability for Meeting", "context": "Please find the attached report. When are you available for a meeting?", "attachments": ["$2"]}}
</tool_call>
```
### Failed
```markdown
**User:**
I want to generate an image and send it to Discord. Can you help me with that?
**Assistant:**
Of course! Could you please provide me with a description or prompt for the image you would like to generate?
**User:**
I want to generate an image of a cat with a gray background.
**Assistant:**
<tool_call>
{"name": "generate_image", "arguments": {"prompt": "a cat with a gray background"}}
</tool_call>
<tool_call>
{"name": "send_to_discord", "arguments": {"message": "", "attachments": ["image.png"]}}
</tool_call>
```
# Benchmarks
## Berkeley Function Calling Benchmark Results
| Test Name | EdgeRunner-Command-Nested| Qwen/Qwen2.5-7B-Instruct |
|-----------------------------|------------------------------------------------|--------------------------|
| multiple_function | 0.95 | 0.81 |
| parallel_multiple_function | 0.84 | 0.655 |
| parallel_function | 0.86 | 0.69 |
| simple | 0.96 | 0.9275 |
| irrelevance | 0.74 | 0.625 | |