Skip to content

Add supported kwargs to fixed_cross_entropy#43254

Open
Rocketknight1 wants to merge 2 commits intomainfrom
add_fixed_cross_entropy_kwargs
Open

Add supported kwargs to fixed_cross_entropy#43254
Rocketknight1 wants to merge 2 commits intomainfrom
add_fixed_cross_entropy_kwargs

Conversation

@Rocketknight1
Copy link
Copy Markdown
Member

This PR allows some specific kwargs to be passed through to fixed_cross_entropy. Fixes #43240

cc @ArthurZucker because I think you wrote the original?

@Rocketknight1 Rocketknight1 marked this pull request as ready for review January 13, 2026 13:53
@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@github-actions
Copy link
Copy Markdown
Contributor

View the CircleCI Test Summary for this PR:

https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=43254&sha=f05ae7

@stas00
Copy link
Copy Markdown
Contributor

stas00 commented Jan 15, 2026

After this change I'd then drop **kwargs arg, since it silently ignores them. This is not good for the user - it either should do something with kwargs and assert if the use is unexpected or it shouldn't absorb args that shouldn't be there.

There is another version of this PR here #43251

@Rocketknight1
Copy link
Copy Markdown
Member Author

Hey @stas00, good to hear from you again! I suspect the **kwargs there is because the function is often called with **kwargs in other contexts, so doing it like that lets it catch any named kwargs that match while ignoring ones that don't. That makes me a little nervous about updating it, because I think those kwargs are flowing through from a lot of different possible sources.

@stas00
Copy link
Copy Markdown
Contributor

stas00 commented Jan 21, 2026

I understand your reasoning, Matt

Perhaps with v5 transformers could fix the silent kwargs black holes in its code - kwargs is designed for passing forward arguments to the next function in the stack. In this situation the function isn't passing kwargs forward therefore it shouldn't have kwargs in its API.

@Rocketknight1 Rocketknight1 force-pushed the add_fixed_cross_entropy_kwargs branch 4 times, most recently from daabe79 to 0f4840b Compare January 26, 2026 15:58
@Rocketknight1 Rocketknight1 force-pushed the add_fixed_cross_entropy_kwargs branch from 0f4840b to afb3f23 Compare January 29, 2026 19:00
This was referenced Apr 22, 2026
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.

kwargs are not passed to loss calculation function.

3 participants