🚀 FireFunction V2: Fireworks 関数呼び出しモデル
FireFunctionは、商用利用可能なライセンスを持つ最先端の関数呼び出しモデルです。詳細情報は発表ブログでご確認ください。
Fireworksで試す | APIドキュメント | デモアプリ | Discord
主な特徴
他のモデルとの比較
- 関数呼び出し性能においてGPT - 4oと競争力があり、公開評価の総合スコアでは0.81対0.80となっています。
- Llama 3をベースに学習されており、Llama 3の会話能力と命令追従能力を保持しています。MT benchでは0.84対0.89(Llama 3)のスコアを記録しています。
- 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 |
Average |
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のライセンスを使用しています。
📦 リソース