Skip to content

Fix AdamW import in TAPAS fine-tuning example - #50607

Closed
LKL-ZREO wants to merge 1 commit into
huggingface:mainfrom
LKL-ZREO:fix/tapas-adamw-example
Closed

LKL-ZREO wants to merge 1 commit into
huggingface:mainfrom
LKL-ZREO:fix/tapas-adamw-example

Conversation

@LKL-ZREO

@LKL-ZREO LKL-ZREO commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

🤗 Transformers CI

What does this PR do?

The TAPAS fine-tuning example imports AdamW from transformers, which raises an ImportError before the example can load the model. This switches the example to torch.optim.AdamW and explicitly preserves the previous eps=1e-6 and weight_decay=0.0 defaults.

Validation

Run the example's original import on main (e4e4e98):

python -c "from transformers import AdamW, TapasConfig, TapasForQuestionAnswering"

This raises ImportError: cannot import name 'AdamW' from 'transformers'. With the updated import and optimizer call, I initialized a tiny TAPAS model on CPU, checked the optimizer defaults, and verified that one optimizer step updated a parameter. git diff --check passed. The five repository style checkers passed locally with the pinned Ruff version.

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution 🤗!

CI Security Gate — waiting for maintainer approval

CI is approved automatically only for authors who already have a contribution merged in this repository. A maintainer will review this PR and approve CI to run on it.

@Rocketknight1

Copy link
Copy Markdown
Member

We're trying to avoid PRs for these small doc fixes right now, sorry! People find them a lot in agent sweeps and it creates a lot of PR spam. If you're interested in these kinds of fixes, please make an issue to discuss bulk-fixing them (for example, sweeping all model docs for invalid imports in a single PR, rather than just drip-feeding them)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants