[GH-ISSUE #10960] Ollama appears to corrupt deepseek-r1:7b model #53734

Closed
opened 2026-04-29 04:36:57 -05:00 by GiteaMirror · 6 comments
Owner

Originally created by @RetroDev256 on GitHub (Jun 3, 2025).
Original GitHub issue: https://github.com/ollama/ollama/issues/10960

What is the issue?

Certain trivial inputs cause deepseek-r1:7b to enter an infinite thinking loop, and the AI output appears mangled after several minutes. Attached is a script recording. Here is an asciinema link: https://asciinema.org/a/721755

Relevant log output

(not embedded because it's too large)
deepseek_trash.txt

OS

Linux (Gentoo)

GPU

NVIDIA GeForce RTX 4060 Laptop GPU

CPU

Intel(R) Core(TM) i9-14900HX

Ollama version

ollama version is 0.9.0

Originally created by @RetroDev256 on GitHub (Jun 3, 2025). Original GitHub issue: https://github.com/ollama/ollama/issues/10960 ### What is the issue? Certain trivial inputs cause deepseek-r1:7b to enter an infinite thinking loop, and the AI output appears mangled after several minutes. Attached is a `script` recording. Here is an asciinema link: https://asciinema.org/a/721755 ### Relevant log output (not embedded because it's too large) [deepseek_trash.txt](https://github.com/user-attachments/files/20579938/deepseek_trash.txt) ### OS Linux (Gentoo) ### GPU NVIDIA GeForce RTX 4060 Laptop GPU ### CPU Intel(R) Core(TM) i9-14900HX ### Ollama version ollama version is 0.9.0
GiteaMirror added the bug label 2026-04-29 04:36:57 -05:00
Author
Owner

@rick-github commented on GitHub (Jun 3, 2025):

The model might be spending so many tokens thinking that it runs out of space, causing it to lose cohesion. Increase the context length and see if the output improves. Server logs may aid in debugging.

<!-- gh-comment-id:2937057705 --> @rick-github commented on GitHub (Jun 3, 2025): The model might be spending so many tokens thinking that it runs out of space, causing it to lose cohesion. Increase the [context length](https://github.com/ollama/ollama/blob/main/docs/faq.md#how-can-i-specify-the-context-window-size) and see if the output improves. [Server logs](https://github.com/ollama/ollama/blob/main/docs/troubleshooting.md#how-to-troubleshoot-issues) may aid in debugging.
Author
Owner

@RetroDev256 commented on GitHub (Jun 3, 2025):

Thanks! That makes sense. After boosting the context length, it returns an answer.
Image
EDIT: server logs don't show anything unique for shorter context length.

<!-- gh-comment-id:2937317190 --> @RetroDev256 commented on GitHub (Jun 3, 2025): Thanks! That makes sense. After boosting the context length, it returns an answer. ![Image](https://github.com/user-attachments/assets/230c2745-c13e-4461-a7d9-f3a87fbc6872) EDIT: server logs don't show anything unique for shorter context length.
Author
Owner

@rick-github commented on GitHub (Jun 3, 2025):

I think if you enabled debugging (OLLAMA_DEBUG=1 in the server environment) you will see messages about shifting, which indicates a context buffer overflow.

<!-- gh-comment-id:2937343442 --> @rick-github commented on GitHub (Jun 3, 2025): I think if you enabled debugging (`OLLAMA_DEBUG=1` in the server environment) you will see messages about shifting, which indicates a context buffer overflow.
Author
Owner

@RetroDev256 commented on GitHub (Jun 3, 2025):

Yep, it's there alright.
Image
Is this an issue that ollama would be expected to fix? Or is the behavior expected? Wondering if the issue should be closed.

<!-- gh-comment-id:2937425181 --> @RetroDev256 commented on GitHub (Jun 3, 2025): Yep, it's there alright. ![Image](https://github.com/user-attachments/assets/366ab962-4fe1-4b9b-8a67-073daa879929) Is this an issue that ollama would be expected to fix? Or is the behavior expected? Wondering if the issue should be closed.
Author
Owner

@rick-github commented on GitHub (Jun 3, 2025):

It comes down to a configuration issue. Thinking models are token hungry, and ollama recently increased the default length partly in response, but some models are just thinkier than others. There are downsides to having ollama guess at the amount required, so it's up to the user to set limits. Hand-in-hand with num_ctx is num_predict, which limits the number of tokens that can be generated.

<!-- gh-comment-id:2937451820 --> @rick-github commented on GitHub (Jun 3, 2025): It comes down to a configuration issue. Thinking models are token hungry, and ollama recently increased the default length partly in response, but some models are just thinkier than others. There are downsides to having ollama guess at the amount required, so it's up to the user to set limits. Hand-in-hand with `num_ctx` is `num_predict`, which limits the number of tokens that can be generated.
Author
Owner

@RetroDev256 commented on GitHub (Jun 3, 2025):

Thanks for the info! I solved my issue by creating a modelfile for deepseek-r1:7b which increased the number of tokens for the context, and I'll be sure to also set num_predict.

<!-- gh-comment-id:2937455752 --> @RetroDev256 commented on GitHub (Jun 3, 2025): Thanks for the info! I solved my issue by creating a modelfile for `deepseek-r1:7b` which increased the number of tokens for the context, and I'll be sure to also set `num_predict`.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#53734