Views
No views yet
| Name | Quant method | Bits | Size | Use case |
|---|---|---|---|---|
| Breeze-7B-FC-v1_0-q4_0.gguf | Q4_0 | 4 | 4.3 GB | medium quality |
| Breeze-7B-FC-v1_0-q4_k_m.gguf | Q4_K_M | 4 | 4.54 GB | medium, balanced quality - recommended |
| Breeze-7B-FC-v1_0-q5_0.gguf | Q5_0 | 5 | 5.2 GB | large, low quality loss - recommended |
| Breeze-7B-FC-v1_0-q5_1.gguf | Q5_1 | 5 | 5.6 GB | large, very low quality loss - recommended |
| Breeze-7B-FC-v1_0-q5_k_m.gguf | Q5_K_M | 5 | 5.32 GB | large, very low quality loss - recommended |
| Breeze-7B-FC-v1_0-q6_k.gguf | Q6_K | 6 | 6.11 GB | very large, extremely low quality loss |
| Breeze-7B-FC-v1_0-q8_0.gguf | Q8_0 | 8 | 8.0 GB | very large, nearly no quality loss |
# Base ctransformers with no GPU acceleration
pip install ctransformers
# Or with CUDA GPU acceleration
pip install ctransformers[cuda]
# Or with AMD ROCm GPU acceleration (Linux only)
CT_HIPBLAS=1 pip install ctransformers --no-binary ctransformers
# Or with Metal GPU acceleration for macOS systems only
CT_METAL=1 pip install ctransformers --no-binary ctransformers1from ctransformers import AutoModelForCausalLM
2
3# Set gpu_layers to the number of layers to offload to GPU. Set to 0 if no GPU acceleration is available on your system.
4llm = AutoModelForCausalLM.from_pretrained(
5 "yuuko-eth/Breeze-7B-FC-v1_0-GGUF",
6 model_file="Breeze-7B-FC-v1_0-q6_k.gguf",
7 model_type="mistral",
8 context_length=8192,
9 gpu_layers=99)
10
11from transformers import AutoTokenizer
12tokenizer = AutoTokenizer.from_pretrained("MediaTek-Research/Breeze-7B-Instruct-v1_0")
13
14gen_kwargs = dict(
15 max_new_tokens=1024,
16 repetition_penalty=1.1,
17 stop=["[INST]"],
18 temperature=0.0,
19 top_p=0.0,
20 top_k=1,
21)
22
23chat = [
24 {"role": "system", "content": "You are a helpful AI assistant built by MediaTek Research. The user you are helping speaks Traditional Chinese and comes from Taiwan."},
25 {"role": "user", "content": "請介紹五樣台灣小吃"}
26]
27for text in llm(tokenizer.apply_chat_template(chat, tokenize=False), stream=True, **gen_kwargs):
28 print(text, end="", flush=True)
29
30# 以下推薦五樣台灣的小吃:
31#
32# 1. 蚵仔煎 (Oyster omelette) - 蚵仔煎是一種以蛋、麵皮和蚵仔為主要食材的傳統美食。它通常在油鍋中煎至金黃色,外酥內嫩,並帶有一股獨特的香氣。蚵仔煎是一道非常受歡迎的小吃,經常可以在夜市或小吃店找到。
33# 2. 牛肉麵 (Beef noodle soup) - 牛肉麵是台灣的經典美食之一,它以軟嫩的牛肉和濃郁的湯頭聞名。不同地區的牛肉麵可能有不同的口味和配料,但通常都會包含麵條、牛肉、蔬菜和調味料。牛肉麵在全台灣都有不少知名店家,例如林東芳牛肉麵、牛大哥牛肉麵等。
34# 3. 鹹酥雞 (Fried chicken) - 鹹酥雞是一種以雞肉為主要食材的快餐。它通常會經過油炸處理,然後搭配多種蔬菜和調味料。鹹酥雞的口味因地區而異,但通常都會有辣、甜、鹹等不同風味。鹹酥雞經常可以在夜市或路邊攤找到,例如鼎王鹹酥雞、鹹酥G去等知名店家。
35# 4. 珍珠奶茶 (Bubble tea) - 珍珠奶茶是一種以紅茶為基底的飲品,加入珍珠(Q彈的小湯圓)和鮮奶。它起源於台灣,並迅速成為全球流行的飲料。珍珠奶茶在全台灣都有不少知名品牌,例如茶湯會、五桐號等。
36# 5. 臭豆腐 (Stinky tofu) - 臭豆腐是一種以發酵豆腐為原料製作的傳統小吃。它具有強烈的氣味,但味道獨特且深受台灣人喜愛。臭豆腐通常會搭配多種調味料和配料,例如辣椒醬、蒜泥、酸菜等。臭豆腐在全台灣都有不少知名店家,例如阿宗麵線、大勇街臭豆腐等。1from 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度'}llama.cpp server: