Repository navigation
Conversation
…hout top_logprobs The chat handlers passed top_logprobs straight to create_completion as logprobs, so logprobs=true with top_logprobs unset became logprobs=None and the response had logprobs: null. Request zero extra candidates in that case so the sampled token's logprob is returned, as the OpenAI API does.
This branch has not been deployed
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.
create_chat_completion(logprobs=True)withouttop_logprobsreturns"logprobs": null. The OpenAI API returns the logprob of each generated token in that case, with an emptytop_logprobslist. Only requests that also settop_logprobsgot logprobs here. The server's chat endpoint passeslogprobs/top_logprobsthrough to the same handlers.The chat handlers pass
logprobs=top_logprobs if logprobs else Nonetocreate_completion, which treatsNoneas "no logprobs". Withtop_logprobsunset that expression isNone. The same line is in the generic formatter handler, Llava15ChatHandler, MTMDChatHandler and chatml_function_calling (two places).The five call sites now pass
(top_logprobs or 0) if logprobs else None, sologprobs=Truealone behaves likelogprobs=True, top_logprobs=0.logprobs=Falseand unset behave as before. Two things follow from that, both already true fortop_logprobs=0today:top_logprobslist has one entry, the sampled token itself, not an empty list (create_completionalways adds the sampled token).logits_all=False(theLlamadefault) now raisesValueError: logprobs is not supported for models created with logits_all=Falseforlogprobs=True, where it used to returnNone. The server defaults tologits_all=True.Tests:
pytest tests/test_llama_chat_format.pypasses (3); the new test fails on main (None == 0). Checked end to end with stories260K.gguf on macOS:logprobs=TruegaveNonebefore and 3 entries after, also when streaming;top_logprobs=0/2andlogprobs=Falseare unchanged. The server was not run.ruff checkandruff format --checkare clean. A changelog line is added under Unreleased.The implementation and tests were written with AI assistance.