Triangle104 commited on
Commit
cfc8358
1 Parent(s): d36d72e

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +189 -0
README.md CHANGED
@@ -16,6 +16,195 @@ tags:
16
  This model was converted to GGUF format from [`katanemo/Arch-Function-3B`](https://huggingface.co/katanemo/Arch-Function-3B) using llama.cpp via the ggml.ai's [GGUF-my-repo](https://huggingface.co/spaces/ggml-org/gguf-my-repo) space.
17
  Refer to the [original model card](https://huggingface.co/katanemo/Arch-Function-3B) for more details on the model.
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  ## Use with llama.cpp
20
  Install llama.cpp through brew (works on Mac and Linux)
21
 
 
16
  This model was converted to GGUF format from [`katanemo/Arch-Function-3B`](https://huggingface.co/katanemo/Arch-Function-3B) using llama.cpp via the ggml.ai's [GGUF-my-repo](https://huggingface.co/spaces/ggml-org/gguf-my-repo) space.
17
  Refer to the [original model card](https://huggingface.co/katanemo/Arch-Function-3B) for more details on the model.
18
 
19
+ ---
20
+ Model details:
21
+ -
22
+ The Katanemo Arch-Function collection of large language models (LLMs) is a collection state-of-the-art (SOTA) LLMs specifically designed for function calling tasks. The models are designed to understand complex function signatures, identify required parameters, and produce accurate function call outputs based on natural language prompts. Achieving performance on par with GPT-4, these models set a new benchmark in the domain of function-oriented tasks, making them suitable for scenarios where automated API interaction and function execution is crucial.
23
+
24
+ In summary, the Katanemo Arch-Function collection demonstrates:
25
+
26
+ State-of-the-art performance in function calling
27
+ Accurate parameter identification and suggestion, even in ambiguous or incomplete inputs
28
+ High generalization across multiple function calling use cases, from API interactions to automated backend tasks.
29
+ Optimized low-latency, high-throughput performance, making it suitable for real-time, production environments.
30
+
31
+ Arch-Function is the core LLM used in then open source Arch Gateway to seamlessly integrate user prompts with developers APIs
32
+ Key Features
33
+ Functionality Definition
34
+ Single Function Calling Call only one function per user query
35
+ Parallel Function Calling Call the same function multiple times but with different set of parameter values
36
+ Multiple Function Calling Call different functions per user query
37
+ Parallel & Multiple Perform both parallel and multiple function calling
38
+ Training Details
39
+
40
+ Katanemo Arch-Function collection is built on top of the Qwen 2.5. A blog with technical details leading to our models will be published soon.
41
+ Performance Benchmarks
42
+
43
+ We evaluate Katanemo Arch-Function series on the Berkeley Function-Calling Leaderboard (BFCL). For each model family, we select the one with the highest rank. The results are shwon below:
44
+ Rank Model Overall Single Turn Multi Turn Hallucination
45
+ Non-live (AST) Non-live (Exec) Live (AST) Overall Relevance Irrelevance
46
+ 1 GPT-4-turbo-2024-04-09 59.49% 82.65% 83.80% 73.39% 21.62% 70.73% 79.79%
47
+ 3 xLAM-8x22b-r 59.13% 89.75% 89.32% 72.81% 15.62% 97.56% 75.23%
48
+ Arch-Function-7B 57.48% 87.50% 86.80% 72.19% 13.75% 82.93% 79.54%
49
+ Arch-Function-3B 56.23% 85.10% 89.16% 70.72% 12.28% 90.24% 73.98%
50
+ 7 mistral-large-2407 55.82% 84.12% 83.09% 67.17% 20.50% 78.05% 48.93%
51
+ 9 Claude-3.5-Sonnet-20240620 54.83% 70.35% 66.34% 71.39% 23.5% 63.41% 75.91%
52
+ Arch-Function-1.5B 53.61% 82.60% 87.36% 68.19% 8.62% 87.80% 75.90%
53
+ 11 o1-mini-2024-09-12 53.43% 75.48% 76.86% 71.17% 11.00% 46.34% 88.07%
54
+ 12 Gemini-1.5-Flash-Preview-0514 53.01% 77.10% 71.23% 71.17% 13.12% 60.98% 76.15%
55
+ Requirements
56
+
57
+ The code of Arch-Function-3B has been in the Hugging Face transformers library and we advise you to install latest version:
58
+
59
+ pip install transformers>=4.37.0
60
+
61
+ How to use
62
+ -
63
+ We use the following example to illustrate how to use our model to perform function calling tasks. Please note that, our model works best with our provided prompt format. It allows us to extract JSON output that is similar to the function-calling mode of ChatGPT.
64
+ Single Turn Example
65
+
66
+ import json
67
+ from typing import Any, Dict, List
68
+ from transformers import AutoModelForCausalLM, AutoTokenizer
69
+
70
+ model_name = "katanemo/Arch-Function-3B"
71
+ model = AutoModelForCausalLM.from_pretrained(
72
+ model_name, device_map="auto", torch_dtype="auto", trust_remote_code=True
73
+ )
74
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
75
+
76
+ # Please use our provided prompt for best performance
77
+ TASK_PROMPT = """
78
+ You are a helpful assistant.
79
+ """.strip()
80
+
81
+ TOOL_PROMPT = """
82
+ # Tools
83
+
84
+ You may call one or more functions to assist with the user query.
85
+
86
+ You are provided with function signatures within <tools></tools> XML tags:
87
+ <tools>
88
+ {tool_text}
89
+ </tools>
90
+ """.strip()
91
+
92
+ FORMAT_PROMPT = """
93
+ For each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:
94
+ <tool_call>
95
+ {"name": <function-name>, "arguments": <args-json-object>}
96
+ </tool_call>
97
+ """.strip()
98
+
99
+ # Define available tools
100
+ get_weather_api = {
101
+ "type": "function",
102
+ "function": {
103
+ "name": "get_weather",
104
+ "description": "Get the current weather for a location",
105
+ "parameters": {
106
+ "type": "object",
107
+ "properties": {
108
+ "location": {
109
+ "type": "str",
110
+ "description": "The city and state, e.g. San Francisco, New York",
111
+ },
112
+ "unit": {
113
+ "type": "str",
114
+ "enum": ["celsius", "fahrenheit"],
115
+ "description": "The unit of temperature to return",
116
+ },
117
+ },
118
+ "required": ["location"],
119
+ },
120
+ },
121
+ }
122
+
123
+ openai_format_tools = [get_weather_api]
124
+
125
+
126
+ def convert_tools(tools: List[Dict[str, Any]]):
127
+ return "\n".join([json.dumps(tool) for tool in tools])
128
+
129
+ # Helper function to create the system prompt for our model
130
+ def format_prompt(tools: List[Dict[str, Any]]):
131
+ tool_text = convert_tools(tools)
132
+
133
+ return (
134
+ TASK_PROMPT
135
+ + "\n\n"
136
+ + TOOL_PROMPT.format(tool_text=tool_text)
137
+ + "\n\n"
138
+ + FORMAT_PROMPT
139
+ + "\n"
140
+ )
141
+
142
+
143
+ system_prompt = format_prompt(openai_format_tools)
144
+
145
+ messages = [
146
+ {"role": "system", "content": system_prompt},
147
+ {"role": "user", "content": "What is the weather in Seattle?"},
148
+ ]
149
+
150
+ inputs = tokenizer.apply_chat_template(
151
+ messages, add_generation_prompt=True, return_tensors="pt"
152
+ ).to(model.device)
153
+
154
+ outputs = model.generate(
155
+ inputs,
156
+ max_new_tokens=512,
157
+ do_sample=False,
158
+ num_return_sequences=1,
159
+ eos_token_id=tokenizer.eos_token_id,
160
+ )
161
+
162
+ response = tokenizer.decode(outputs[0][len(inputs[0]) :], skip_special_tokens=True)
163
+ print(response)
164
+
165
+ Then you should be able to see the following output string in JSON format:
166
+
167
+ <tool_call>
168
+ {"name": "get_weather", "arguments": {"location": "Seattle"}}
169
+ </tool_call>
170
+
171
+ Multi Turn Example
172
+ -
173
+ Upon getting results from functions, you can add it to the messages list as a user message and pass it to the model to get responses for users.
174
+
175
+ # Suppose we receive the following result from the function:
176
+ get_weather_api_result = {'name': 'get_weather', 'results': {'temperature': '62°', 'unit': 'fahrenheit'}}
177
+ execution_results = [get_weather_api_result]
178
+
179
+ def add_execution_results(messages: List[Dict[str, Any]], execution_results: List[Dict[str, Any]]):
180
+ content = "\n".join([f"<tool_response>\n{json.dumps(result)}</tool_response>" for result in execution_results])
181
+ messages.append({"role": "user", "content": content})
182
+ return messages
183
+
184
+ messages = add_execution_results(messages, execution_results)
185
+
186
+ inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to(model.device)
187
+
188
+ outputs = model.generate(
189
+ inputs,
190
+ max_new_tokens=512,
191
+ do_sample=False,
192
+ num_return_sequences=1,
193
+ eos_token_id=tokenizer.eos_token_id,
194
+ )
195
+
196
+ response = tokenizer.decode(outputs[0][len(inputs[0]) :], skip_special_tokens=True)
197
+ print(response)
198
+
199
+ Then you should be able to see the following output:
200
+
201
+ The current temperature in Seattle is 62 degrees in Fahrenheit.
202
+
203
+ License
204
+ -
205
+ Katanemo Arch-Function collection is distributed under the Katanemo license.
206
+
207
+ ---
208
  ## Use with llama.cpp
209
  Install llama.cpp through brew (works on Mac and Linux)
210