Skip to content
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

min_tokens_to_keep has to be a positive integer, but it's type is float in mlx_lm/generate.py #1134

Closed
asamiKA opened this issue Dec 3, 2024 · 2 comments

Comments

@asamiKA
Copy link

asamiKA commented Dec 3, 2024

In mlx_lm/generate.py, the type of --min-tokens-to-keep parameter is set to float.

    parser.add_argument(
        "--min-tokens-to-keep",
        type=float,  # <- int
        default=DEFAULT_MIN_TOKENS_TO_KEEP,
        help="Minimum tokens to keep for min-p sampling.",
    )

but in mlx_lm/sample_utils.py, this cause error that 'min_tokens_to_keep has to be a positive integer'.

if not isinstance(min_tokens_to_keep, int) or (min_tokens_to_keep < 1):

    if not (0 <= min_p <= 1.0):
        raise ValueError(
            f"`min_p` has to be a float in the [0, 1] interval, but is {min_p}"
        )
    if not isinstance(min_tokens_to_keep, int) or (min_tokens_to_keep < 1):
        raise ValueError(
            f"`min_tokens_to_keep` has to be a positive integer, but is {min_tokens_to_keep}"
        )
@awni
Copy link
Member

awni commented Dec 3, 2024

Good catch, that's a typo. Would you like to send a PR to fix it?

@awni
Copy link
Member

awni commented Dec 3, 2024

Actually I just added the fix in #1133

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

No branches or pull requests

2 participants