Skip to content

llm-server --replay: score teacher-forced logprobs - #295

Open
stikves wants to merge 2 commits into
apple:mainfrom
stikves:sukru/replay-logprobs
Open

stikves wants to merge 2 commits into
apple:mainfrom
stikves:sukru/replay-logprobs

Conversation

@stikves

@stikves stikves commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Extends the socket-free --replay path (previously chat-only) so it can also drive the chat-completions loglikelihood scorer behind /v1/completions. This lets teacher-forced perplexity be validated by replaying a JSONL file, with no HTTP surface.

Details

  • ReplayRequest now carries exactly one of two bodies per line: request (a chat completion) or loglikelihood (a scoring request). A custom decoder rejects a line that has neither or both, keeping each record unambiguous.
  • ReplayResult gains optional tokens / token_logprobs / text_offset. These are present only for loglikelihood lines and are omitted for chat lines via the synthesized optional encoding.
  • The loglikelihood scoring logic is factored into a socket-free runLoglikelihood(req:state:) core, shared by the HTTP handler and --replay.
  • ReplayRunner branches on the body type and keeps the sequential-only guard (loglikelihood scoring requires --variant coreai-sequential).

Additive change; chat replay behavior is unchanged.

Extend the socket-free --replay path (previously chat-only) to drive the
chat-completions loglikelihood scorer, so perplexity can be validated without
an HTTP surface.

- ReplayRequest carries exactly one of `request` (chat) or `loglikelihood`
  (a CompletionRequest); the decoder rejects neither/both.
- ReplayResult gains tokens / token_logprobs / text_offset, omitted for chat
  lines via the synthesized optional encoding.
- Extract a socket-free runLoglikelihood(req:state:) core from the HTTP handler;
  ReplayRunner branches on the body type and keeps the sequential-only guard.
@stikves stikves self-assigned this Sep 27, 2026
@stikves
stikves marked this pull request as ready for review September 28, 2026 17:35
@stikves stikves closed this Sep 29, 2026
@stikves stikves reopened this Sep 29, 2026
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