🚀 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日