Skip to content

[BUG: Breaking] 'SuryaDecoderConfig' object has no attribute 'pad_token_id' #484

@jjsmclaughlin

Description

@jjsmclaughlin

🧨 Describe the Bug

Presently for me, installing surya in a fresh venv, it fails when run with "'SuryaDecoderConfig' object has no attribute 'pad_token_id'"

Manually downgrading transformers to 4.57.3 fixes the issue.

Paste the complete stack trace or error output, if available.

Click to expand

Traceback (most recent call last):
File "/home/jamie/numbers/.venv/bin/surya_ocr", line 7, in
sys.exit(ocr_text_cli())
~~~~~~~~~~~~^^
File "/home/jamie/numbers/.venv/lib/python3.13/site-packages/click/core.py", line 1485, in call
return self.main(*args, **kwargs)
~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/home/jamie/numbers/.venv/lib/python3.13/site-packages/click/core.py", line 1406, in main
rv = self.invoke(ctx)
File "/home/jamie/numbers/.venv/lib/python3.13/site-packages/click/core.py", line 1269, in invoke
return ctx.invoke(self.callback, **ctx.params)
~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jamie/numbers/.venv/lib/python3.13/site-packages/click/core.py", line 824, in invoke
return callback(*args, **kwargs)
File "/home/jamie/numbers/.venv/lib/python3.13/site-packages/surya/scripts/ocr_text.py", line 29, in ocr_text_cli
foundation_predictor = FoundationPredictor()
File "/home/jamie/numbers/.venv/lib/python3.13/site-packages/surya/foundation/init.py", line 113, in init
super().init(checkpoint, device, dtype, attention_implementation)
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jamie/numbers/.venv/lib/python3.13/site-packages/surya/common/predictor.py", line 37, in init
self.model = loader.model(device, dtype, attention_implementation)
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jamie/numbers/.venv/lib/python3.13/site-packages/surya/foundation/loader.py", line 69, in model
model = model_cls.from_pretrained(
~~~~~~~~~~~~~~~~~~~~~~~~~^
self.checkpoint, dtype=dtype, config=config, ignore_mismatched_sizes=True
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
).to(device)
^
File "/home/jamie/numbers/.venv/lib/python3.13/site-packages/surya/common/s3.py", line 182, in from_pretrained
return super().from_pretrained(local_path, *args, **kwargs)
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jamie/numbers/.venv/lib/python3.13/site-packages/transformers/modeling_utils.py", line 4072, in from_pretrained
model = cls(config, *model_args, **model_kwargs)
File "/home/jamie/numbers/.venv/lib/python3.13/site-packages/surya/common/surya/init.py", line 123, in init
decoder = SuryaDecoderModel(config.decoder)
File "/home/jamie/numbers/.venv/lib/python3.13/site-packages/surya/common/surya/decoder/init.py", line 447, in init
self.padding_idx = config.pad_token_id
^^^^^^^^^^^^^^^^^^^
File "/home/jamie/numbers/.venv/lib/python3.13/site-packages/transformers/configuration_utils.py", line 164, in getattribute
return super().getattribute(key)
~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
AttributeError: 'SuryaDecoderConfig' object has no attribute 'pad_token_id'

⚙️ Environment

Please fill in all relevant details:

  • surya-ocr==0.17.1
  • Python 3.13.7
  • torch==2.9.1+cpu
  • transformers==5.0.0
  • Arch Linux

📟 Command or Code Used

Paste the exact bash command or Python code you used to run Marker:

Click to expand

surya_ocr test.png --images --output_dir test

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug: breakingCrashes, errors, anything that stops execution or is runtime-breaking

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions