Skip to content

Remove phantom label_smoothing attribute from NpoLoss docstring - #744

Open
PratikDhanave wants to merge 1 commit into
google-deepmind:mainfrom
PratikDhanaveFork:fix/npo-loss-phantom-label-smoothing-docstring
Open

Remove phantom label_smoothing attribute from NpoLoss docstring#744
PratikDhanave wants to merge 1 commit into
google-deepmind:mainfrom
PratikDhanaveFork:fix/npo-loss-phantom-label-smoothing-docstring

Conversation

@PratikDhanave

@PratikDhanave PratikDhanave commented Jul 25, 2026

Copy link
Copy Markdown

What

NpoLoss (in gemma/gm/losses/_npo.py) documents a label_smoothing attribute in its class docstring:

label_smoothing: The label smoothing to apply to the loss.

However, the dataclass has no label_smoothing field, and the NPO loss it computes — -jax.nn.log_sigmoid(-po_delta) — has no label-smoothing term. The line is a copy-paste artifact from the sibling DpoLoss, which genuinely declares and uses label_smoothing in its loss formula.

A user following the NpoLoss docs and passing NpoLoss(label_smoothing=...) would hit a TypeError, misled into thinking a knob exists that doesn't.

Change

Remove the stale docstring line so the documented attributes match the actual fields. Docstring-only; no behavior change.

@google-cla

google-cla Bot commented Jul 25, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

`NpoLoss`'s docstring documented a `label_smoothing` attribute, but the
dataclass has no such field and the NPO loss (`-log_sigmoid(-po_delta)`)
has no label-smoothing term. The line is a copy-paste artifact from the
sibling `DpoLoss`, which genuinely has and uses `label_smoothing`. A user
following the NpoLoss docs would hit a TypeError passing `label_smoothing=`.
Drop the stale line so the documented attributes match the actual fields.
@PratikDhanave
PratikDhanave force-pushed the fix/npo-loss-phantom-label-smoothing-docstring branch from 66b446a to 11a277f Compare July 25, 2026 04:46
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.

1 participant