[PR #2605] [CLOSED] Basic whitespace detection in JSON mode #73239

Closed
opened 2026-05-05 04:58:35 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/2605
Author: @jmorganca
Created: 2/20/2024
Status: Closed

Base: mainHead: whitespace-detection


📝 Commits (1)

  • aae31dc naive whitespace detection

📊 Changes

1 file changed (+19 additions, -0 deletions)

View changed files

📝 llm/dyn_ext_server.go (+19 -0)

📄 Description

This stops hanging from infinite whitespace generation by detecting 100 consecutive whitespace tokens and cancelling

Other ideas:

  • Repetition detection – detect the repetition of the same string over and over again
  • Only do this after detecting a full json object
  • Lower whitespace logit bias when using JSON mode (might affect outcome of the response)
  • Force user to specify JSON in the prompt (might be hard for folks to know this, this is what OpenAI does)

🔄 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/2605 **Author:** [@jmorganca](https://github.com/jmorganca) **Created:** 2/20/2024 **Status:** ❌ Closed **Base:** `main` ← **Head:** `whitespace-detection` --- ### 📝 Commits (1) - [`aae31dc`](https://github.com/ollama/ollama/commit/aae31dc6edab0781a00c9fab45f8d27967935905) naive whitespace detection ### 📊 Changes **1 file changed** (+19 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `llm/dyn_ext_server.go` (+19 -0) </details> ### 📄 Description This stops hanging from infinite whitespace generation by detecting 100 consecutive whitespace tokens and cancelling Other ideas: - [ ] Repetition detection – detect the repetition of the same string over and over again - [ ] Only do this after detecting a full json object - [ ] Lower whitespace logit bias when using JSON mode (might affect outcome of the response) - [ ] Force user to specify `JSON` in the prompt (might be hard for folks to know this, this is what OpenAI does) --- <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-05-05 04:58:35 -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#73239