[GH-ISSUE #1182] Bug: --json mode going into a infinite loop? #47114

Closed
opened 2026-04-28 03:16:34 -05:00 by GiteaMirror · 6 comments
Owner

Originally created by @hemanth on GitHub (Nov 17, 2023).
Original GitHub issue: https://github.com/ollama/ollama/issues/1182

Originally assigned to: @BruceMacD on GitHub.

/tmp took 37s 
❯ ollama run llama2 --format json
>>> give me 10 emojis with their meanings
{   

  

 

 

 

 .... # never ends for that input

https://github.com/jmorganca/ollama/assets/18315/6771fd1f-d0e3-4f1f-9e7b-e15bacf8acad

^ recording

Originally created by @hemanth on GitHub (Nov 17, 2023). Original GitHub issue: https://github.com/ollama/ollama/issues/1182 Originally assigned to: @BruceMacD on GitHub. ```sh /tmp took 37s ❯ ollama run llama2 --format json >>> give me 10 emojis with their meanings { .... # never ends for that input ``` https://github.com/jmorganca/ollama/assets/18315/6771fd1f-d0e3-4f1f-9e7b-e15bacf8acad ^ recording
GiteaMirror added the bug label 2026-04-28 03:16:34 -05:00
Author
Owner

@jmorganca commented on GitHub (Nov 17, 2023):

Hi @hemanth sorry you hit this issue. It's important sometimes to add Answer in JSON in the response so the model can better predict JSON fields (I'll still label this as a bug)

<!-- gh-comment-id:1817183106 --> @jmorganca commented on GitHub (Nov 17, 2023): Hi @hemanth sorry you hit this issue. It's important sometimes to add `Answer in JSON` in the response so the model can better predict JSON fields (I'll still label this as a bug)
Author
Owner

@hemanth commented on GitHub (Nov 17, 2023):

>>> give me 3 emojis and meanings in JSON format
{
  "emojis":[
    {"name":"😂", "meaning":"laughter"},
    {"name":"🤔", "meaning":"thoughtfulness"},
    {"name":"🎉", "meaning":"celebration"}
  ] 
}

Nice!

Interestingly:

>>> give me 5 emojis and meanings
{"emojis":[
"😂",
"🤔",
"🎉",
"🚀",
"👍"
] }

>>> give me 5 emojis and meanings in JSON format
{"emojis":[
{"name":"😂", "meaning":"laughter"},
{"name":"🤔", "meaning":"thoughtfulness"},
{"name":"🎉", "meaning":"celebration"},
{"name":"🚀", "meaning":"aspiration"},
{"name":"👍", "meaning":"approval"}
] }

<!-- gh-comment-id:1817216722 --> @hemanth commented on GitHub (Nov 17, 2023): ```sh >>> give me 3 emojis and meanings in JSON format { "emojis":[ {"name":"😂", "meaning":"laughter"}, {"name":"🤔", "meaning":"thoughtfulness"}, {"name":"🎉", "meaning":"celebration"} ] } ``` Nice! Interestingly: ```sh >>> give me 5 emojis and meanings {"emojis":[ "😂", "🤔", "🎉", "🚀", "👍" ] } >>> give me 5 emojis and meanings in JSON format {"emojis":[ {"name":"😂", "meaning":"laughter"}, {"name":"🤔", "meaning":"thoughtfulness"}, {"name":"🎉", "meaning":"celebration"}, {"name":"🚀", "meaning":"aspiration"}, {"name":"👍", "meaning":"approval"} ] } ```
Author
Owner

@igorschlum commented on GitHub (Nov 18, 2023):

For me it's working without specifying json in the prompt. (I have 32Gb on M1Pro MacBook)

(base) igor@macIgor ~ % ollama run llama2 --format json

give me 10 emojis with their meanings
{ "😊": "Happy", "👍": "Okay", "🤔": "Thinking", "🚀": "Space", "🎉": "Celebration", "💭": "Thoughts", "🤝":
"Friendship", "🌈": "Rainbow", "🏆": "Trophy", "📚": "Book" }

<!-- gh-comment-id:1817574613 --> @igorschlum commented on GitHub (Nov 18, 2023): For me it's working without specifying json in the prompt. (I have 32Gb on M1Pro MacBook) (base) igor@macIgor ~ % ollama run llama2 --format json >>> give me 10 emojis with their meanings { "😊": "Happy", "👍": "Okay", "🤔": "Thinking", "🚀": "Space", "🎉": "Celebration", "💭": "Thoughts", "🤝": "Friendship", "🌈": "Rainbow", "🏆": "Trophy", "📚": "Book" }
Author
Owner

@nathanleclaire commented on GitHub (Feb 7, 2024):

It seems to spin out of control for me quite often in the "REPL" mode specifically. It will just go nutty dumping newlines after it finishes the JSON object.

<!-- gh-comment-id:1933017316 --> @nathanleclaire commented on GitHub (Feb 7, 2024): It seems to spin out of control for me quite often in the "REPL" mode specifically. It will just go nutty dumping newlines after it finishes the JSON object.
Author
Owner

@BruceMacD commented on GitHub (Mar 12, 2024):

Resolving this to unify with #1910, which will be solved by #3080

<!-- gh-comment-id:1992315257 --> @BruceMacD commented on GitHub (Mar 12, 2024): Resolving this to unify with #1910, which will be solved by #3080
Author
Owner

@bitsydarel commented on GitHub (May 12, 2025):

This seems to be back with 0.6.8 on gemma3 and qwen3

<!-- gh-comment-id:2870547375 --> @bitsydarel commented on GitHub (May 12, 2025): This seems to be back with 0.6.8 on gemma3 and qwen3
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#47114