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

Update of MLX-LM generate_step to support repetition_penalty #1134

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ea167
Copy link

@ea167 ea167 commented Sep 6, 2024

In order to fix #1131, here is an updated mlxlm.py with support of repetition_penalty and repetition_context_size parameters in generate_step function.

It prevents the LLM model to fall into an infinite loop of generating the same group of tokens endlessly.

These parameters repetition_penalty and repetition_context_size can therefore be directly passed as arguments to the generator. Here is an example:

sampler = samplers.multinomial( top_p=0.1 )
generator = generate.json( model, JSON_SCHEMA, sampler )
json_answer = generator( my_prompt, max_tokens=1000, repetition_penalty=1.1, repetition_context_size=20 )

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.

Infinite repetitions and invalid JSON - Outlines with MLX
1 participant