updated model card with more precise information about the model
Browse files
README.md
CHANGED
@@ -7,28 +7,67 @@ tags:
|
|
7 |
- trl
|
8 |
- sft
|
9 |
licence: license
|
|
|
|
|
10 |
---
|
11 |
|
12 |
# Model Card for Phi-3.5-mini-thinking-function_calling-V0
|
13 |
|
14 |
-
This model is a fine-tuned version of [microsoft/Phi-3.5-mini-instruct](https://huggingface.co/microsoft/Phi-3.5-mini-instruct).
|
15 |
-
|
16 |
|
17 |
-
|
|
|
|
|
|
|
18 |
|
19 |
```python
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
```
|
27 |
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
-
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
This model was trained with SFT.
|
34 |
|
@@ -42,8 +81,6 @@ This model was trained with SFT.
|
|
42 |
|
43 |
## Citations
|
44 |
|
45 |
-
|
46 |
-
|
47 |
Cite TRL as:
|
48 |
|
49 |
```bibtex
|
|
|
7 |
- trl
|
8 |
- sft
|
9 |
licence: license
|
10 |
+
datasets:
|
11 |
+
- Jofthomas/hermes-function-calling-thinking-V1
|
12 |
---
|
13 |
|
14 |
# Model Card for Phi-3.5-mini-thinking-function_calling-V0
|
15 |
|
16 |
+
This model is a fine-tuned version of [microsoft/Phi-3.5-mini-instruct](https://huggingface.co/microsoft/Phi-3.5-mini-instruct) on [Jofthomas/hermes-function-calling-thinking-V1](https://huggingface.co/datasets/NousResearch/hermes-function-calling-v1) for function calling.
|
17 |
+
<br>This toy model has been training as an alternative exercise to the Unit 1 bonus section of the [Agent Ai course](https://huggingface.co/learn/agents-course/unit0/introduction).
|
18 |
|
19 |
+
💥 The training script to adapt the given example notebook for Phi-3.5-mini-instruct can be found [here](https://colab.research.google.com/drive/1b8_Kdzloqe_UMFasGXqItKuoP2D-wTrW?usp=sharing).
|
20 |
+
|
21 |
+
|
22 |
+
## Example usage
|
23 |
|
24 |
```python
|
25 |
+
prompt = """<|user|>
|
26 |
+
You are a function calling AI model. You are provided with function signatures within <tools></tools> XML tags.You may call one or more functions to assist with the user query. Don't make assumptions about what values to plug into functions.Here are the available tools:<tools> [{'type': 'function', 'function': {'name': 'convert_currency', 'description': 'Convert from one currency to another', 'parameters': {'type': 'object', 'properties': {'amount': {'type': 'number', 'description': 'The amount to convert'}, 'from_currency': {'type': 'string', 'description': 'The currency to convert from'}, 'to_currency': {'type': 'string', 'description': 'The currency to convert to'}}, 'required': ['amount', 'from_currency', 'to_currency']}}}, {'type': 'function', 'function': {'name': 'calculate_distance', 'description': 'Calculate the distance between two locations', 'parameters': {'type': 'object', 'properties': {'start_location': {'type': 'string', 'description': 'The starting location'}, 'end_location': {'type': 'string', 'description': 'The ending location'}}, 'required': ['start_location', 'end_location']}}}] </tools>Use the following pydantic model json schema for each tool call you will make: {'title': 'FunctionCall', 'type': 'object', 'properties': {'arguments': {'title': 'Arguments', 'type': 'object'}, 'name': {'title': 'Name', 'type': 'string'}}, 'required': ['arguments', 'name']}For each function call return a json object with function name and arguments within <tool_call></tool_call> XML tags as follows:
|
27 |
+
<tool_call>
|
28 |
+
{tool_call}
|
29 |
+
</tool_call>Also, before making a call to a function take the time to plan the function to take. Make that thinking process between <think>{your thoughts}</think>
|
30 |
+
|
31 |
+
Hi, I need to convert 500 USD to Euros. Can you help me with that?<|end|>
|
32 |
+
<|assistant|>
|
33 |
+
<think>"""
|
34 |
+
|
35 |
+
eos_token_id = tokenizer.encode('<|endoftext|>')[0]
|
36 |
|
37 |
+
inputs = tokenizer(prompt, return_tensors="pt", add_special_tokens=False)
|
38 |
+
inputs = {k: v.to("cuda") for k,v in inputs.items()}
|
39 |
+
outputs = model.generate(**inputs,
|
40 |
+
max_new_tokens=300,# Adapt as necessary
|
41 |
+
do_sample=True,
|
42 |
+
top_p=0.95,
|
43 |
+
temperature=0.01,
|
44 |
+
repetition_penalty=1.0,
|
45 |
+
eos_token_id=eos_token_id)
|
46 |
+
|
47 |
+
print(tokenizer.decode(outputs[0]))
|
48 |
```
|
49 |
|
50 |
+
You should expect a result similar to the following, where the model could successfully "think" and call a function to answer the user:
|
51 |
+
```python
|
52 |
+
<|user|> You are a function calling AI model. You are provided with function signatures within <tools></tools> XML tags.You may call one or more functions to assist with the user query. Don't make assumptions about what values to plug into functions.Here are the available tools:<tools> [{'type': 'function', 'function': {'name': 'convert_currency', 'description': 'Convert from one currency to another', 'parameters': {'type': 'object', 'properties': {'amount': {'type': 'number', 'description': 'The amount to convert'}, 'from_currency': {'type': 'string', 'description': 'The currency to convert from'}, 'to_currency': {'type': 'string', 'description': 'The currency to convert to'}}, 'required': ['amount', 'from_currency', 'to_currency']}}}, {'type': 'function', 'function': {'name': 'calculate_distance', 'description': 'Calculate the distance between two locations', 'parameters': {'type': 'object', 'properties': {'start_location': {'type': 'string', 'description': 'The starting location'}, 'end_location': {'type': 'string', 'description': 'The ending location'}}, 'required': ['start_location', 'end_location']}}}] </tools> Use the following pydantic model json schema for each tool call you will make: {'title': 'FunctionCall', 'type': 'object', 'properties': {'arguments': {'title': 'Arguments', 'type': 'object'}, 'name': {'title': 'Name', 'type': 'string'}}, 'required': ['arguments', 'name']}For each function call return a json object with function name and arguments within <tool_call></tool_call> XML tags as follows:
|
53 |
+
<tool_call>
|
54 |
+
{tool_call}
|
55 |
+
</tool_call> Also, before making a call to a function take the time to plan the function to take. Make that thinking process between <think> {your thoughts}</think>
|
56 |
|
57 |
+
Hi, I need to convert 500 USD to Euros. Can you help me with that?<|end|><|assistant|><think> Okay, so the user is asking to convert 500 USD to Euros. I need to figure out which function to use. Looking at the available tools, there's a function called convert_currency that does exactly that. It requires the amount, the currency to convert from, and the currency to convert to. The user provided all these details: 500 USD to Euros. So, I'll call the convert_currency function with those parameters.
|
58 |
|
59 |
+
I should make sure to format the function call correctly, using the specified JSON schema. The function name is 'convert_currency', and the arguments are amount: 500, from_currency: 'USD', and to_currency: 'EUR'. That should do it.
|
60 |
+
|
61 |
+
Alright, I think that's all I need to do here. The user's request is straightforward, and the function is perfectly suited for this task.
|
62 |
+
<|tool|><|tool|>
|
63 |
+
{'name': 'convert_currency', 'arguments': {'amount': 500, 'from_currency': 'USD', 'to_currency': 'EUR'}}
|
64 |
+
<|tool|><|end|><|tool|>
|
65 |
+
<tool_response>
|
66 |
+
{'converted_amount': 425.5, 'from_currency': 'USD', 'to_currency': 'EUR'}
|
67 |
+
</tool_response><|end|><|assistant|> Sure, 500 USD is approximately 425.50 Euros.<|end|>
|
68 |
+
```
|
69 |
+
|
70 |
+
## Training procedure
|
71 |
|
72 |
This model was trained with SFT.
|
73 |
|
|
|
81 |
|
82 |
## Citations
|
83 |
|
|
|
|
|
84 |
Cite TRL as:
|
85 |
|
86 |
```bibtex
|