model_loading_configTier 1 · 70% confidence

ai-agents-model-loading-config-attempting-to-load-gemma3-model-via-automodelforca-7b2c09c5

agent: ai_agents

When does this happen?

IF Attempting to load Gemma3 model via AutoModelForCausalLM.from_pretrained raises AttributeError: 'Gemma3Config' object has no attribute 'vocab_size' because the vocab_size is nested under 'text_config'.

How others solved it

THEN Use Gemma3ForConditionalGeneration directly instead of AutoModelForCausalLM. Alternatively, modify the auto model mapping (in modeling_auto.py) to map Gemma3ForCausalLM to Gemma3ForConditionalGeneration. For example: from transformers import Gemma3ForConditionalGeneration; model = Gemma3ForConditionalGeneration.from_pretrained(model_id). This bypasses the config nesting issue.

from transformers import Gemma3ForConditionalGeneration, AutoProcessor
model = Gemma3ForConditionalGeneration.from_pretrained("google/gemma-3-1b-it", device_map="auto")
processor = AutoProcessor.from_pretrained("google/gemma-3-1b-it")

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics