Views
No views yet
| Models | #Parameters | Organization | License | 🧰 Function Calling? | 💬 Instrustion Following? |
|---|---|---|---|---|---|
| Breeze-7B-Instruct-v1_0 | 7B | MediaTek Research | Apache 2.0 | ❌ | ✅ |
| Breeze-7B-FC-v1_0 | 7B | MediaTek Research | Apache 2.0 | ✅ | ✅ |
| Gorilla-OpenFunctions-v2 | 7B | Gorilla LLM | Apache 2.0 | ✅ | ❌ |
| GPT-3.5-Turbo-0125 | OpenAI | Proprietary | ✅ | ✅ |
| Models | ↑ Overall | Irrelevance Detection | AST/ Simple | AST/ Multiple | AST/ Parallel | AST/ Parallel-Multiple | Exec/ Simple | Exec/ Multiple | Exec/ Parallel | Exec/ Parallel-Multiple |
|---|---|---|---|---|---|---|---|---|---|---|
| Breeze-7B-FC-v1_0 (FC) | 86.89 | 76.25 | 90.00 | 93.00 | 84.00 | 84.00 | 100.00 | 92.00 | 88.00 | 77.50 |
| Gorilla-OpenFunctions-v2 (FC) | 85.95 | 60.00 | 94.25 | 95.50 | 86.50 | 86.00 | 97.00 | 96.00 | 80.00 | 75.00 |
| GPT-3.5-Turbo-0125 (FC) | 72.77 | 4.58 | 87.75 | 90.50 | 88.50 | 82.50 | 91.00 | 82.00 | 78.00 | 52.50 |

| Models | ↑ Overall | Irrelevance Detection | AST/ Simple | AST/ Multiple | AST/ Parallel | AST/ Parallel-Multiple | Exec/ Simple | Exec/ Multiple | Exec/ Parallel | Exec/ Parallel-Multiple |
|---|---|---|---|---|---|---|---|---|---|---|
| Breeze-7B-FC-v1_0 (FC) | 78.18 | 72.50 | 82.00 | 86.00 | 76.50 | 67.00 | 88.00 | 88.00 | 80.00 | 60.00 |
| Gorilla-OpenFunctions-v2 (FC) | 75.68 | 53.75 | 84.75 | 86.50 | 72.50 | 68.00 | 92.00 | 92.00 | 62.00 | 72.50 |
| GPT-3.5-Turbo-0125 (FC) | 66.15 | 7.50 | 83.75 | 83.50 | 73.00 | 65.50 | 88.00 | 84.00 | 72.00 | 40.00 |

| Win | Tie | Lose | |
|---|---|---|---|
| Breeze-7B-FC-v1_0 v.s. Breeze-7B-Instruct-v1_0 | 29 (18.1%) | 55 (34.3%) | 76 (47.5%) |
| Win | Tie | Lose | |
|---|---|---|---|
| Breeze-7B-FC-v1_0 v.s. Breeze-7B-Instruct-v1_0 | 35 (21.9%) | 73 (45.6%) | 52 (32.5%) |
mtkresearch packagepip install mtkresearch1from vllm import LLM, SamplingParams
2
3llm = LLM(
4 model='MediaTek-Research/Breeze-7B-FC-v1_0',
5 tensor_parallel_size=num_gpu, # number of gpus
6 gpu_memory_utilization=0.7,
7 dtype='half'
8)
9
10turn_end_token_id = 61876 # <|im_end|>
11params = SamplingParams(
12 temperature=0.01,
13 top_p=0.01,
14 max_tokens=4096,
15 repetition_penalty=1.1,
16 stop_token_ids=[turn_end_token_id]
17)
18
19def _inference(prompt, llm, params):
20 return llm.generate(prompt, params)[0].outputs[0].text
211from mtkresearch.llm.prompt import MRPromptV2
2
3sys_prompt = ('You are a helpful AI assistant built by MediaTek Research. '
4 'The user you are helping speaks Traditional Chinese and comes from Taiwan.')
5
6prompt_engine = MRPromptV2()
7
8conversations = [
9 {"role": "system", "content": sys_prompt},
10 {"role": "user", "content": "請問什麼是深度學習?"},
11]
12
13prompt = prompt_engine.get_prompt(conversations)
14
15
16output_str = _inference(prompt, llm, params)
17result = prompt_engine.parse_generated_str(output_str)
18
19print(result)
20# {'role': 'assistant',
21# 'content': '深度學習(Deep Learning)是一種機器學習方法,它模仿人類大腦的神經網路結構來
22# 處理複雜的數據和任務。在深度學習中,模型由多層人工神經元組成,每個神經元之間有
23# 權重連接,並通過非線性轉換進行計算。這些層與層之間的相互作用使模型能夠學習複雜
24# 的函數關係或模式,從而解決各種問題,如圖像識別、自然語言理解、語音辨識等。深度
25# 學習通常需要大量的數據和強大的計算能力,因此經常使用圖形處理器(GPU)或特殊的
26# 加速器來執行。'}1import json
2
3from mtkresearch.llm.prompt import MRPromptV2
4
5functions = [
6 {
7 "name": "get_current_weather",
8 "description": "Get the current weather in a given location",
9 "parameters": {
10 "type": "object",
11 "properties": {
12 "location": {
13 "type": "string",
14 "description": "The city and state, e.g. San Francisco, CA"
15 },
16 "unit": {
17 "type": "string",
18 "enum": ["celsius", "fahrenheit"]
19 }
20 },
21 "required": ["location"]
22 }
23 }
24]
25
26def fake_get_current_weather(location, unit=None):
27 return {'temperature': 30}
28
29mapping = {
30 'get_current_weather': fake_get_current_weather
31}
32
33prompt_engine = MRPromptV2()
34
35# stage 1: query
36conversations = [
37 {"role": "user", "content": "請問台北目前溫度是攝氏幾度?"},
38]
39
40prompt = prompt_engine.get_prompt(conversations, functions=functions)
41
42output_str = _inference(prompt, llm, params)
43result = prompt_engine.parse_generated_str(output_str)
44
45print(result)
46# {'role': 'assistant',
47# 'tool_calls': [
48# {'id': 'call_U9bYCBRAbF639uUqfwehwSbw', 'type': 'function',
49# 'function': {'name': 'get_current_weather', 'arguments': '{"location": "台北, 台灣", "unit": "celsius"}'}}]}
50
51# stage 2: execute called functions
52conversations.append(result)
53
54tool_call = result['tool_calls'][0]
55func_name = tool_call['function']['name']
56func = mapping[func_name]
57arguments = json.loads(tool_call['function']['arguments'])
58called_result = func(**arguments)
59
60# stage 3: put executed results
61conversations.append(
62 {
63 'role': 'tool',
64 'tool_call_id': tool_call['id'],
65 'name': func_name,
66 'content': json.dumps(called_result)
67 }
68)
69
70prompt = prompt_engine.get_prompt(conversations, functions=functions)
71
72output_str2 = _inference(prompt, llm, params)
73result2 = prompt_engine.parse_generated_str(output_str2)
74print(result2)
75# {'role': 'assistant', 'content': '台北目前的溫度是攝氏30度'}@article{chen2024enhancing,
title={Enhancing Function-Calling Capabilities in LLMs: Strategies for Prompt Formats, Data Integration, and Multilingual Translation},
author={Chen, Yi-Chang and Hsu, Po-Chun and Hsu, Chan-Jan and Shiu, Da-shan},
journal={arXiv preprint arXiv:2412.01130},
year={2024},
url={https://arxiv.org/abs/2412.01130}
}