ibm-granite/granite-4.1-8b · Hugging Face

Reddit r/LocalLLaMA 模型

摘要

IBM 发布 Granite-4.1-8B:Apache 2.0 许可的 80 亿参数长上下文 Instruct 模型,工具调用与多语言能力全面升级。

**模型概述:** Granite-4.1-8B 是一款 80 亿参数的长上下文 Instruct 模型,基于 *Granite-4.1-8B-Base*,结合开源许可的指令数据集与内部合成数据微调而成。Granite 4.1 系列经过升级的后训练流程,包括监督微调与强化学习对齐,显著提升了工具调用、指令遵循与对话能力。 * **开发者:** Granite Team, IBM * **HF 合集:** [Granite 4.1 语言模型 HF 合集](https://huggingface.co/collections/ibm-granite/granite-40-language-models-6811a18b820ef362d9e5a82c) * **技术博客:** [Granite-4.1 博客](https://huggingface.co/blog/ibm-granite/granit-4-1) * **GitHub 仓库:** [ibm-granite/granite-4.1-language-models](https://github.com/ibm-granite/granite-4.1-language-models) * **官网文档:** [Granite Docs](https://www.ibm.com/granite/docs/) * **发布日期:** 2026 年 4 月 29 日 * **许可证:** [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0) **支持语言:** 英语、德语、西班牙语、法语、日语、葡萄牙语、阿拉伯语、捷克语、意大利语、韩语、荷兰语、中文。用户可继续微调以支持其他语言。 **适用场景:** 模型专为通用指令跟随设计,可作为各领域 AI 助手的基础,尤其适用于商业应用及具备工具使用能力的 LLM Agent。 *能力列表* * 文本摘要 * 文本分类 * 信息抽取 * 问答 * 检索增强生成(RAG) * 代码任务 * 函数调用 * 多语言对话 * Fill-In-the-Middle(FIM)代码补全
查看原文
查看缓存全文

缓存时间: 2026/04/22 02:02

ibm-granite/granite-4.1-8b · Hugging Face

来源:https://huggingface.co/ibm-granite/granite-4.1-8b
mof-class3-qualified(https://mot.isitopen.ai/model/1160)

模型摘要:
Granite-4.1-8B 是一个 80 亿参数的长上下文指令模型,基于 Granite-4.1-8B-Base,在多种开源(宽松许可证)指令数据集以及内部合成数据上微调而来。Granite 4.1 系列经过升级的后训练流程,包括监督微调(SFT)与强化学习对齐,显著提升了工具调用、指令遵循与对话能力。

  • **开发者:**Granite Team, IBM
  • **HF 合集:**Granite 4.1 语言模型 HF 合集(https://huggingface.co/collections/ibm-granite/granite-40-language-models-6811a18b820ef362d9e5a82c)
  • **技术博客:**Granite-4.1 博客(https://huggingface.co/blog/ibm-granite/granit-4-1)
  • **GitHub 仓库:**ibm-granite/granite-4.1-language-models(https://github.com/ibm-granite/granite-4.1-language-models)
  • **官网:**Granite 文档(https://www.ibm.com/granite/docs/)
  • **发布日期:**2026 年 4 月 29 日
  • **许可证:**Apache 2.0(https://www.apache.org/licenses/LICENSE-2.0)

支持语言:
英语、德语、西班牙语、法语、日语、葡萄牙语、阿拉伯语、捷克语、意大利语、韩语、荷兰语、中文。用户也可对 Granite 4.1 进行微调以支持更多语言。

预期用途:
模型旨在遵循通用指令,可作为多领域 AI 助手(含商业场景)的基础,也可用于具备工具调用能力的 LLM Agent。

能力

  • 文本摘要
  • 文本分类
  • 信息抽取
  • 问答
  • 检索增强生成(RAG)
  • 代码相关任务
  • 函数调用任务
  • 多语言对话
  • Fill-In-the-Middle(FIM)代码补全

生成示例:
以下展示如何快速调用 Granite-4.1-8B 模型。先安装依赖:

pip install torch torchvision torchaudio
pip install accelerate
pip install transformers

随后复制对应场景的代码片段:

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

device = "cuda"
model_path = "ibm-granite/granite-4.1-8b"
tokenizer = AutoTokenizer.from_pretrained(model_path)
# 若在 CPU 运行,请去掉 device_map
model = AutoModelForCausalLM.from_pretrained(model_path, device_map=device)
model.eval()

# 按需修改输入
chat = [
    {"role": "user", "content": "Please list one IBM Research laboratory located in the United States. You should only output its name and location."},
]
chat = tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)

input_tokens = tokenizer(chat, return_tensors="pt").to(device)
output = model.generate(**input_tokens, max_new_tokens=100)
output = tokenizer.batch_decode(output)
print(output[0])

预期输出:

<|start_of_role|>system<|end_of_role|>You are a helpful assistant. Please ensure responses are professional, accurate, and safe.<|end_of_text|>
<|start_of_role|>user<|end_of_role|>Please list one IBM Research laboratory located in the United States. You should only output its name and location.<|end_of_text|>
<|start_of_role|>assistant<|end_of_role|>Almaden Research Center, San Jose, California<|end_of_text|>

工具调用:
Granite-4.1-8B 具备增强的工具调用能力,可无缝集成外部函数与 API。定义工具列表时请遵循 OpenAI 的函数定义模式(https://platform.openai.com/docs/guides/function-calling)。示例:

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

device = "cuda"
model_path = "ibm-granite/granite-4.1-8b"
tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModelForCausalLM.from_pretrained(model_path, device_map=device)
model.eval()

tools = [
    {
        "type": "function",
        "function": {
            "name": "get_current_weather",
            "description": "Get the current weather for a specified city.",
            "parameters": {
                "type": "object",
                "properties": {
                    "city": {"type": "string", "description": "Name of the city"}
                },
                "required": ["city"]
            }
        }
    }
]

chat = [
    {"role": "user", "content": "What's the weather like in Boston right now?"},
]
chat = tokenizer.apply_chat_template(chat,
                                     tokenize=False,
                                     tools=tools,
                                     add_generation_prompt=True)

input_tokens = tokenizer(chat, return_tensors="pt").to(device)
output = model.generate(**input_tokens, max_new_tokens=100)
output = tokenizer.batch_decode(output)
print(output[0])

预期输出:

<|start_of_role|>system<|end_of_role|>You are a helpful assistant with access to the following tools. You may call one or more tools to assist with the user query. You are provided with function signatures within XML tags: {"type": "function", "function": {"name": "get_current_weather", "description": "Get the current weather for a specified city.", "parameters": {"type": "object", "properties": {"city": {"type": "string", "description": "Name of the city"}}, "required": ["city"]}}} For each tool call, return a json object with function name and arguments within XML tags: {"name": <name>, "arguments": <args>} . If a tool does not exist in the provided list of tools, notify the user that you do not have the ability to fulfill the request.<|end_of_text|>
<|start_of_role|>user<|end_of_role|>What's the weather like in Boston right now?<|end_of_text|>
<|start_of_role|>assistant<|end_of_role|> {"name": "get_current_weather", "arguments": {"city": "Boston"}} <|end_of_text|>

评测结果:

基准指标3B Dense8B Dense30B Dense
通用任务
MMLU 5-shot67.0273.8480.16
MMLU-Pro 5-shot, CoT49.8355.9964.09
BBH 3-shot, CoT75.8380.5183.74
AGI Eval 0-shot, CoT65.1672.4377.80
GPQA 0-shot, CoT31.7041.9645.76
SimpleQA3.684.826.81
对齐任务
AlpacaEval 2.038.5750.0856.16
IFEval Avg82.3085.8788.88
ArenaHard37.8068.9871.02
MTBench Avg7.578.618.61
数学任务
GSM8K 8-shot86.8892.4994.16
GSM Symbolic 8-shot81.3283.7075.70
Minerva Math 0-shot, CoT67.9480.1081.32
DeepMind Math 0-shot, CoT64.6480.0781.93
代码任务
HumanEval pass@181.7185.3788.41
HumanEval+ pass@176.8379.8885.37
MBPP pass@171.1687.3085.45
MBPP+ pass@162.1773.8173.54
CRUXEval-O pass@140.7547.6355.75
BigCodeBench pass@132.1935.0038.77
MULTIPLE pass@152.5460.2662.31
Eval+ Avg pass@167.0580.2182.66
工具调用任务
BFCL v360.8068.2773.68
多语言任务
MMMLU 5-shot57.6164.8473.71
INCLUDE 5-shot52.0558.8967.26
MGSM 8-shot70.0082.3271.12
安全
SALAD-Bench93.9595.8096.41
AttaQ81.8881.1985.76
Tulu3 Safety Eval Avg66.8475.5778.19

多语言基准及所含语言:

基准语言数量语言
MMMLU11ar, de, en, es, fr, ja, ko, pt, zh, bn, hi
INCLUDE14hi, bn, ta, te, ar, de, es, fr, it, ja, ko, nl, pt, zh
MGSM5en, es, fr, ja, zh

模型架构:
Granite-4.1-8B 基线采用纯解码器稠密 Transformer 架构,核心组件包括 GQA、RoPE、SwiGLU MLP、RMSNorm 及共享输入/输出嵌入。

模型3B Dense8B Dense30B Dense
Embedding size256040964096
层数404064
Attention head size64128128
Attention heads403232
KV heads888
MLP 隐层 / 共享专家81921280032768
MLP 激活SwiGLUSwiGLUSwiGLU
序列长度409640964096
位置编码RoPERoPERoPE
参数量3B8B30B

训练数据:
SFT 数据主要来自三方面:

  1. 公开且许可证宽松的指令数据集
  2. 针对特定能力内部合成的数据
  3. 少量人工精标数据

监督微调与强化学习:
指令模型经过大幅改进的 SFT 与 RL 流程,使用上述高质量混合数据。通过多轮 SFT-RL 迭代,显著提升了工具调用、指令遵循与对话能力。详见 Granite-4.1 博客(https://huggingface.co/blog/ibm-granite/granit-4-1)。

基础设施:
Granite 4.1 语言模型在 CoreWeave 托管的 NVIDIA GB200 NVL72 集群上训练。单机柜内通过 72-GPU NVLink 域通信,机柜间采用无阻塞全 Fat-Tree NDR 400 Gb/s InfiniBand 网络,为数千 GPU 的可扩展高效训练提供保障。

伦理考量与限制:
Granite 4.1 指令模型主要使用英文学指令-回复对,同时包含多语言数据。尽管模型支持多语言对话,但在非英语场景下的表现可能不及英语任务,此时可引入少量示例(few-shot)提升准确性。虽然已进行安全对齐,模型仍可能输出不准确、有偏见或不安全的内容,建议社区针对具体任务进行充分的安全测试与调优。

资源

  • ⭐️ 了解 Granite 最新动态:https://www.ibm.com/granite
  • 📄 教程、最佳实践与提示工程指南:https://www.ibm.com/granite/docs/
  • 💡 最新学习资源汇总:https://ibm.biz/granite-learning-resources

相似文章

IBM Granite Speech 5.0 2B

Reddit r/LocalLLaMA

IBM 发布了 Granite Speech 5.0 2B,这是一款紧凑的多语言语音语言模型,支持六种语言的语音识别(ASR)和语音翻译,相比前代产品提升了噪声鲁棒性、语言识别提示(language-ID prompting)能力,并支持多达 2000 个关键词的偏置引导。

Granite 4.2 LLMs:构建原理

Hugging Face Blog

Granite 4.2是IBM推出的新型推理LLM系列,提供3B、8B和30B尺寸,具备思考模式、工具调用功能,并在Apache 2.0许可证下通过多阶段强化学习流水线进行训练。

ibm-granite/granite-switch-4.1 30B/8B

Reddit r/LocalLLaMA

IBM 发布 Granite Switch 4.1 30B/8B,这是一个模块化 LLM,将基座模型、多个 aLoRA 适配器(决策、guardian)和语音编码器组合在一起,通过单个端点即可在聊天、通用/专业决策和语音转文本之间切换,采用 Apache 2.0 许可。