[PR #14692] runner: preserve raw token bytes in logprobs #25329

Open
opened 2026-04-19 18:09:21 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/14692
Author: @eyupcanakman
Created: 3/7/2026
Status: 🔄 Open

Base: mainHead: fix/logprobs-utf8-bytes-13497


📝 Commits (2)

  • b994f77 runner: preserve raw token bytes in logprobs
  • b6b43c0 runner: trim redundant comments

📊 Changes

9 files changed (+215 additions, -28 deletions)

View changed files

📝 llama/llama.go (+10 -2)
llm/logprob_test.go (+32 -0)
📝 llm/server.go (+2 -0)
📝 runner/common/logprob.go (+6 -4)
📝 runner/common/logprob_test.go (+58 -17)
📝 runner/llamarunner/runner.go (+5 -1)
📝 runner/ollamarunner/runner.go (+2 -2)
📝 server/logprob.go (+14 -2)
server/logprob_test.go (+86 -0)

📄 Description

When logprobs are on, partial UTF-8 tokens get their bytes mangled to U+FFFD during JSON between the runner and server. The API returns [239, 191, 189] instead of the real bytes like [240].

Added a Bytes field to the internal TokenLogprob that gets filled straight from the C tokenizer (before string conversion). The server uses it when available, falls back to the string for older runners.

Fixes #13497


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/14692 **Author:** [@eyupcanakman](https://github.com/eyupcanakman) **Created:** 3/7/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/logprobs-utf8-bytes-13497` --- ### 📝 Commits (2) - [`b994f77`](https://github.com/ollama/ollama/commit/b994f7704afb59962ebcd7e858aecbdda11076c5) runner: preserve raw token bytes in logprobs - [`b6b43c0`](https://github.com/ollama/ollama/commit/b6b43c090aa748901eaabf4dc8071322b3598625) runner: trim redundant comments ### 📊 Changes **9 files changed** (+215 additions, -28 deletions) <details> <summary>View changed files</summary> 📝 `llama/llama.go` (+10 -2) ➕ `llm/logprob_test.go` (+32 -0) 📝 `llm/server.go` (+2 -0) 📝 `runner/common/logprob.go` (+6 -4) 📝 `runner/common/logprob_test.go` (+58 -17) 📝 `runner/llamarunner/runner.go` (+5 -1) 📝 `runner/ollamarunner/runner.go` (+2 -2) 📝 `server/logprob.go` (+14 -2) ➕ `server/logprob_test.go` (+86 -0) </details> ### 📄 Description When logprobs are on, partial UTF-8 tokens get their bytes mangled to U+FFFD during JSON between the runner and server. The API returns [239, 191, 189] instead of the real bytes like [240]. Added a Bytes field to the internal TokenLogprob that gets filled straight from the C tokenizer (before string conversion). The server uses it when available, falls back to the string for older runners. Fixes #13497 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-19 18:09:21 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#25329