jeffreymeetkai
commited on
Commit
•
29cdcc1
1
Parent(s):
8b990d3
Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Model Card for functionary-small-v2.2-GGUF
|
2 |
+
|
3 |
+
[https://github.com/MeetKai/functionary](https://github.com/MeetKai/functionary)
|
4 |
+
|
5 |
+
![Functionary Logo](https://huggingface.co/meetkai/functionary-medium-v2.2/resolve/main/functionary_logo.jpg "Functionary Logo")
|
6 |
+
|
7 |
+
Functionary is a language model that can interpret and execute functions/plugins.
|
8 |
+
|
9 |
+
The model determines when to execute functions, whether in parallel or serially, and can understand their outputs. It only triggers functions as needed. Function definitions are given as JSON Schema Objects, similar to OpenAI GPT function calls.
|
10 |
+
|
11 |
+
## Key Features
|
12 |
+
|
13 |
+
- Intelligent **parallel tool use**
|
14 |
+
- Able to analyze functions/tools outputs and provide relevant responses **grounded in the outputs**
|
15 |
+
- Able to decide **when to not use tools/call functions** and provide normal chat response
|
16 |
+
- Truly one of the best open-source alternative to GPT-4
|
17 |
+
|
18 |
+
## Performance
|
19 |
+
|
20 |
+
Our model achieves achieves state-of-the-art performance in Function Calling Accuracy on our in-house dataset. The accuracy metric measures the overall correctness of predicted function calls, including function name prediction and arguments extraction.
|
21 |
+
|
22 |
+
![Eval Chart](https://huggingface.co/meetkai/functionary-medium-v2.2/resolve/main/evaluation_chart.jpeg "Eval Chart")
|
23 |
+
|
24 |
+
| Dataset | Model Name | Function Calling Accuracy (Name & Arguments) |
|
25 |
+
| :-------------| :-------------------| ---------------------------: |
|
26 |
+
| In-house data | MeetKai-functionary-small-v2.2 | 0.546|
|
27 |
+
| In-house data | MeetKai-functionary-medium-v2.2 | **0.664**|
|
28 |
+
| In-house data | OpenAI-gpt-3.5-turbo-1106 | 0.531 |
|
29 |
+
| In-house data | OpenAI-gpt-4-1106-preview | **0.737** |
|
30 |
+
|
31 |
+
## Prompt Template
|
32 |
+
|
33 |
+
We use a specially designed prompt template which we call "v2PromptTemplate" that breaks down each turns into from, recipient and content portions.
|
34 |
+
|
35 |
+
We convert function definitions to a similar text to TypeScript definitions. Then we inject these definitions as system prompts. After that, we inject the default system prompt. Then we start the conversation messages.
|
36 |
+
|
37 |
+
This formatting is also available via our vLLM server which we process the functions into Typescript definitions encapsulated in a system message and use a pre-defined Transformers chat template. This means that lists of messages can be formatted for you with the apply_chat_template() method within our server:
|
38 |
+
|
39 |
+
```python
|
40 |
+
from openai import OpenAI
|
41 |
+
|
42 |
+
client = OpenAI(base_url="http://localhost:8000/v1", api_key="functionary")
|
43 |
+
|
44 |
+
client.chat.completions.create(
|
45 |
+
model="path/to/functionary/model/",
|
46 |
+
messages=[{"role": "user",
|
47 |
+
"content": "What is the weather for Istanbul?"}
|
48 |
+
],
|
49 |
+
tools=[{
|
50 |
+
"type": "function",
|
51 |
+
"function": {
|
52 |
+
"name": "get_current_weather",
|
53 |
+
"description": "Get the current weather",
|
54 |
+
"parameters": {
|
55 |
+
"type": "object",
|
56 |
+
"properties": {
|
57 |
+
"location": {
|
58 |
+
"type": "string",
|
59 |
+
"description": "The city and state, e.g. San Francisco, CA"
|
60 |
+
}
|
61 |
+
},
|
62 |
+
"required": ["location"]
|
63 |
+
}
|
64 |
+
}
|
65 |
+
}],
|
66 |
+
tool_choice="auto"
|
67 |
+
)
|
68 |
+
```
|
69 |
+
|
70 |
+
will yield:
|
71 |
+
|
72 |
+
```
|
73 |
+
<|from|>system
|
74 |
+
<|recipient|>all
|
75 |
+
<|content|>// Supported function definitions that should be called when necessary.
|
76 |
+
namespace functions {
|
77 |
+
// Get the current weather
|
78 |
+
type get_current_weather = (_: {
|
79 |
+
// The city and state, e.g. San Francisco, CA
|
80 |
+
location: string,
|
81 |
+
}) => any;
|
82 |
+
} // namespace functions
|
83 |
+
<|from|>system
|
84 |
+
<|recipient|>all
|
85 |
+
<|content|>A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions. The assistant calls functions with appropriate input when necessary
|
86 |
+
<|from|>user
|
87 |
+
<|recipient|>all
|
88 |
+
<|content|>What is the weather for Istanbul?
|
89 |
+
```
|
90 |
+
|
91 |
+
A more detailed example is provided [here](https://github.com/MeetKai/functionary/blob/main/tests/prompt_test_v2.txt).
|
92 |
+
|
93 |
+
## Run the model
|
94 |
+
|
95 |
+
We encourage users to run our models using our OpenAI-compatible vLLM server [here](https://github.com/MeetKai/functionary).
|
96 |
+
|
97 |
+
# The MeetKai Team
|
98 |
+
![MeetKai Logo](https://huggingface.co/meetkai/functionary-medium-v2.2/resolve/main/meetkai_logo.png "MeetKai Logo")
|