Skip to content

Fix max number of tokens for synthetic data generator #170

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

Merged
merged 2 commits into from
May 21, 2025

Conversation

jackcook
Copy link
Contributor

@jackcook jackcook commented May 20, 2025

When using prompt_tokens_max (and not using prompt_tokens_stdev), there will occasionally be one token more than the maximum number specified. This can be tested as follows:

from guidellm.utils import IntegerRangeSampler

MIN_VALUE = 5
MAX_VALUE = 15

irs = IntegerRangeSampler(average=(MAX_VALUE - MIN_VALUE) // 2, variance=None, min_value=MIN_VALUE, max_value=MAX_VALUE, random_seed=None)
it = iter(irs)

for _ in range(10000):
    assert next(it) != 16

The assertion will fire, despite the max being set to 15. This happens because random.randint, which is used by IntegerRangeSampler, generates numbers up to and including the max value it is given. This PR fixes that.

Copy link
Member

@markurtz markurtz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks @jackcook!

@markurtz markurtz merged commit b85c6b9 into neuralmagic:main May 21, 2025
9 of 11 checks passed
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