granite vision 3.3 2b

提供商ibm-granite
分类image-to-text
许可证apache-2.0
下载量330
星标0

简介

Granite Vision 3.3 2B 是 IBM 推出的轻量级多模态视觉模型。它主打在极小参数量下实现高效的图像理解能力,非常适合那些对端侧部署或推理成本敏感的开发者。该模型能够将视觉信息转化为精准的文本描述,在文档分析、简单的图像识别和视觉问答场景中表现稳健。对于习惯使用大模型的用户来说,它更像是一个灵活的“视觉插件”,可以快速集成到自动化工作流中,且得益于 Apache-2.0 协议,企业级部署的门槛极低。

核心亮点

  • 2B 轻量级参数,端侧部署与推理极速
  • Apache-2.0 协议,企业商用无压力
  • 擅长图像描述与视觉问答,响应高效
  • 低资源占用,适合构建轻量化 AI 工作流

使用方法

安装依赖
# 安装 Hugging Face transformers
pip install transformers torch
SDK 使用
# 使用 transformers 加载模型
from transformers import AutoModel, AutoTokenizer

model = AutoModel.from_pretrained("ibm-granite/granite-vision-3.3-2b")
tokenizer = AutoTokenizer.from_pretrained("ibm-granite/granite-vision-3.3-2b")

Hugging Face 下载

我们推荐使用命令行或者 Hugging Face Hub SDK 来进行模型的下载。

操作指引:在下载前,请先通过如下命令安装 huggingface_hub:

操作指引
pip install -U huggingface_hub

命令行下载

下载完整模型库

下载完整模型库
huggingface-cli download ibm-granite/granite-vision-3.3-2b

下载单个文件到指定本地文件夹(以下载 config.json 到当前路径下 ./dir 目录为例)

下载单个文件到指定本地文件夹(以下载 config.json 到当前路径下 ./dir 目录为例)
huggingface-cli download ibm-granite/granite-vision-3.3-2b config.json --local-dir ./dir

更多命令行下载选项,可参见官方文档

SDK 下载

SDK 下载
# 模型下载
from huggingface_hub import snapshot_download
model_dir = snapshot_download('ibm-granite/granite-vision-3.3-2b')

Git 下载

请确保 lfs 已经被正确安装

Git 下载
git lfs install
git clone https://huggingface.co/ibm-granite/granite-vision-3.3-2b

如果您希望跳过 lfs 大文件下载,可以使用如下命令

跳过 LFS
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/ibm-granite/granite-vision-3.3-2b

模型文件托管在 Hugging Face Hub,使用 HF CLI / SDK / Git 直接下载,不经过本站。

PyTorch / Transformers 使用

安装 Transformers

安装 Transformers
pip install -U transformers torch

模型加载和推理

模型加载和推理
from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained('ibm-granite/granite-vision-3.3-2b')
tokenizer = AutoTokenizer.from_pretrained('ibm-granite/granite-vision-3.3-2b')

模型下载

我们推荐使用命令行或者 ModelScope SDK 来进行模型的下载。

操作指引:在下载前,请先通过如下命令安装 ModelScope:

操作指引
pip install modelscope

命令行下载

下载完整模型库

下载完整模型库
modelscope download --model ibm-granite/granite-vision-3.3-2b

下载单个文件到指定本地文件夹(以下载 README.md 到当前路径下 dir 目录为例)

下载单个文件到指定本地文件夹(以下载 README.md 到当前路径下 dir 目录为例)
modelscope download --model ibm-granite/granite-vision-3.3-2b README.md --local_dir ./dir

更多更丰富的命令行下载选项,可参见具体文档

SDK 下载

SDK 下载
# 模型下载
from modelscope import snapshot_download
model_dir = snapshot_download('ibm-granite/granite-vision-3.3-2b')

Git 下载

请确保 lfs 已经被正确安装

Git 下载
git lfs install
git clone https://www.modelscope.cn/ibm-granite/granite-vision-3.3-2b.git

如果您希望跳过 lfs 大文件下载,可以使用如下命令

跳过 LFS
GIT_LFS_SKIP_SMUDGE=1 git clone https://www.modelscope.cn/ibm-granite/granite-vision-3.3-2b.git

ModelScope 模型页直接下载模型文件;无需将模型文件放在本站服务器。

Notebook 快速开发

下载并安装 ModelScope library

下载并安装 ModelScope library
pip install "modelscope[audio,cv,nlp,multi-modal,science]" -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html

模型加载和推理

模型加载和推理
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks

p = pipeline('text-generation', 'ibm-granite/granite-vision-3.3-2b')

完整文档

来源: HuggingFace

---
tags:
- image-to-text
license: apache-2.0
new_version: ibm-granite/granite-4.0-3b-vision
---

granite-vision-3.3-2b

Model Summary: Granite-vision-3.3-2b is a compact and efficient vision-language model, specifically designed for visual document understanding, enabling automated content extraction from tables, charts, infographics, plots, diagrams, and more. Granite-vision-3.3-2b introduces several novel experimental features such as *image segmentation*, *doctags generation*, and *multi-page support* (see Experimental Capabilities for more details) and offers enhanced safety when compared to earlier Granite vision models. The model was trained on a meticulously curated instruction-following data, comprising diverse public and synthetic datasets tailored to support a wide range of document understanding and general image tasks. Granite-vision-3.3-2b was trained by fine-tuning a Granite large language model with both image and text modalities.

Evaluations: We compare the performance of granite-vision-3.3-2b with previous versions of granite-vision models. Evaluations were done using the standard llms-eval benchmark and spanned multiple public benchmarks, with particular emphasis on document understanding tasks while also including general visual question-answering benchmarks.

| | Granite-vision-3.1-2b-preview | Granite-vision-3.2-2b | Granite-vision-3.3-2b |
|-----------|-----------|--------------|----------------|
| Document benchmarks |
| ChartQA | 0.86 | 0.87 | 0.87 |
| DocVQA | 0.88 | 0.89 | 0.91 |
| TextVQA | 0.76 | 0.78 | 0.80 |
| AI2D | 0.78 | 0.76 | 0.77 |
| InfoVQA | 0.63 | 0.64 | 0.68 |
| OCRBench | 0.75 | 0.77 | 0.79 |
| LiveXiv VQA v2 | 0.61 | 0.61 | 0.61 |
| LiveXiv TQA v2 | 0.55 | 0.57 | 0.52 |
| Other benchmarks |
| MMMU | 0.35 | 0.37 | 0.37 |
| VQAv2 | 0.81 | 0.78 | 0.79 |
| RealWorldQA | 0.65 | 0.63 | 0.63 |
| VizWiz VQA | 0.64 | 0.63 | 0.62 |
| OK VQA | 0.57 | 0.56 | 0.55|

  • Release Date: Jun 11th, 2025

Supported Input Format: Currently the model supports English instructions and images (png, jpeg) as input format.

Intended Use: The model is intended to be used in enterprise applications that involve processing visual and text data. In particular, the model is well-suited for a range of visual document understanding tasks, such as analyzing tables and charts, performing optical character recognition (OCR), and answering questions based on document content. Additionally, its capabilities extend to general image understanding, enabling it to be applied to a broader range of business applications. For tasks that exclusively involve text-based input, we suggest using our Granite large language models, which are optimized for text-only processing and offer superior performance compared to this model.

Generation:

Granite Vision model is supported natively transformers>=4.49. Below is a simple example of how to use the granite-vision-3.3-2b model.

Usage with transformers

First, make sure to build the latest versions of transformers:

shell
pip install transformers>=4.49

Then run the code:

python
from transformers import AutoProcessor, AutoModelForVision2Seq
from huggingface_hub import hf_hub_download
import torch

device = "cuda" if torch.cuda.is_available() else "cpu"

model_path = "ibm-granite/granite-vision-3.3-2b"
processor = AutoProcessor.from_pretrained(model_path)
model = AutoModelForVision2Seq.from_pretrained(model_path).to(device)

prepare image and text prompt, using the appropriate prompt template

img_path = hf_hub_download(repo_id=model_path, filename='example.png')

conversation = [
{
"role": "user",
"content": [
{"type": "image", "url": img_path},
{"type": "text", "text": "What is the highest scoring model on ChartQA and what is its score?"},
],
},
]
inputs = processor.apply_chat_template(
conversation,
add_generation_prompt=True,
tokenize=True,
return_dict=True,
return_tensors="pt"
).to(device)

autoregressively complete prompt

output = model.generate(inputs, max_new_tokens=100) print(processor.decode(output[0], skip_special_tokens=True))

Usage with vLLM

The model can also be loaded with vLLM. First make sure to install the following libraries:

shell
pip install torch torchvision torchaudio
pip install vllm==0.6.6
Then, copy the snippet from the section that is relevant for your use case.
python
from vllm import LLM, SamplingParams
from vllm.assets.image import ImageAsset
from huggingface_hub import hf_hub_download
from PIL import Image

model_path = "ibm-granite/granite-vision-3.3-2b"

model = LLM(
model=model_path,
)

sampling_params = SamplingParams(
temperature=0.2,
max_tokens=64,
)

Define the question we want to answer and format the prompt

image_token = "<image>" system_prompt = "<|system|>\nA chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions.\n"

question = "What is the highest scoring model on ChartQA and what is its score?"
prompt = f"{system_prompt}<|user|>\n{image_token}\n{question}\n<|assistant|>\n"
img_path = hf_hub_download(repo_id=model_path, filename='example.png')
image = Image.open(img_path).convert("RGB")
print(image)

Build the inputs to vLLM; the image is passed as multi_modal_data.

inputs = { "prompt": prompt, "multi_modal_data": { "image": image, } }

outputs = model.generate(inputs, sampling_params=sampling_params)
print(f"Generated text: {outputs[0].outputs[0].text}")

Safety Evaluation

The Granite-vision-3.3-2b model also went through safety alignment to make sure responses are safer without affecting the model’s performance on its intended task. We carefully safety aligned the model on publicly available safety data and synthetically generated safety data. We report our safety scores on publicly available RTVLM and VLGuard datasets.

RTVLM Safety Score - [0,10] - Higher is Better

| | Politics | Racial | Jailbreak | Mislead |
|-----------|-----------|--------------|----------------|----------------|
|Granite-vision-3.1-2b-preview|7.2|7.7|4.5|7.6|
|Granite-vision-3.2-2b|7.6|7.8|6.2|8.0|
|Granite-vision-3.3-2b|8.0|8.1|7.5|8.0|

VLGuard Safety Score - [0,10] - Higher is Better**

| | Unsafe Images (Unsafe) | Safe Images with Unsafe Instructions |
|-----------|-----------|--------------|
|Granite-vision-3.1-2b-preview|6.6|8.4|
|Granite-vision-3.2-2b|7.6|8.9|
|Granite-vision-3.3-2b|8.4|9.3|

Experimental Capabilities

Granite-vision-3.3-2b introduces three new experimental capabilities:

(1) Image segmentation: A notebook showing a segmentation example

(2) Doctags generation: Parse document images to structured text in doctags format. Please see Docling project for more details on doctags.

(3) Multipage support: The model was trained to handle question answering (QA) tasks using multiple consecutive pages from a document—up to 8 pages—given the demands of long-context processing. To support such long sequences without exceeding GPU memory limits, we recommend resizing images so that their longer dimension is 768 pixels.

Fine-tuning

For an example of fine-tuning granite-vision-3.3-2b