feat: Logprobs API + structural tag constraint for tool calls#5
Merged
raullenchai merged 1 commit intomainfrom Feb 25, 2026
Merged
feat: Logprobs API + structural tag constraint for tool calls#5raullenchai merged 1 commit intomainfrom
raullenchai merged 1 commit intomainfrom
Conversation
57cadf4 to
ecedbf5
Compare
Logprobs: Propagate mlx-lm per-token logprobs through the full stack (StreamingOutput → GenerationOutput → API response). Supports both streaming and non-streaming chat completions with top_logprobs (0-20). Structural tags: Extend MiniMaxToolLogitsProcessor with parameter value schema tracking — biases toward valid JSON types (string/number/boolean/ object/array) at the start of parameter values. SimpleEngine gets post-generation validation with warning logs for schema mismatches. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ecedbf5 to
ccceab9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
logprobs: trueandtop_logprobs: 0-20per OpenAI spec.MiniMaxToolLogitsProcessorwith parameter value schema tracking — biases toward valid JSON types (string/number/boolean/object/array) at the start of parameter values during generation. SimpleEngine gets post-generation validation with warning logs for schema mismatches.response_formatschemas (wrapsbuild_json_system_promptandparse_json_outputin try/except).Changes
api/models.pyTopLogProb,TokenLogProb,ChoiceLogProbsmodels; addlogprobs/top_logprobsto request/response typesmodels/llm.pyresponse.logprobs(mx.array) throughStreamingOutputengine/base.pylogprobs: AnytoGenerationOutputengine/simple.pyapi/tool_logits.pyvalidate_param_value(),_extract_param_schemas()server.py_extract_token_logprob()helper, top_logprobs validation, streaming/non-streaming logprobs wiring,_validate_tool_call_params()post-generation checkapi/tool_calling.pyjson.dumps(schema)to prevent crash on non-serializable schemasTest plan
pytest tests/test_api_models.py— model schema tests pass (72 tests)pytest tests/test_tool_logits.py— tool logits processor tests pass (9 tests)pytest tests/test_server.py— server endpoint tests pass (34 tests)curlwithlogprobs: true, top_logprobs: 5returns token-level logprobs🤖 Generated with Claude Code