[GH-ISSUE #4724] empty response #80659

Closed
opened 2026-05-09 09:16:37 -05:00 by GiteaMirror · 7 comments
Owner

Originally created by @themw123 on GitHub (May 30, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/4724

What is the issue?

I am getting an empty response string with llama3:8b.
Different models like mistral-instruct are working fine.

Setup:

  • windows 11
  • newest ollama version
  • llama3:8b(latest)

When context gets to high (approximately after exchanging 20 question/answer pairs) by appending the history with every request, i get an empty response from time to time like in 30% of responses.

Here is my code:

self.messages = [{"role": "system", "content": system_role}]
self.messages.append({"role": "user", "content": my_input_text})

url = "http://localhost:11434/api/chat"
data = {
    "model": "llama3:8b",
    "messages": self.messages,
    "stream": True
}
response = requests.post(url, json=data)   

for chunk in response.iter_lines():
    if chunk:
        chunk = chunk.decode('utf-8')
        chunk = json.loads(chunk)
        content = chunk['message']['content']
        print(content, end="", flush=True)
        yield content

OS

Windows

GPU

Nvidia

CPU

AMD

Ollama version

0.1.39

Originally created by @themw123 on GitHub (May 30, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/4724 ### What is the issue? I am getting an empty response string with llama3:8b. Different models like mistral-instruct are working fine. Setup: - windows 11 - newest ollama version - llama3:8b(latest) When context gets to high (approximately after exchanging 20 question/answer pairs) by appending the history with every request, i get an empty response from time to time like in 30% of responses. Here is my code: ``` self.messages = [{"role": "system", "content": system_role}] self.messages.append({"role": "user", "content": my_input_text}) url = "http://localhost:11434/api/chat" data = { "model": "llama3:8b", "messages": self.messages, "stream": True } response = requests.post(url, json=data) for chunk in response.iter_lines(): if chunk: chunk = chunk.decode('utf-8') chunk = json.loads(chunk) content = chunk['message']['content'] print(content, end="", flush=True) yield content ``` ### OS Windows ### GPU Nvidia ### CPU AMD ### Ollama version 0.1.39
GiteaMirror added the bug label 2026-05-09 09:16:37 -05:00
Author
Owner

@dominikvalk commented on GitHub (Jun 5, 2024):

same for me.

<!-- gh-comment-id:2150666245 --> @dominikvalk commented on GitHub (Jun 5, 2024): same for me.
Author
Owner

@MoritzHinterleitner commented on GitHub (Jun 5, 2024):

same for me. llama 3 and 2 with several messages and instant empty response
Edit: it seems to only happen for me if I give the array of messages and a promt at the same time. Might not be the same issue as it works for me now

<!-- gh-comment-id:2150790974 --> @MoritzHinterleitner commented on GitHub (Jun 5, 2024): same for me. llama 3 and 2 with several messages and instant empty response Edit: it seems to only happen for me if I give the array of messages and a promt at the same time. Might not be the same issue as it works for me now
Author
Owner

@Qualzz commented on GitHub (Jun 30, 2024):

Same for me with gemma2, llama3.

What is weird is that using open web ui, long contexts works fine, but using the ollama.js chat function, > 512 token and the answer are empty with "model does not support sliding window, limiting generation" visible in the ollama logs

<!-- gh-comment-id:2198797693 --> @Qualzz commented on GitHub (Jun 30, 2024): Same for me with gemma2, llama3. What is weird is that using open web ui, long contexts works fine, but using the ollama.js chat function, > 512 token and the answer are empty with "`model does not support sliding window, limiting generation`" visible in the ollama logs
Author
Owner

@SheMelody commented on GitHub (Jul 3, 2024):

This seems to be an issue specific to Windows. I'm having the same exact problem. When using ollama on Linux it's perfectly fine, I literally had zero issues in there, same versions.

EDIT: I have instantly found a solution. Before running your scripts and program, make sure you do it from powershell and use the following commands before running them:

$OutputEncoding=[Text.Encoding]::UTF8
[Console]::OutputEncoding=[Text.Encoding]::UTF8

As I imagined, this was simply a problem with text encoding and was causing wrong interpretation through client and server. It's all fine now for me.

Edit 2: The issue at hand says "getting empty responses 30% of the times", which was exactly what was happening to me especially when it was generating fast. I don't know if it's the same exact specific issue, but this seems to have solved it for me.

<!-- gh-comment-id:2206326895 --> @SheMelody commented on GitHub (Jul 3, 2024): This seems to be an issue specific to Windows. I'm having the same exact problem. When using ollama on Linux it's perfectly fine, I literally had zero issues in there, same versions. EDIT: I have instantly found a solution. Before running your scripts and program, make sure you do it from powershell and use the following commands before running them: ``` $OutputEncoding=[Text.Encoding]::UTF8 [Console]::OutputEncoding=[Text.Encoding]::UTF8 ``` As I imagined, this was simply a problem with text encoding and was causing wrong interpretation through client and server. It's all fine now for me. Edit 2: The issue at hand says "getting empty responses 30% of the times", which was exactly what was happening to me especially when it was generating fast. I don't know if it's the same exact specific issue, but this seems to have solved it for me.
Author
Owner

@pdevine commented on GitHub (Sep 12, 2024):

I'm having a hard time reproducing this in Windows (and haven't seen it in either Linux or MacOS). I've been trying with Windows 11 and a 7900 XTX, but no luck.

Given the issue was opened in May, let's go ahead and close it, but if someone can repro I can reopen.

<!-- gh-comment-id:2347398366 --> @pdevine commented on GitHub (Sep 12, 2024): I'm having a hard time reproducing this in Windows (and haven't seen it in either Linux or MacOS). I've been trying with Windows 11 and a 7900 XTX, but no luck. Given the issue was opened in May, let's go ahead and close it, but if someone can repro I can reopen.
Author
Owner

@v3ss0n commented on GitHub (Sep 25, 2024):

Is this bug solved? i am still encountering. Why this is closed as completed? which PR fixes it?

<!-- gh-comment-id:2374643944 --> @v3ss0n commented on GitHub (Sep 25, 2024): Is this bug solved? i am still encountering. Why this is closed as completed? which PR fixes it?
Author
Owner

@codejq commented on GitHub (Jan 25, 2025):

For me, the issue was, that I set the temperature to 0.5 and I had to change it ti to 0.1 and I had to omit the format: JSON

<!-- gh-comment-id:2614038251 --> @codejq commented on GitHub (Jan 25, 2025): For me, the issue was, that I set the temperature to 0.5 and I had to change it ti to 0.1 and I had to omit the format: JSON
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#80659