Skip to content

AttributeError: 'Llama4Config' object has no attribute 'pad_token_id' #43525

@xin3he

Description

@xin3he

System Info

transformers == 5.0.0

Who can help?

@zucchini-nlp

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

To reproduce:

import transformers
model_name = "/dataset/Llama-4-Scout-17B-16E-Instruct"
config = transformers.Llama4Config.from_pretrained(model_name)
config.vision_config.num_hidden_layers = 1  # Reduce layers for testing
config.text_config.num_hidden_layers = 1
model = transformers.Llama4ForConditionalGeneration(config)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/xinhe/miniforge3/lib/python3.12/site-packages/transformers/models/llama4/modeling_llama4.py", line 1190, in __init__
    self.pad_token_id = self.config.pad_token_id if self.config.pad_token_id is not None else -1
                                                    ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/xinhe/miniforge3/lib/python3.12/site-packages/transformers/configuration_utils.py", line 164, in __getattribute__
    return super().__getattribute__(key)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Llama4Config' object has no attribute 'pad_token_id'

Expected behavior

The demo code should work well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions