[GH-ISSUE #201] Adding extra/unexpected spaces when generating code (at least for Java code) #144

Closed
opened 2026-10-26 21:15:16 +00:00 by bsakaguchi · 4 comments
Owner

Originally created by @mario-mlc on GitHub (Jan 30, 2025).
Original GitHub issue: https://github.com/deepseek-ai/DeepSeek-R1/issues/201

Using Deepseek-r1:27b (default version available at ollama.com) and even with 70b, after some prompts, it generates some extra spaces on code after dots and even underscores (_), real case example:

package com. redacted. name_ with_ underscores. dto; 

import com. fasterxml. jackson. annotation. JsonInclude;
import com. fasterxml. jackson. annotation. JsonProperty;
import com. fasterxml. jackson. annotation. JsonRootName;
import lombok. Getter;
import lombok. Setter;
import lombok. ToString;
import lombok. AllArgsConstructor;
import lombok. NoArgsConstructor;

Observe there are spaces after the dots and the underscores... out of nothing, it starts doing this. Not very critical since I can issue a next prompt telling the model it is doing it and to please refactor the code without it, then it generates the code correctly for a couple more prompts and then it starts doing it again... considerably annoying.
Running through last version of ollama (0.5.7) and Open WebUI. It does not always occur, it is somewhat random when it starts and, when you complain to the model, also random when it forgets and starts doing it again. Downloaded the models from ollama.com (using ollama pull) the next day they became available. No new updates so far.

Originally created by @mario-mlc on GitHub (Jan 30, 2025). Original GitHub issue: https://github.com/deepseek-ai/DeepSeek-R1/issues/201 Using Deepseek-r1:27b (default version available at ollama.com) and even with 70b, after some prompts, it generates some extra spaces on code after dots and even underscores (_), real case example: ``` package com. redacted. name_ with_ underscores. dto; import com. fasterxml. jackson. annotation. JsonInclude; import com. fasterxml. jackson. annotation. JsonProperty; import com. fasterxml. jackson. annotation. JsonRootName; import lombok. Getter; import lombok. Setter; import lombok. ToString; import lombok. AllArgsConstructor; import lombok. NoArgsConstructor; ``` Observe there are spaces after the dots and the underscores... out of nothing, it starts doing this. Not very critical since I can issue a next prompt telling the model it is doing it and to please refactor the code without it, then it generates the code correctly for a couple more prompts and then it starts doing it again... considerably annoying. Running through last version of ollama (0.5.7) and Open WebUI. It does not always occur, it is somewhat random when it starts and, when you complain to the model, also random when it forgets and starts doing it again. Downloaded the models from ollama.com (using ollama pull) the next day they became available. No new updates so far.
bsakaguchi 2026-10-26 21:15:16 +00:00
Author
Owner

@dinithaw commented on GitHub (Feb 1, 2025):

Damn that's unusual 😅
I would paste it vs code and reformat the code using ctrl+shift+i
Or tell github copilot to do it

<!-- gh-comment-id:2628837856 --> @dinithaw commented on GitHub (Feb 1, 2025): Damn that's unusual 😅 I would paste it vs code and reformat the code using ctrl+shift+i Or tell github copilot to do it
Author
Owner

@wangjiyang commented on GitHub (Feb 5, 2025):

I have same issue. Seems it is caused by model itself instead of prompt template. C++ code for me.

<!-- gh-comment-id:2637729902 --> @wangjiyang commented on GitHub (Feb 5, 2025): I have same issue. Seems it is caused by model itself instead of prompt template. C++ code for me.
Author
Owner

@github-actions[bot] commented on GitHub (Mar 10, 2025):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe this issue is still relevant, please leave a comment to keep it open. Thank you for your contributions!

<!-- gh-comment-id:2709148906 --> @github-actions[bot] commented on GitHub (Mar 10, 2025): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe this issue is still relevant, please leave a comment to keep it open. Thank you for your contributions!
Author
Owner

@github-actions[bot] commented on GitHub (Apr 5, 2025):

false

<!-- gh-comment-id:2779931485 --> @github-actions[bot] commented on GitHub (Apr 5, 2025): false
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
deepseek-ai/DeepSeek-R1#144
No description provided.