MediaTek-Research/Breeze-7B-FC-v1_0

Model

Model Card for MediaTek Research Breeze-7B-FC-v1_0

21

59 commits

4 linked in READMEs

updated Jan 15, 2025

See the code

README

Model Card for MediaTek Research Breeze-7B-FC-v1_0

MediaTek Research Breeze-7B-FC (hereinafter referred to as Breeze-7B-FC) is an advanced language model developed by MediaTek Research, building on Breeze-7B-Base. Breeze-7B-FC extends its predecessor by incorporating a key feature: function calling. These enhancements make Breeze-7B-FC more versatile and capable of handling a wider range of tasks efficiently.

🏆 Performance

Models#ParametersOrganizationLicense🧰 Function Calling?💬 Instrustion Following?
Breeze-7B-Instruct-v1_07BMediaTek ResearchApache 2.0❌✅
Breeze-7B-FC-v1_07BMediaTek ResearchApache 2.0✅✅
Gorilla-OpenFunctions-v27BGorilla LLMApache 2.0✅❌
GPT-3.5-Turbo-0125OpenAIProprietary✅✅

Evaluate function calling on EN benchmark

We evaluate the performance of function calling on English with benchmark Berkeley function-calling leaderboard.

Models↑ OverallIrrelevance
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.8976.2590.0093.0084.0084.00100.0092.0088.0077.50
Gorilla-OpenFunctions-v2 (FC)85.9560.0094.2595.5086.5086.0097.0096.0080.0075.00
GPT-3.5-Turbo-0125 (FC)72.774.5887.7590.5088.5082.5091.0082.0078.0052.50

Evaluate function calling on ZHTW benchmark

We evaluate the performance of function calling on Traditional Chinese with benchmark function-calling-leaderboard-for-zhtw.

Models↑ OverallIrrelevance
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.1872.5082.0086.0076.5067.0088.0088.0080.0060.00
Gorilla-OpenFunctions-v2 (FC)75.6853.7584.7586.5072.5068.0092.0092.0062.0072.50
GPT-3.5-Turbo-0125 (FC)66.157.5083.7583.5073.0065.5088.0084.0072.0040.00

Evaluate instrustion following on EN benchmark

We evaluate the performance of instruction following on English with benchmark MT-Bench.

WinTieLose
Breeze-7B-FC-v1_0 v.s. Breeze-7B-Instruct-v1_029 (18.1%)55 (34.3%)76 (47.5%)

Evaluate instrustion following on ZHTW benchmark

We evaluate the performance of instruction following on Traditional Chinese with benchmark MT-Bench-TC.

WinTieLose
Breeze-7B-FC-v1_0 v.s. Breeze-7B-Instruct-v1_035 (21.9%)73 (45.6%)52 (32.5%)

👩‍💻 How to use

Demo with Kaggle Kernel

Start from clicking the "Copy & Edit" button on https://www.kaggle.com/code/ycckaggle/run-breeze-fc

Dependiency

Install mtkresearch package

pip install mtkresearch

Hosting the model by VLLM

from vllm import LLM, SamplingParams

llm = LLM(
    model='MediaTek-Research/Breeze-7B-FC-v1_0',
    tensor_parallel_size=num_gpu, # number of gpus
    gpu_memory_utilization=0.7,
    dtype='half'
)

turn_end_token_id = 61876 # <|im_end|>
params = SamplingParams(
    temperature=0.01,
    top_p=0.01,
    max_tokens=4096,
    repetition_penalty=1.1,
    stop_token_ids=[turn_end_token_id]
)

def _inference(prompt, llm, params):
    return llm.generate(prompt, params)[0].outputs[0].text

Instruction following

from mtkresearch.llm.prompt import MRPromptV2

sys_prompt = ('You are a helpful AI assistant built by MediaTek Research. '
  'The user you are helping speaks Traditional Chinese and comes from Taiwan.')

prompt_engine = MRPromptV2()

conversations = [
    {"role": "system", "content": sys_prompt},
    {"role": "user", "content": "請問什麼是深度學習?"},
]

prompt = prompt_engine.get_prompt(conversations)


output_str = _inference(prompt, llm, params)
result = prompt_engine.parse_generated_str(output_str)

print(result)
# {'role': 'assistant',
#  'content': '深度學習(Deep Learning)是一種機器學習方法,它模仿人類大腦的神經網路結構來
#              處理複雜的數據和任務。在深度學習中,模型由多層人工神經元組成,每個神經元之間有
#              權重連接,並通過非線性轉換進行計算。這些層與層之間的相互作用使模型能夠學習複雜
#              的函數關係或模式,從而解決各種問題,如圖像識別、自然語言理解、語音辨識等。深度
#              學習通常需要大量的數據和強大的計算能力,因此經常使用圖形處理器(GPU)或特殊的
#              加速器來執行。'}

Function Calling

import json

from mtkresearch.llm.prompt import MRPromptV2

functions = [
    {
      "name": "get_current_weather",
      "description": "Get the current weather in a given location",
      "parameters": {
        "type": "object",
        "properties": {
          "location": {
            "type": "string",
            "description": "The city and state, e.g. San Francisco, CA"
          },
          "unit": {
            "type": "string",
            "enum": ["celsius", "fahrenheit"]
          }
        },
        "required": ["location"]
      }
    }
]

def fake_get_current_weather(location, unit=None):
    return {'temperature': 30}

mapping = {
    'get_current_weather': fake_get_current_weather
}

prompt_engine = MRPromptV2()

# stage 1: query
conversations = [
    {"role": "user", "content": "請問台北目前溫度是攝氏幾度?"},
]

prompt = prompt_engine.get_prompt(conversations, functions=functions)

output_str = _inference(prompt, llm, params)
result = prompt_engine.parse_generated_str(output_str)

print(result) 
# {'role': 'assistant', 
#  'tool_calls': [
#    {'id': 'call_U9bYCBRAbF639uUqfwehwSbw', 'type': 'function', 
#     'function': {'name': 'get_current_weather', 'arguments': '{"location": "台北, 台灣", "unit": "celsius"}'}}]}

# stage 2: execute called functions
conversations.append(result)

tool_call = result['tool_calls'][0]
func_name = tool_call['function']['name']
func = mapping[func_name]
arguments = json.loads(tool_call['function']['arguments'])
called_result = func(**arguments)

# stage 3: put executed results
conversations.append(
    {
        'role': 'tool',
        'tool_call_id': tool_call['id'],
        'name': func_name,
        'content': json.dumps(called_result)
    }
)

prompt = prompt_engine.get_prompt(conversations, functions=functions)

output_str2 = _inference(prompt, llm, params)
result2 = prompt_engine.parse_generated_str(output_str2)
print(result2)
# {'role': 'assistant', 'content': '台北目前的溫度是攝氏30度'}

Citation

If you find this work is useful, please cite it with:

@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}
}
mistral
pytorch

MediaTek-Research/Breeze-7B-FC-v1_0

Model

Model Card for MediaTek Research Breeze-7B-FC-v1_0

21

59 commits

4 linked in READMEs

updated Jan 15, 2025

See the code

README

Model Card for MediaTek Research Breeze-7B-FC-v1_0

MediaTek Research Breeze-7B-FC (hereinafter referred to as Breeze-7B-FC) is an advanced language model developed by MediaTek Research, building on Breeze-7B-Base. Breeze-7B-FC extends its predecessor by incorporating a key feature: function calling. These enhancements make Breeze-7B-FC more versatile and capable of handling a wider range of tasks efficiently.

🏆 Performance

Models#ParametersOrganizationLicense🧰 Function Calling?💬 Instrustion Following?
Breeze-7B-Instruct-v1_07BMediaTek ResearchApache 2.0❌✅
Breeze-7B-FC-v1_07BMediaTek ResearchApache 2.0✅✅
Gorilla-OpenFunctions-v27BGorilla LLMApache 2.0✅❌
GPT-3.5-Turbo-0125OpenAIProprietary✅✅

Evaluate function calling on EN benchmark

We evaluate the performance of function calling on English with benchmark Berkeley function-calling leaderboard.

Models↑ OverallIrrelevance
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.8976.2590.0093.0084.0084.00100.0092.0088.0077.50
Gorilla-OpenFunctions-v2 (FC)85.9560.0094.2595.5086.5086.0097.0096.0080.0075.00
GPT-3.5-Turbo-0125 (FC)72.774.5887.7590.5088.5082.5091.0082.0078.0052.50

Evaluate function calling on ZHTW benchmark

We evaluate the performance of function calling on Traditional Chinese with benchmark function-calling-leaderboard-for-zhtw.

Models↑ OverallIrrelevance
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.1872.5082.0086.0076.5067.0088.0088.0080.0060.00
Gorilla-OpenFunctions-v2 (FC)75.6853.7584.7586.5072.5068.0092.0092.0062.0072.50
GPT-3.5-Turbo-0125 (FC)66.157.5083.7583.5073.0065.5088.0084.0072.0040.00

Evaluate instrustion following on EN benchmark

We evaluate the performance of instruction following on English with benchmark MT-Bench.

WinTieLose
Breeze-7B-FC-v1_0 v.s. Breeze-7B-Instruct-v1_029 (18.1%)55 (34.3%)76 (47.5%)

Evaluate instrustion following on ZHTW benchmark

We evaluate the performance of instruction following on Traditional Chinese with benchmark MT-Bench-TC.

WinTieLose
Breeze-7B-FC-v1_0 v.s. Breeze-7B-Instruct-v1_035 (21.9%)73 (45.6%)52 (32.5%)

👩‍💻 How to use

Demo with Kaggle Kernel

Start from clicking the "Copy & Edit" button on https://www.kaggle.com/code/ycckaggle/run-breeze-fc

Dependiency

Install mtkresearch package

pip install mtkresearch

Hosting the model by VLLM

from vllm import LLM, SamplingParams

llm = LLM(
    model='MediaTek-Research/Breeze-7B-FC-v1_0',
    tensor_parallel_size=num_gpu, # number of gpus
    gpu_memory_utilization=0.7,
    dtype='half'
)

turn_end_token_id = 61876 # <|im_end|>
params = SamplingParams(
    temperature=0.01,
    top_p=0.01,
    max_tokens=4096,
    repetition_penalty=1.1,
    stop_token_ids=[turn_end_token_id]
)

def _inference(prompt, llm, params):
    return llm.generate(prompt, params)[0].outputs[0].text

Instruction following

from mtkresearch.llm.prompt import MRPromptV2

sys_prompt = ('You are a helpful AI assistant built by MediaTek Research. '
  'The user you are helping speaks Traditional Chinese and comes from Taiwan.')

prompt_engine = MRPromptV2()

conversations = [
    {"role": "system", "content": sys_prompt},
    {"role": "user", "content": "請問什麼是深度學習?"},
]

prompt = prompt_engine.get_prompt(conversations)


output_str = _inference(prompt, llm, params)
result = prompt_engine.parse_generated_str(output_str)

print(result)
# {'role': 'assistant',
#  'content': '深度學習(Deep Learning)是一種機器學習方法,它模仿人類大腦的神經網路結構來
#              處理複雜的數據和任務。在深度學習中,模型由多層人工神經元組成,每個神經元之間有
#              權重連接,並通過非線性轉換進行計算。這些層與層之間的相互作用使模型能夠學習複雜
#              的函數關係或模式,從而解決各種問題,如圖像識別、自然語言理解、語音辨識等。深度
#              學習通常需要大量的數據和強大的計算能力,因此經常使用圖形處理器(GPU)或特殊的
#              加速器來執行。'}

Function Calling

import json

from mtkresearch.llm.prompt import MRPromptV2

functions = [
    {
      "name": "get_current_weather",
      "description": "Get the current weather in a given location",
      "parameters": {
        "type": "object",
        "properties": {
          "location": {
            "type": "string",
            "description": "The city and state, e.g. San Francisco, CA"
          },
          "unit": {
            "type": "string",
            "enum": ["celsius", "fahrenheit"]
          }
        },
        "required": ["location"]
      }
    }
]

def fake_get_current_weather(location, unit=None):
    return {'temperature': 30}

mapping = {
    'get_current_weather': fake_get_current_weather
}

prompt_engine = MRPromptV2()

# stage 1: query
conversations = [
    {"role": "user", "content": "請問台北目前溫度是攝氏幾度?"},
]

prompt = prompt_engine.get_prompt(conversations, functions=functions)

output_str = _inference(prompt, llm, params)
result = prompt_engine.parse_generated_str(output_str)

print(result) 
# {'role': 'assistant', 
#  'tool_calls': [
#    {'id': 'call_U9bYCBRAbF639uUqfwehwSbw', 'type': 'function', 
#     'function': {'name': 'get_current_weather', 'arguments': '{"location": "台北, 台灣", "unit": "celsius"}'}}]}

# stage 2: execute called functions
conversations.append(result)

tool_call = result['tool_calls'][0]
func_name = tool_call['function']['name']
func = mapping[func_name]
arguments = json.loads(tool_call['function']['arguments'])
called_result = func(**arguments)

# stage 3: put executed results
conversations.append(
    {
        'role': 'tool',
        'tool_call_id': tool_call['id'],
        'name': func_name,
        'content': json.dumps(called_result)
    }
)

prompt = prompt_engine.get_prompt(conversations, functions=functions)

output_str2 = _inference(prompt, llm, params)
result2 = prompt_engine.parse_generated_str(output_str2)
print(result2)
# {'role': 'assistant', 'content': '台北目前的溫度是攝氏30度'}

Citation

If you find this work is useful, please cite it with:

@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}
}
mistral
pytorch