Add logits_processor option to generate_step function#983
Add logits_processor option to generate_step function#983awni merged 8 commits intoml-explore:mainfrom
Conversation
|
Sorry for the delayed review. This is cool! And I think we can include it but I want to clarify something first. We have the In addition, I don't think we need to support both arguments as it's a bit messy and redundant. Perhaps we can remove the |
|
I can indeed use the If you agree, I can remove the |
|
Sounds good, thanks for clarifying. Let's remove |
llms/mlx_lm/utils.py
Outdated
| else: | ||
| y, logprobs = sample(logits) | ||
|
|
||
| tokens_ids = mx.concat([tokens_ids, y], axis=0) |
There was a problem hiding this comment.
Is this a bug? Shouldn't it be tokens?
8de0a15 to
824f7fd
Compare
|
I added logit_bias back because it's part of the OpenAI API spec and I don't want to break compatability with that. As a follow up, a nice thing to do would be to refactor out |
|
Do you mean adding If so, it might be beneficial to modify the |
|
I hadn't thought it through too carefully but yes what your describing is more or less what I had in mind.
Yea .. that may be cleaner. |
This update introduces token masking capabilities to the
generate_stepfunction via a newlogits_processorparameter. This enhancement supports constrained decoding scenarios that require token masking prior to sampling.Updates include:
logits_processorparameter ingenerate_stepfunction_stepfunctiongenerate_stepto describelogits_processorUsage example:
Here,
grammar_processorcould represent a custom constrained decoding approach.