Update README.md
Browse files
README.md
CHANGED
|
@@ -16,18 +16,17 @@ language:
|
|
| 16 |
|
| 17 |
# Model Card for Llama-3.2-1B-Instruct-APIGen-FC-v0.1
|
| 18 |
|
| 19 |
-
This model is a fine-tuned version of [meta-llama/Llama-3.2-1B-Instruct](https://huggingface.co/meta-llama/Llama-3.2-1B-Instruct) on
|
| 20 |
-
|
| 21 |
-
[argilla
|
| 22 |
It has been trained using [TRL](https://github.com/huggingface/trl).
|
| 23 |
|
| 24 |
## Quick start
|
| 25 |
|
| 26 |
This is a Fine tuned version of `Llama-3.2-1B-Instruct` model specific for Function Calling, to showcase how to fine tune a model on top of a dataset
|
| 27 |
-
like [argilla
|
| 28 |
-
[Salesforce/xlam-function-calling-60k](https://huggingface.co/datasets/Salesforce/xlam-function-calling-60k) and prepared with any custom format.
|
| 29 |
|
| 30 |
-
|
| 31 |
|
| 32 |
<details><summary> Click to see helper functions </summary>
|
| 33 |
|
|
@@ -109,6 +108,11 @@ def parse_response(text: str) -> str | dict[str, any]:
|
|
| 109 |
|
| 110 |
</details>
|
| 111 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
Example of *simple* function call:
|
| 113 |
|
| 114 |
````python
|
|
@@ -170,7 +174,9 @@ response = parse_response(result)
|
|
| 170 |
# [{'name': 'get_weather', 'arguments': {'location': 'New York', 'unit': 'fahrenheit'}}]
|
| 171 |
````
|
| 172 |
|
| 173 |
-
|
|
|
|
|
|
|
| 174 |
|
| 175 |
```python
|
| 176 |
available_tools = [{"name": "spotify.play", "description": "Play specific tracks from a given artist for a specific time duration.", "parameters": {"type": "dict", "properties": {"artist": {"type": "string", "description": "The artist whose songs you want to play."}, "duration": {"type": "integer", "description": "The duration for which the songs should be played, in minutes."}}, "required": ["artist", "duration"]}}]
|
|
@@ -188,7 +194,10 @@ response = parse_response(result)
|
|
| 188 |
|
| 189 |
</details>
|
| 190 |
|
| 191 |
-
|
|
|
|
|
|
|
|
|
|
| 192 |
|
| 193 |
```python
|
| 194 |
available_tools = [{"name": "country_info.largest_city", "description": "Fetch the largest city of a specified country.", "parameters": {"type": "dict", "properties": {"country": {"type": "string", "description": "Name of the country."}}, "required": ["country"]}}, {"name": "country_info.capital", "description": "Fetch the capital city of a specified country.", "parameters": {"type": "dict", "properties": {"country": {"type": "string", "description": "Name of the country."}}, "required": ["country"]}}, {"name": "country_info.population", "description": "Fetch the current population of a specified country.", "parameters": {"type": "dict", "properties": {"country": {"type": "string", "description": "Name of the country."}}, "required": ["country"]}}]
|
|
@@ -206,7 +215,10 @@ response = parse_response(result)
|
|
| 206 |
|
| 207 |
</details>
|
| 208 |
|
| 209 |
-
|
|
|
|
|
|
|
|
|
|
| 210 |
|
| 211 |
```python
|
| 212 |
available_tools = [{"name": "math_toolkit.sum_of_multiples", "description": "Find the sum of all multiples of specified numbers within a specified range.", "parameters": {"type": "dict", "properties": {"lower_limit": {"type": "integer", "description": "The start of the range (inclusive)."}, "upper_limit": {"type": "integer", "description": "The end of the range (inclusive)."}, "multiples": {"type": "array", "items": {"type": "integer"}, "description": "The numbers to find multiples of."}}, "required": ["lower_limit", "upper_limit", "multiples"]}}, {"name": "math_toolkit.product_of_primes", "description": "Find the product of the first n prime numbers.", "parameters": {"type": "dict", "properties": {"count": {"type": "integer", "description": "The number of prime numbers to multiply together."}}, "required": ["count"]}}]
|
|
@@ -224,7 +236,10 @@ response = parse_response(result)
|
|
| 224 |
|
| 225 |
</details>
|
| 226 |
|
| 227 |
-
|
|
|
|
|
|
|
|
|
|
| 228 |
|
| 229 |
```python
|
| 230 |
|
|
@@ -280,7 +295,10 @@ response = parse_response(result)
|
|
| 280 |
|
| 281 |
</details>
|
| 282 |
|
| 283 |
-
|
|
|
|
|
|
|
|
|
|
| 284 |
|
| 285 |
Example response with no tools available
|
| 286 |
|
|
@@ -334,7 +352,7 @@ response = parse_response(result)
|
|
| 334 |
|
| 335 |
[<img src="https://raw.githubusercontent.com/wandb/assets/main/wandb-github-badge-28.svg" alt="Visualize in Weights & Biases" width="150" height="24"/>](https://wandb.ai/plaguss/huggingface/runs/dw9q43g4)
|
| 336 |
|
| 337 |
-
This model was trained with SFT. You can take a look at [sft.slurm](https://huggingface.co/
|
| 338 |
training script, if you don't have access to a slurm cluster, it can be run jsut using the `accelerate` command. It took 13 minutes in a node with 8xH100.
|
| 339 |
|
| 340 |
To install the requirements, the following commands can be used:
|
|
@@ -360,8 +378,6 @@ And login to your WandB and Hugging Face accounts to push both logs and the fina
|
|
| 360 |
|
| 361 |
## Citations
|
| 362 |
|
| 363 |
-
|
| 364 |
-
|
| 365 |
Cite TRL as:
|
| 366 |
|
| 367 |
```bibtex
|
|
|
|
| 16 |
|
| 17 |
# Model Card for Llama-3.2-1B-Instruct-APIGen-FC-v0.1
|
| 18 |
|
| 19 |
+
This model is a fine-tuned version of [meta-llama/Llama-3.2-1B-Instruct](https://huggingface.co/meta-llama/Llama-3.2-1B-Instruct) on ç
|
| 20 |
+
[argilla-warehouse/apigen-synth-trl](https://huggingface.co/datasets/argilla-warehouse/apigen-synth-trl) dataset, a version of
|
| 21 |
+
[argilla/Synth-APIGen-v0.1](https://huggingface.co/datasets/argilla-warehouse/Synth-APIGen-v0.1) ready to do SFT on top of it.
|
| 22 |
It has been trained using [TRL](https://github.com/huggingface/trl).
|
| 23 |
|
| 24 |
## Quick start
|
| 25 |
|
| 26 |
This is a Fine tuned version of `Llama-3.2-1B-Instruct` model specific for Function Calling, to showcase how to fine tune a model on top of a dataset
|
| 27 |
+
like [argilla/Synth-APIGen-v0.1](https://huggingface.co/datasets/argilla/Synth-APIGen-v0.1).
|
|
|
|
| 28 |
|
| 29 |
+
### Helper functions for the prompt and output parsing
|
| 30 |
|
| 31 |
<details><summary> Click to see helper functions </summary>
|
| 32 |
|
|
|
|
| 108 |
|
| 109 |
</details>
|
| 110 |
|
| 111 |
+
### Examples
|
| 112 |
+
|
| 113 |
+
The following examples show how to use the model with transformers, for different types of queries and depending on the availability of tools.
|
| 114 |
+
|
| 115 |
+
|
| 116 |
Example of *simple* function call:
|
| 117 |
|
| 118 |
````python
|
|
|
|
| 174 |
# [{'name': 'get_weather', 'arguments': {'location': 'New York', 'unit': 'fahrenheit'}}]
|
| 175 |
````
|
| 176 |
|
| 177 |
+
#### `Parallel` function call
|
| 178 |
+
|
| 179 |
+
<details><summary> Click here: </summary>
|
| 180 |
|
| 181 |
```python
|
| 182 |
available_tools = [{"name": "spotify.play", "description": "Play specific tracks from a given artist for a specific time duration.", "parameters": {"type": "dict", "properties": {"artist": {"type": "string", "description": "The artist whose songs you want to play."}, "duration": {"type": "integer", "description": "The duration for which the songs should be played, in minutes."}}, "required": ["artist", "duration"]}}]
|
|
|
|
| 194 |
|
| 195 |
</details>
|
| 196 |
|
| 197 |
+
#### `Multiple` function call
|
| 198 |
+
|
| 199 |
+
|
| 200 |
+
<details><summary> Click here: </summary>
|
| 201 |
|
| 202 |
```python
|
| 203 |
available_tools = [{"name": "country_info.largest_city", "description": "Fetch the largest city of a specified country.", "parameters": {"type": "dict", "properties": {"country": {"type": "string", "description": "Name of the country."}}, "required": ["country"]}}, {"name": "country_info.capital", "description": "Fetch the capital city of a specified country.", "parameters": {"type": "dict", "properties": {"country": {"type": "string", "description": "Name of the country."}}, "required": ["country"]}}, {"name": "country_info.population", "description": "Fetch the current population of a specified country.", "parameters": {"type": "dict", "properties": {"country": {"type": "string", "description": "Name of the country."}}, "required": ["country"]}}]
|
|
|
|
| 215 |
|
| 216 |
</details>
|
| 217 |
|
| 218 |
+
#### `Parallel multiple` function call
|
| 219 |
+
|
| 220 |
+
|
| 221 |
+
<details><summary> Click here: </summary>
|
| 222 |
|
| 223 |
```python
|
| 224 |
available_tools = [{"name": "math_toolkit.sum_of_multiples", "description": "Find the sum of all multiples of specified numbers within a specified range.", "parameters": {"type": "dict", "properties": {"lower_limit": {"type": "integer", "description": "The start of the range (inclusive)."}, "upper_limit": {"type": "integer", "description": "The end of the range (inclusive)."}, "multiples": {"type": "array", "items": {"type": "integer"}, "description": "The numbers to find multiples of."}}, "required": ["lower_limit", "upper_limit", "multiples"]}}, {"name": "math_toolkit.product_of_primes", "description": "Find the product of the first n prime numbers.", "parameters": {"type": "dict", "properties": {"count": {"type": "integer", "description": "The number of prime numbers to multiply together."}}, "required": ["count"]}}]
|
|
|
|
| 236 |
|
| 237 |
</details>
|
| 238 |
|
| 239 |
+
#### `Multi-turn` function call
|
| 240 |
+
|
| 241 |
+
|
| 242 |
+
<details><summary> Click here: </summary>
|
| 243 |
|
| 244 |
```python
|
| 245 |
|
|
|
|
| 295 |
|
| 296 |
</details>
|
| 297 |
|
| 298 |
+
#### `Irrelevance` function call (examples when some data is missing)
|
| 299 |
+
|
| 300 |
+
|
| 301 |
+
<details><summary> Click here: </summary>
|
| 302 |
|
| 303 |
Example response with no tools available
|
| 304 |
|
|
|
|
| 352 |
|
| 353 |
[<img src="https://raw.githubusercontent.com/wandb/assets/main/wandb-github-badge-28.svg" alt="Visualize in Weights & Biases" width="150" height="24"/>](https://wandb.ai/plaguss/huggingface/runs/dw9q43g4)
|
| 354 |
|
| 355 |
+
This model was trained with SFT. You can take a look at [sft.slurm](https://huggingface.co/argilla/Llama-3.2-1B-Instruct-APIGen-FC-v0.1/blob/main/sft.slurm) to see the
|
| 356 |
training script, if you don't have access to a slurm cluster, it can be run jsut using the `accelerate` command. It took 13 minutes in a node with 8xH100.
|
| 357 |
|
| 358 |
To install the requirements, the following commands can be used:
|
|
|
|
| 378 |
|
| 379 |
## Citations
|
| 380 |
|
|
|
|
|
|
|
| 381 |
Cite TRL as:
|
| 382 |
|
| 383 |
```bibtex
|