Skip to content

Fix PPFormulaNet training loss: prevent incorrect label shift in ForCausalLMLoss - #47319

Closed
sagnikai wants to merge 1 commit into
huggingface:mainfrom
sagnikai:fix/pp-formulanet-loss-shift-labels
Closed

Fix PPFormulaNet training loss: prevent incorrect label shift in ForCausalLMLoss#47319
sagnikai wants to merge 1 commit into
huggingface:mainfrom
sagnikai:fix/pp-formulanet-loss-shift-labels

Conversation

@sagnikai

@sagnikai sagnikai commented Jul 14, 2026

Copy link
Copy Markdown

CI

ForCausalLMLoss internally shifts labels left by 1 (labels[..., 1:]) when shift_labels is not provided. However, PPFormulaNet is an encoder-decoder model where logits are already aligned with labels — no shift is needed. This causes the model to train against misaligned labels, losing the last target token.

This fix passes shift_labels=labels to ForCausalLMLoss, telling it to skip the internal shift. This matches the same pattern used by Florence2 (fixed in #46898), which PPFormulaNet inherits from but overrides orward().

Fixes #47317.

@github-actions

Copy link
Copy Markdown
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: pp_formulanet

@github-actions

Copy link
Copy Markdown
Contributor

CI recap

Dashboard: View test results in Grafana
Latest run: 29336073721
Result: failure | Grafana metrics are not available yet.

Code quality check failed: test jobs were skipped. Fix the code quality issues and push again to run tests.

@sagnikai sagnikai closed this Jul 14, 2026
@sagnikai
sagnikai deleted the fix/pp-formulanet-loss-shift-labels branch July 14, 2026 13:25
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.

PPFormulaNet training-loss bug

1 participant