Skip to content

Add GemmaModel.score_next to the Python binding. - #1053

Merged
copybara-service[bot] merged 1 commit into
devfrom
test_996092908
Oct 12, 2026
Merged

copybara-service[bot] merged 1 commit into
devfrom
test_996092908

Conversation

@copybara-service

@copybara-service copybara-service Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Add GemmaModel.score_next to the Python binding.

score_next(prompt, candidates) returns, for each candidate string, the
probability that the next token after the prompt is that candidate's first
token, from the full-vocabulary softmax (ops-inl.h Softmax) of the next-token
logits. It uses RuntimeConfig::sample_func for one decode step and restores the
config afterwards. get_last_prob() cannot serve this: with the default
top_k == 1 it reports the softmax over the top-1 token, so it is always 1.0.

@google-cla

google-cla Bot commented Oct 8, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@copybara-service
copybara-service Bot force-pushed the test_996092908 branch 5 times, most recently from 060962c to 7cd5c67 Compare October 12, 2026 15:37
score_next(prompt, candidates) returns, for each candidate string, the
probability that the next token after the prompt is that candidate's first
token, from the full-vocabulary softmax (ops-inl.h Softmax) of the next-token
logits. It uses RuntimeConfig::sample_func for one decode step and restores the
config afterwards. get_last_prob() cannot serve this: with the default
top_k == 1 it reports the softmax over the top-1 token, so it is always 1.0.
PiperOrigin-RevId: 997943475
@copybara-service
copybara-service Bot merged commit e9da305 into dev Oct 12, 2026
10 checks passed
@copybara-service
copybara-service Bot deleted the test_996092908 branch October 12, 2026 15:46
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.

0 participants