Released by Google DeepMind, Gemma 4 31B IT is a multimodal model that supports not only text generation but also image input. Furthermore, it can handle long-form contexts of up to 256K tokens and has been trained on over 140 languages, making it suitable for a wide range of tasks including multilingual processing, long-document comprehension, coding, and reasoning. It is available on Hugging Face under the Apache 2.0 license, which makes it attractive for research and validation purposes.
Brief introduction
Gemma 4 31B IT is an instruction-tuned open model by Google DeepMind. With features like multimodal support for images, a 256K long-context window, and a thinking mode, it is a notable model that can handle reasoning, coding, and long-document comprehension all in one.
Three key features
Multimodal support
In addition to text, it can handle image input. Image understanding capabilities are intended for documents, UIs, charts, and OCR-related tasks.Strong with long text
The 31B version supports a context of up to 256K tokens, making it suitable for summarizing long documents or cross-referencing multiple documents.Easy to use for reasoning tasks
The Gemma 4 family is designed with a focus on reasoning, and you can use it while toggling the thinking mode.
Code to try in Google Colab
# Colab: Gemma 4 31B IT を試す最小例
事前に Hugging Face のアクセストークンを設定しておくと安心です
(必要なら notebook_login() を使ってログイン)
!pip -q install -U transformers accelerate sentencepiece
from huggingface_hub import notebook_login
必要に応じてログイン
notebook_login()
import torch
from transformers import AutoProcessor, AutoModelForCausalLM
MODEL_ID = "google/gemma-4-31B-it"
メモリ不足ならこちらを試す:
MODEL_ID = "google/gemma-4-E4B-it"
processor = AutoProcessor.from_pretrained(MODEL_ID)
model = AutoModelForCausalLM.from_pretrained(
MODEL_ID,
torch_dtype="auto",
device_map="auto",
)
messages = [
"role": "system", "content": "あなたは簡潔で正確なアシスタントです。",
"role": "user", "content": "Gemma 4 31B ITの特徴を3点で簡潔に説明してください。",
]
text = processor.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True,
enable_thinking=False, # reasoningを使うなら True
)
inputs = processor(text=text, return_tensors="pt").to(model.device)
input_len = inputs["input_ids"].shape[-1]
with torch.inference_mode():
outputs = model.generate(
inputs,
max_new_tokens=256,
do_sample=False,
)
response = processor.decode(
outputs[0][input_len:],
skip_special_tokens=False
)
print(processor.parse_response(response))Impressions
I wanted to try it in Google Colab, but the free version only has 16GB of GPU memory, which was insufficient to run it to completion. I also tried the lightweight version of the model, but it also lacked enough memory to run.
Lately, I've been wondering if there are people who are successfully utilizing local LLMs. I assume LLM development will continue, and it feels more efficient to use commercial LLMs. While local LLMs might be good for simple translations, for actual production use, commercial LLMs should offer better cost-performance.