File size: 1,975 Bytes
51203f2
5fbe284
 
51203f2
5fbe284
 
 
51203f2
5fbe284
 
 
51203f2
 
5fbe284
51203f2
5fbe284
51203f2
5fbe284
51203f2
5fbe284
369095e
5fbe284
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
369095e
 
 
 
 
 
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
---
license: llama3.1
base_model: meta-llama/Llama-3.1-8B-Instruct
tags:
- function-calling
- tool-use
- fine-tuned
- llama
datasets:
- Salesforce/xlam-function-calling-60k
pipeline_tag: text-generation
---

# Llama 3.1 8B Function Calling

Fine-tuned [Llama 3.1 8B Instruct](https://huggingface.co/meta-llama/Llama-3.1-8B-Instruct) for function/tool calling.

## Training

- **Dataset:** 900 examples from [Salesforce/xlam-function-calling-60k](https://huggingface.co/datasets/Salesforce/xlam-function-calling-60k)
- **Method:** LoRA 
- **Trainable params:** 42M / 8B (0.52%)
- **Epochs:** 1
- **Loss:** 0.66 → 0.63

## Evaluation (100 held-out samples)

- **Exact match:** 62%
- **Function name accuracy:** ~90%+

## Usage
```python
from vllm import LLM

llm = LLM(model="alfazick/llama-3.1-8b-function-calling")
```

Or with transformers:
```python
from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained("alfazick/llama-3.1-8b-function-calling")
tokenizer = AutoTokenizer.from_pretrained("alfazick/llama-3.1-8b-function-calling")
```

## Prompt Format
```
<|begin_of_text|><|start_header_id|>system<|end_header_id|>

You are a helpful assistant with access to the following tools or function calls. Your task is to produce a sequence of tools or function calls necessary to generate response to the user utterance. Use the following tools or function calls as required:
[{"name": "func_name", "description": "...", "parameters": {...}}]<|eot_id|><|start_header_id|>user<|end_header_id|>

{query}<|eot_id|><|start_header_id|>assistant<|end_header_id|>
```

## Output Format
```json
[{"name": "function_name", "arguments": {"arg": "value"}}]
```

## Limitations

- Trained on 900 examples (proof of concept)
- May have argument variations vs ground truth
- Best for single/simple tool calls

## Training Details
- **Framework:** Unsloth 2025.11.2 + TRL
- **Hardware:** RTX 5090 (32GB)
- **Method:** LoRA (r=16, alpha=16)