Functionary is a language model that can interpret and execute functions/plugins.
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.
Key Features
Intelligent
parallel tool use
Able to analyze functions/tools outputs and provide relevant responses
grounded in the outputs
Able to decide
when to not use tools/call functions
and provide normal chat response
Truly one of the best open-source alternative to GPT-4
Support code interpreter
How to Get Started
We provide custom code for both converting tool definitions into the system prompts and parsing raw model response into a JSON object containing
role
,
content
and
tool_calls
fields. This enables the model to be able to generate tool calls.
from transformers import AutoModelForCausalLM, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("meetkai/functionary-small-v2.5", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("meetkai/functionary-small-v2.5", device_map="auto", trust_remote_code=True)
tools = [
{
"type": "function",
"function": {
"name": "get_current_weather",
"description": "Get the current weather",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA"
}
},
"required": ["location"]
}
}
}
]
messages = [{"role": "user", "content": "What is the weather in Istanbul and Singapore respectively?"}]
final_prompt = tokenizer.apply_chat_template(messages, tools, add_generation_prompt=True, tokenize=False)
tokenizer.padding_side = "left"
inputs = tokenizer(final_prompt, return_tensors="pt").to("cuda")
pred = model.generate_tool_use(**inputs, max_new_tokens=128, tokenizer=tokenizer)
print(tokenizer.decode(pred.cpu()[0]))
Prompt Template
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.
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:
from openai import OpenAI
client = OpenAI(base_url="http://localhost:8000/v1", api_key="functionary")
client.chat.completions.create(
model="path/to/functionary/model/",
messages=[{"role": "user",
"content": "What is the weather for Istanbul?"}
],
tools=[{
"type": "function",
"function": {
"name": "get_current_weather",
"description": "Get the current weather",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA"
}
},
"required": ["location"]
}
}
}],
tool_choice="auto"
)
will yield:
<|start_header_id|>system<|end_header_id|>
// Supported function definitions that should be called when necessary.
namespace functions {
// Get the current weather
type get_current_weather = (_: {
// The city and state, e.g. San Francisco, CA
location: string,
}) => any;
} // namespace functions<|eot_id|><|start_header_id|>user<|end_header_id|>
What is the weather for Istanbul?
functionary-small-v2.5 huggingface.co is an AI model on huggingface.co that provides functionary-small-v2.5's model effect (), which can be used instantly with this meetkai functionary-small-v2.5 model. huggingface.co supports a free trial of the functionary-small-v2.5 model, and also provides paid use of the functionary-small-v2.5. Support call functionary-small-v2.5 model through api, including Node.js, Python, http.
functionary-small-v2.5 huggingface.co is an online trial and call api platform, which integrates functionary-small-v2.5's modeling effects, including api services, and provides a free online trial of functionary-small-v2.5, you can try functionary-small-v2.5 online for free by clicking the link below.
meetkai functionary-small-v2.5 online free url in huggingface.co:
functionary-small-v2.5 is an open source model from GitHub that offers a free installation service, and any user can find functionary-small-v2.5 on GitHub to install. At the same time, huggingface.co provides the effect of functionary-small-v2.5 install, users can directly use functionary-small-v2.5 installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
functionary-small-v2.5 install url in huggingface.co: