[GH-ISSUE #3355] Token limit #2062

Open
opened 2026-04-12 12:18:05 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @jmorganca on GitHub (Mar 26, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/3355

Originally assigned to: @BruceMacD on GitHub.

Ollama should stop generation after a token limit to avoid infinite generation

  • Add a done_reason field in the return object of the generate/chat apis, which defaults to stop if hit a stop word, limit if the context window size is hit
  • Truncate chat prompts more aggressively so we always have at least 25% of the context window available for generation
Originally created by @jmorganca on GitHub (Mar 26, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/3355 Originally assigned to: @BruceMacD on GitHub. Ollama should stop generation after a token limit to avoid infinite generation * Add a `done_reason` field in the return object of the generate/chat apis, which defaults to `stop` if hit a stop word, `limit` if the context window size is hit * Truncate chat prompts more aggressively so we always have at least 25% of the context window available for generation
GiteaMirror added the feature requestapi labels 2026-04-12 12:18:05 -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#2062