Views
No views yet

| Benchmark | 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 |
1from transformers import AutoModelForCausalLM, AutoTokenizer
2import json
3from datetime import datetime
4
5device = "cuda" # the device to load the model onto
6
7model = AutoModelForCausalLM.from_pretrained("fireworks-ai/firefunction-v2", device_map="auto")
8tokenizer = AutoTokenizer.from_pretrained("fireworks-ai/firefunction-v2")
9
10function_spec = [
11 {
12 "name": "get_stock_price",
13 "description": "Get the current stock price",
14 "parameters": {
15 "type": "object",
16 "properties": {
17 "symbol": {
18 "type": "string",
19 "description": "The stock symbol, e.g. AAPL, GOOG"
20 }
21 },
22 "required": [
23 "symbol"
24 ]
25 }
26 },
27 {
28 "name": "check_word_anagram",
29 "description": "Check if two words are anagrams of each other",
30 "parameters": {
31 "type": "object",
32 "properties": {
33 "word1": {
34 "type": "string",
35 "description": "The first word"
36 },
37 "word2": {
38 "type": "string",
39 "description": "The second word"
40 }
41 },
42 "required": [
43 "word1",
44 "word2"
45 ]
46 }
47 }
48]
49functions = json.dumps(function_spec, indent=4)
50
51messages = [
52 {'role': 'system', 'content': 'You are a helpful assistant with access to functions. Use them if required.'},
53 {'role': 'user', 'content': 'Hi, can you tell me the current stock price of google and netflix?'}
54]
55
56now = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
57
58model_inputs = tokenizer.apply_chat_template(messages, functions=functions, datetime=now, return_tensors="pt").to(model.device)
59
60generated_ids = model.generate(model_inputs, max_new_tokens=128)
61decoded = tokenizer.batch_decode(generated_ids)
62print(decoded[0])