File size: 9,253 Bytes
50bf950 f855da9 50bf950 f855da9 50bf950 1414999 50bf950 |
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 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 |
---
license: other
license_name: katanemo-research
license_link: https://huggingface.co/katanemo/Arch-Function-3B/blob/main/LICENSE
base_model: katanemo/Arch-Function-3B
language:
- en
pipeline_tag: text-generation
library_name: transformers
tags:
- llama-cpp
- gguf-my-repo
---
# Triangle104/Arch-Function-3B-Q5_K_S-GGUF
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.
Refer to the [original model card](https://huggingface.co/katanemo/Arch-Function-3B) for more details on the model.
---
Model details:
-
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.
In summary, the Katanemo Arch-Function collection demonstrates:
State-of-the-art performance in function calling
Accurate parameter identification and suggestion, even in ambiguous or incomplete inputs
High generalization across multiple function calling use cases, from API interactions to automated backend tasks.
Optimized low-latency, high-throughput performance, making it suitable for real-time, production environments.
Arch-Function is the core LLM used in then open source Arch Gateway to seamlessly integrate user prompts with developers APIs
Key Features
Functionality Definition
Single Function Calling Call only one function per user query
Parallel Function Calling Call the same function multiple times but with different set of parameter values
Multiple Function Calling Call different functions per user query
Parallel & Multiple Perform both parallel and multiple function calling
Training Details
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.
Performance Benchmarks
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:
Rank Model Overall Single Turn Multi Turn Hallucination
Non-live (AST) Non-live (Exec) Live (AST) Overall Relevance Irrelevance
1 GPT-4-turbo-2024-04-09 59.49% 82.65% 83.80% 73.39% 21.62% 70.73% 79.79%
3 xLAM-8x22b-r 59.13% 89.75% 89.32% 72.81% 15.62% 97.56% 75.23%
Arch-Function-7B 57.48% 87.50% 86.80% 72.19% 13.75% 82.93% 79.54%
Arch-Function-3B 56.23% 85.10% 89.16% 70.72% 12.28% 90.24% 73.98%
7 mistral-large-2407 55.82% 84.12% 83.09% 67.17% 20.50% 78.05% 48.93%
9 Claude-3.5-Sonnet-20240620 54.83% 70.35% 66.34% 71.39% 23.5% 63.41% 75.91%
Arch-Function-1.5B 53.61% 82.60% 87.36% 68.19% 8.62% 87.80% 75.90%
11 o1-mini-2024-09-12 53.43% 75.48% 76.86% 71.17% 11.00% 46.34% 88.07%
12 Gemini-1.5-Flash-Preview-0514 53.01% 77.10% 71.23% 71.17% 13.12% 60.98% 76.15%
Requirements
The code of Arch-Function-3B has been in the Hugging Face transformers library and we advise you to install latest version:
pip install transformers>=4.37.0
How to use
-
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.
Single Turn Example
import json
from typing import Any, Dict, List
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "katanemo/Arch-Function-3B"
model = AutoModelForCausalLM.from_pretrained(
model_name, device_map="auto", torch_dtype="auto", trust_remote_code=True
)
tokenizer = AutoTokenizer.from_pretrained(model_name)
# Please use our provided prompt for best performance
TASK_PROMPT = """
You are a helpful assistant.
""".strip()
TOOL_PROMPT = """
# Tools
You may call one or more functions to assist with the user query.
You are provided with function signatures within <tools></tools> XML tags:
<tools>
{tool_text}
</tools>
""".strip()
FORMAT_PROMPT = """
For each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:
<tool_call>
{"name": <function-name>, "arguments": <args-json-object>}
</tool_call>
""".strip()
# Define available tools
get_weather_api = {
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather for a location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "str",
"description": "The city and state, e.g. San Francisco, New York",
},
"unit": {
"type": "str",
"enum": ["celsius", "fahrenheit"],
"description": "The unit of temperature to return",
},
},
"required": ["location"],
},
},
}
openai_format_tools = [get_weather_api]
def convert_tools(tools: List[Dict[str, Any]]):
return "\n".join([json.dumps(tool) for tool in tools])
# Helper function to create the system prompt for our model
def format_prompt(tools: List[Dict[str, Any]]):
tool_text = convert_tools(tools)
return (
TASK_PROMPT
+ "\n\n"
+ TOOL_PROMPT.format(tool_text=tool_text)
+ "\n\n"
+ FORMAT_PROMPT
+ "\n"
)
system_prompt = format_prompt(openai_format_tools)
messages = [
{"role": "system", "content": system_prompt},
{"role": "user", "content": "What is the weather in Seattle?"},
]
inputs = tokenizer.apply_chat_template(
messages, add_generation_prompt=True, return_tensors="pt"
).to(model.device)
outputs = model.generate(
inputs,
max_new_tokens=512,
do_sample=False,
num_return_sequences=1,
eos_token_id=tokenizer.eos_token_id,
)
response = tokenizer.decode(outputs[0][len(inputs[0]) :], skip_special_tokens=True)
print(response)
Then you should be able to see the following output string in JSON format:
<tool_call>
{"name": "get_weather", "arguments": {"location": "Seattle"}}
</tool_call>
Multi Turn Example
-
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.
# Suppose we receive the following result from the function:
get_weather_api_result = {'name': 'get_weather', 'results': {'temperature': '62°', 'unit': 'fahrenheit'}}
execution_results = [get_weather_api_result]
def add_execution_results(messages: List[Dict[str, Any]], execution_results: List[Dict[str, Any]]):
content = "\n".join([f"<tool_response>\n{json.dumps(result)}</tool_response>" for result in execution_results])
messages.append({"role": "user", "content": content})
return messages
messages = add_execution_results(messages, execution_results)
inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to(model.device)
outputs = model.generate(
inputs,
max_new_tokens=512,
do_sample=False,
num_return_sequences=1,
eos_token_id=tokenizer.eos_token_id,
)
response = tokenizer.decode(outputs[0][len(inputs[0]) :], skip_special_tokens=True)
print(response)
Then you should be able to see the following output:
The current temperature in Seattle is 62 degrees in Fahrenheit.
License
-
Katanemo Arch-Function collection is distributed under the Katanemo license.
---
## Use with llama.cpp
Install llama.cpp through brew (works on Mac and Linux)
```bash
brew install llama.cpp
```
Invoke the llama.cpp server or the CLI.
### CLI:
```bash
llama-cli --hf-repo Triangle104/Arch-Function-3B-Q5_K_S-GGUF --hf-file arch-function-3b-q5_k_s.gguf -p "The meaning to life and the universe is"
```
### Server:
```bash
llama-server --hf-repo Triangle104/Arch-Function-3B-Q5_K_S-GGUF --hf-file arch-function-3b-q5_k_s.gguf -c 2048
```
Note: You can also use this checkpoint directly through the [usage steps](https://github.com/ggerganov/llama.cpp?tab=readme-ov-file#usage) listed in the Llama.cpp repo as well.
Step 1: Clone llama.cpp from GitHub.
```
git clone https://github.com/ggerganov/llama.cpp
```
Step 2: Move into the llama.cpp folder and build it with `LLAMA_CURL=1` flag along with other hardware-specific flags (for ex: LLAMA_CUDA=1 for Nvidia GPUs on Linux).
```
cd llama.cpp && LLAMA_CURL=1 make
```
Step 3: Run inference through the main binary.
```
./llama-cli --hf-repo Triangle104/Arch-Function-3B-Q5_K_S-GGUF --hf-file arch-function-3b-q5_k_s.gguf -p "The meaning to life and the universe is"
```
or
```
./llama-server --hf-repo Triangle104/Arch-Function-3B-Q5_K_S-GGUF --hf-file arch-function-3b-q5_k_s.gguf -c 2048
```
|