Sitelet https://github.com/WestWaters/pollard-weights/pull/140
Skip to content

Correct served KL calculation for truncated logprobs - #140

Open
SloptimistPrime wants to merge 1 commit into
WestWaters:mainfrom
SloptimistPrime:contrib/served-kl
Open

SloptimistPrime wants to merge 1 commit into
WestWaters:mainfrom
SloptimistPrime:contrib/served-kl

Conversation

@SloptimistPrime

Copy link
Copy Markdown

The old calculation summed only shared top-logprob entries and divided by their count. It could report a negative KL score.

Use shared tokens plus the remaining probability mass, then average per position. The output labels this as coarsened KL, a lower bound rather than full-vocabulary KL. Also reject invalid probabilities and nonpositive strides.

13 tests pass, including known cases, an HTTP comparison and 200 randomized truncations. This fixes the evaluator; it does not establish that one quantization recipe beats another.

I used AI assistance and reviewed and tested the changes.

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.

1 participant