[GH-ISSUE #7256] Last character being truncated by stop sequence #51123

Closed
opened 2026-04-28 18:29:28 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @someone13574 on GitHub (Oct 18, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/7256

Originally assigned to: @dhiltgen on GitHub.

What is the issue?

When running inference in raw mode with '\n\n' as a stop sequence, it seems like punctuation is being removed with the stop sequence. I assume this is because of a bug with how partial stop sequences are handled.

OS

Linux

GPU

Other

CPU

AMD

Ollama version

0.3.11

Originally created by @someone13574 on GitHub (Oct 18, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/7256 Originally assigned to: @dhiltgen on GitHub. ### What is the issue? When running inference in raw mode with '\n\n' as a stop sequence, it seems like punctuation is being removed with the stop sequence. I assume this is because of a bug with how partial stop sequences are handled. ### OS Linux ### GPU Other ### CPU AMD ### Ollama version 0.3.11
GiteaMirror added the bugneeds more info labels 2026-04-28 18:29:29 -05:00
Author
Owner

@someone13574 commented on GitHub (Oct 18, 2024):

Found a PR in llama.cpp fixing the issue. https://github.com/ggerganov/llama.cpp/pull/9867

<!-- gh-comment-id:2423207565 --> @someone13574 commented on GitHub (Oct 18, 2024): Found a PR in llama.cpp fixing the issue. https://github.com/ggerganov/llama.cpp/pull/9867
Author
Owner

@dhiltgen commented on GitHub (Oct 23, 2024):

@someone13574 we're just about to remove server.cpp and switch to the Go based runner, which has different parsing logic. Could you try out the 0.4.0 RC and see if it exhibits the same problem?

https://github.com/ollama/ollama/releases

<!-- gh-comment-id:2432729939 --> @dhiltgen commented on GitHub (Oct 23, 2024): @someone13574 we're just about to [remove server.cpp](https://github.com/ollama/ollama/pull/7157) and switch to the [Go based runner](https://github.com/ollama/ollama/blob/main/docs/development.md#transition-to-go-runner), which has different parsing logic. Could you try out the 0.4.0 RC and see if it exhibits the same problem? https://github.com/ollama/ollama/releases
Author
Owner

@pdevine commented on GitHub (Oct 3, 2025):

I think this issue is pretty old, but I did test it out just to make certain it was working. I used ChatGPT as the stop parameter just to be obvious. Here's the full test using raw mode:

% curl localhost:11434/api/generate -d '{"raw": true, "model": "gpt-oss:20b", "prompt": "<|start|>system<|message|>You are ChatGPT, a large language model trained by OpenAI.\nKnowledge cutoff: 2024-06\nCurrent date: 2025-10-03\n\nReasoning: medium\n\n# Valid channels: analysis, commentary, final. Channel must be included for every message.<|end|><|start|>user<|message|>Hello friend!<|end|><|start|>assistant<|channel|>final<|message|>Hello human!<|end|><|start|>user<|message|>What is your name?<|end|><|start|>assistant", "options": {"stop": ["ChatGPT"]}, "stream": false}'
{"model":"gpt-oss:20b","created_at":"2025-10-03T22:16:20.34754Z","response":"\u003c|channel|\u003eanalysis\u003c|message|\u003eWe need to answer politely.\u003c|end|\u003e\u003c|start|\u003eassistant\u003c|channel|\u003efinal\u003c|message|\u003eI’m ","done":true,"done_reason":"stop","total_duration":612033125,"load_duration":91495417,"prompt_eval_count":88,"prompt_eval_duration":266511417,"eval_count":19,"eval_duration":253525791}
<!-- gh-comment-id:3367379250 --> @pdevine commented on GitHub (Oct 3, 2025): I think this issue is pretty old, but I did test it out just to make certain it was working. I used `ChatGPT` as the stop parameter just to be obvious. Here's the full test using raw mode: ``` % curl localhost:11434/api/generate -d '{"raw": true, "model": "gpt-oss:20b", "prompt": "<|start|>system<|message|>You are ChatGPT, a large language model trained by OpenAI.\nKnowledge cutoff: 2024-06\nCurrent date: 2025-10-03\n\nReasoning: medium\n\n# Valid channels: analysis, commentary, final. Channel must be included for every message.<|end|><|start|>user<|message|>Hello friend!<|end|><|start|>assistant<|channel|>final<|message|>Hello human!<|end|><|start|>user<|message|>What is your name?<|end|><|start|>assistant", "options": {"stop": ["ChatGPT"]}, "stream": false}' {"model":"gpt-oss:20b","created_at":"2025-10-03T22:16:20.34754Z","response":"\u003c|channel|\u003eanalysis\u003c|message|\u003eWe need to answer politely.\u003c|end|\u003e\u003c|start|\u003eassistant\u003c|channel|\u003efinal\u003c|message|\u003eI’m ","done":true,"done_reason":"stop","total_duration":612033125,"load_duration":91495417,"prompt_eval_count":88,"prompt_eval_duration":266511417,"eval_count":19,"eval_duration":253525791} ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#51123