Triangle104 commited on
Commit
229d2b5
1 Parent(s): e204a54

Update README.md

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