🚀 Granite-4.0-Tiny-Preview
Granite-4.0-Tiny-Preview是一個擁有70億參數的細粒度混合專家模型(MoE)指令模型。它基於Granite-4.0-Tiny-Base-Preview進行微調,結合了具有寬鬆許可的開源指令數據集和針對解決長上下文問題定製的內部收集合成數據集。該模型採用了多種技術進行開發,具備結構化的對話格式,包括監督微調以及使用強化學習進行模型對齊。
🚀 快速開始
要使用此檢查點,你需要從源代碼安裝transformers
庫。
安裝完成後,複製以下代碼片段來運行示例:
from transformers import AutoModelForCausalLM, AutoTokenizer, set_seed
import torch
model_path="ibm-granite/granite-4.0-tiny-preview"
device="cuda"
model = AutoModelForCausalLM.from_pretrained(
model_path,
device_map=device,
torch_dtype=torch.bfloat16,
)
tokenizer = AutoTokenizer.from_pretrained(
model_path
)
conv = [{"role": "user", "content":"You have 10 liters of a 30% acid solution. How many liters of a 70% acid solution must be added to achieve a 50% acid mixture?"}]
input_ids = tokenizer.apply_chat_template(conv, return_tensors="pt", thinking=True, return_dict=True, add_generation_prompt=True).to(device)
set_seed(42)
output = model.generate(
**input_ids,
max_new_tokens=8192,
)
prediction = tokenizer.decode(output[0, input_ids["input_ids"].shape[1]:], skip_special_tokens=True)
print(prediction)
✨ 主要特性
- 多語言支持:支持英語、德語、西班牙語、法語、日語、葡萄牙語、阿拉伯語、捷克語、意大利語、韓語、荷蘭語和中文。用戶還可以針對這12種語言之外的語言對該模型進行微調。
- 廣泛的任務處理能力:能夠處理一般的指令跟隨任務,可集成到各個領域的AI助手,包括商業應用。具備思考、總結、文本分類、文本提取、問答、檢索增強生成(RAG)、代碼相關任務、函數調用任務、多語言對話用例以及長上下文任務(如長文檔/會議總結、長文檔問答等)能力。
📦 安裝指南
你需要從源代碼安裝transformers
庫來使用此檢查點。
💻 使用示例
基礎用法
from transformers import AutoModelForCausalLM, AutoTokenizer, set_seed
import torch
model_path="ibm-granite/granite-4.0-tiny-preview"
device="cuda"
model = AutoModelForCausalLM.from_pretrained(
model_path,
device_map=device,
torch_dtype=torch.bfloat16,
)
tokenizer = AutoTokenizer.from_pretrained(
model_path
)
conv = [{"role": "user", "content":"You have 10 liters of a 30% acid solution. How many liters of a 70% acid solution must be added to achieve a 50% acid mixture?"}]
input_ids = tokenizer.apply_chat_template(conv, return_tensors="pt", thinking=True, return_dict=True, add_generation_prompt=True).to(device)
set_seed(42)
output = model.generate(
**input_ids,
max_new_tokens=8192,
)
prediction = tokenizer.decode(output[0, input_ids["input_ids"].shape[1]:], skip_special_tokens=True)
print(prediction)
📚 詳細文檔
評估結果
模型 |
Arena-Hard |
AlpacaEval-2.0 |
MMLU |
PopQA |
TruthfulQA |
BigBenchHard |
DROP |
GSM8K |
HumanEval |
HumanEval+ |
IFEval |
AttaQ |
Granite-3.3-2B-Instruct |
28.86 |
43.45 |
55.88 |
18.4 |
58.97 |
52.51 |
35.98 |
72.48 |
80.51 |
75.68 |
65.8 |
87.47 |
Granite-3.3-8B-Instruct |
57.56 |
62.68 |
65.54 |
26.17 |
66.86 |
59.01 |
41.53 |
80.89 |
89.73 |
86.09 |
74.82 |
88.5 |
Granite-4.0-Tiny-Preview |
26.70 |
35.16 |
60.40 |
22.93 |
58.07 |
55.71 |
46.22 |
70.05 |
82.41 |
78.33 |
63.03 |
86.10 |
注:與之前的Granite模型的比較1。AlpacaEval-2.0和Arena-Hard的分數是在thinking=True
的情況下計算的。
訓練數據
總體而言,訓練數據主要由兩個關鍵來源組成:
- 具有寬鬆許可的公開可用數據集。
- 旨在增強推理能力的內部合成生成數據。
基礎設施
使用IBM的超級計算集群Blue Vela來訓練Granite-4.0-Tiny-Preview,該集群配備了NVIDIA H100 GPU。這個集群為在數千個GPU上訓練模型提供了可擴展且高效的基礎設施。
倫理考量和侷限性
Granite-4.0-Tiny-Preview利用了具有寬鬆許可的開源數據和部分專有數據以提高性能。由於它繼承了前一個模型的基礎,因此適用於Granite-4.0-Tiny-Preview的所有倫理考量和侷限性仍然適用。
資源
📄 許可證
本模型採用Apache 2.0許可證。
開發者
Granite團隊,IBM
網站
Granite Docs
發佈日期
2025年5月2日