Skip to content

logit_bias: apply configurable escalating EOG bias at low n_remain #14229

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

graehl
Copy link

@graehl graehl commented Jun 16, 2025

give eog an increasing (with length - per token, could be per codepoint in future) bias, only after a configured amount generated

add to sample_apply an n_remain param, which is safer than having logit_bias maintain state for how many times it's called (which would lead to wrong assumptions e.g. when calling multiple times per token).

see new command line options (incl a request 'after' instead of 'remain'):

-eog, --eog-bias-per-tok N when fewer than -start-eog-at-remain tokens are left to generate after
-n, add this bias eog for each subsequent token (default: 0.0)
-remain, --start-eog-at-remain N start applying -eog bias when this many tokens remain of the -n max
(default: 0.0)
-after, --start-eog-after N start applying -eog bias after this many tokens generated (default:
1000000000.0); whichever happens first between -remain and -after
applies

Verified that eog bias was effective at avoiding
overgeneration and is a reasonable supplement or alternative to editing the prompt; a constant eog bias, already supported in samplers, is likely to allow pathologically short outputs.

Make sure to read the contributing guidelines before submitting a PR

give eog an increasing (with length - per token, could be per
codepoint in future) bias, only after a configured amount generated

add to `sample_apply` an `n_remain` param, which is safer than having
logit_bias maintain state for how many times it's called (which
would lead to wrong assumptions e.g. when calling multiple times per
token).

see new command line options (incl a request 'after' instead of
'remain'):

-eog,  --eog-bias-per-tok N             when fewer than -start-eog-at-remain tokens are left to generate after
                                        -n, add this bias eog for each subsequent token (default: 0.0)
-remain, --start-eog-at-remain N        start applying -eog bias when this many tokens remain of the -n max
                                        (default: 0.0)
-after, --start-eog-after N             start applying -eog bias after this many tokens generated (default:
                                        1000000000.0); whichever happens first between -remain and -after
                                        applies

Verified that eog bias was effective at avoiding
overgeneration and is a reasonable supplement or alternative
to editing the prompt; a *constant* eog bias, already supported
in samplers, is likely to allow pathologically short outputs.
@graehl graehl requested a review from ngxson as a code owner June 16, 2025 23:32
@github-actions github-actions bot added testing Everything test related examples server labels Jun 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
examples server testing Everything test related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant