File size: 2,156 Bytes
db7354e
 
 
 
 
 
 
 
 
 
 
 
0ec8116
db7354e
 
 
b5509c0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f3cbe79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b5509c0
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
---
language:
- en
datasets:
- glaiveai/glaive-function-calling-v2
---

The model was finetuned using the glaive dataset using qlora and full finetuning using FSDP. 

Dataset link : [Link here](https://huggingface.co/datasets/glaiveai/glaive-function-calling-v2)


For training , inference and evaluation kindly check this repository:

https://github.com/Srini-98/Function-Calling-Using-Mistral

Use the following prompt format
```
SYSTEM: You are a helpful assistant with access to the following functions. Use them if required -
{
    "name": "function_name",
    "description": "description",
    "parameters": {
        "type": "object",
        "properties": {
            "param_name1": {
                "type": "string",
                "description": "description of param"
            },
            "param_name2": {
                "type": "string",
                "description": "description of param"
            },
            "param_name3":{
                "type: "string",
                "description" : "description of param"
            }
        },
        "required": [
            "param_name1",
        ]
    }
}
USER: {question here}


ASSISTANT: {model answer} <|endoftext|>
```


Example: 
```
SYSTEM: You are a helpful assistant with access to the following functions. Use them if required -
{
    "name": "calculate_tax",
    "description": "Calculate the tax amount",
    "parameters": {
        "type": "object",
        "properties": {
            "income": {
                "type": "number",
                "description": "The income amount"
            }
        },
        "required": [
            "income"
        ]
    }
}
USER: Hi, I need to calculate my tax for this year. My income is $70,000.


ASSISTANT: <functioncall> {"name": "calculate_tax", "arguments": '{"income": 70000}'} <|endoftext|>


FUNCTION RESPONSE: {"tax_amount": 17500}


ASSISTANT: Based on your income, your tax for this year is $17,500. <|endoftext|>
```

The answer generation can be stopped with the <|endoftext|> token. You can add multiple functions as well and set param names. "Required" field forces model to always call that param.