🚀 FireFunction V2:Fireworks函數調用模型
FireFunction是一款先進的函數調用模型,擁有商業可行的許可證。它能夠在多種函數調用場景中表現出色,為用戶提供高效、準確的服務。
在Fireworks上試用 | API文檔 | 演示應用 | Discord社區
✨ 主要特性
與其他模型對比
- 函數調用能力:在函數調用方面可與GPT - 4o相媲美,在一系列公開評估中得分0.81,而GPT - 4o為0.80。
- 對話和指令遵循能力:基於Llama 3進行訓練,保留了Llama 3的對話和指令遵循能力,在MT bench測試中得分0.84,而Llama 3為0.89。
- 質量提升:相較於FireFunction v1,在廣泛的指標上有顯著的質量提升。
通用信息
- 迭代升級:是FireFunction模型的繼任者。
- 功能增強:支持並行函數調用(與FireFunction v1不同),並且指令遵循能力出色。
- 成本與速度優勢:託管在Fireworks平臺上,成本不到GPT 4o的10%,速度是其2倍。
📚 詳細文檔
預期用途和限制
支持的用例
該模型經過調優,在一系列用例中表現出色,包括:
- 通用指令遵循
- 混合普通消息和函數調用的多輪聊天
- 單函數和並行函數調用
- 一次支持多達20個函數規範
- 結構化信息提取
該模型與Llama 3一樣,具有8k的上下文窗口。
不適用的用例
該模型未針對以下用例進行優化:
性能指標
基準測試 |
Firefunction v1 |
Firefunction v2 |
Llama 3 70b Instruct |
Gpt - 4o |
Gorilla simple |
0.91 |
0.94 |
0.925 |
0.88 |
Gorilla multiple_function |
0.92 |
0.91 |
0.86 |
0.91 |
Gorilla parallel_function |
0 |
0.9 |
0.86 |
0.89 |
Gorilla parallel_multiple_function |
0 |
0.8 |
0.615 |
0.72 |
Nexus parallel |
0.38 |
0.53 |
0.3 |
0.47 |
Mtbench |
0.73 |
0.84 |
0.89 |
0.93 |
平均值 |
0.49 |
0.82 |
0.74 |
0.8 |
💻 使用示例
基礎用法
from transformers import AutoModelForCausalLM, AutoTokenizer
import json
from datetime import datetime
device = "cuda"
model = AutoModelForCausalLM.from_pretrained("fireworks-ai/firefunction-v2", device_map="auto")
tokenizer = AutoTokenizer.from_pretrained("fireworks-ai/firefunction-v2")
function_spec = [
{
"name": "get_stock_price",
"description": "Get the current stock price",
"parameters": {
"type": "object",
"properties": {
"symbol": {
"type": "string",
"description": "The stock symbol, e.g. AAPL, GOOG"
}
},
"required": [
"symbol"
]
}
},
{
"name": "check_word_anagram",
"description": "Check if two words are anagrams of each other",
"parameters": {
"type": "object",
"properties": {
"word1": {
"type": "string",
"description": "The first word"
},
"word2": {
"type": "string",
"description": "The second word"
}
},
"required": [
"word1",
"word2"
]
}
}
]
functions = json.dumps(function_spec, indent=4)
messages = [
{'role': 'system', 'content': 'You are a helpful assistant with access to functions. Use them if required.'},
{'role': 'user', 'content': 'Hi, can you tell me the current stock price of google and netflix?'}
]
now = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
model_inputs = tokenizer.apply_chat_template(messages, functions=functions, datetime=now, return_tensors="pt").to(model.device)
generated_ids = model.generate(model_inputs, max_new_tokens=128)
decoded = tokenizer.batch_decode(generated_ids)
print(decoded[0])
📄 許可證
本項目使用Llama 3許可證。
📦 資源鏈接