[GH-ISSUE #1967] Small context size limit occasionally causes Ollama to hang on prediction #26895

Closed
opened 2026-04-22 03:36:21 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @BruceMacD on GitHub (Jan 12, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/1967

While testing #1963 I noticed that occasionally a small context window causes the response to hang (maybe indefinitely?).

Here is an example:

curl http://localhost:11434/api/chat -d '{
    "model": "llama2",
    "messages": [
        {
            "role": "user",
            "content": "hi"
        },
        {
            "role": "assistant",
            "content": "Hi there! How can I help you today?"
        },
        {
            "role": "user",
            "content": "what is your name?"
        },
        {
            "role": "assistant",
            "content": "My name is Bard."
        },
        {
            "role": "user",
            "content": "my name is joe"
        }
    ],
    "options": {
        "num_ctx": 30
    }
}'
{"model":"llama2","created_at":"2024-01-12T20:40:01.125385Z","message":{"role":"assistant","content":"Hello"},"done":false}
{"model":"llama2","created_at":"2024-01-12T20:40:01.139753Z","message":{"role":"assistant","content":" Joe"},"done":false}
{"model":"llama2","created_at":"2024-01-12T20:40:01.168206Z","message":{"role":"assistant","content":"!"},"done":false}
{"model":"llama2","created_at":"2024-01-12T20:40:01.18237Z","message":{"role":"assistant","content":" *"},"done":false}
{"model":"llama2","created_at":"2024-01-12T20:40:01.196786Z","message":{"role":"assistant","content":"g"},"done":false}
{"model":"llama2","created_at":"2024-01-12T20:40:01.210965Z","message":{"role":"assistant","content":"igg"},"done":false}
{"model":"llama2","created_at":"2024-01-12T20:40:01.225267Z","message":{"role":"assistant","content":"les"},"done":false}
{"model":"llama2","created_at":"2024-01-12T20:40:01.23965Z","message":{"role":"assistant","content":"*"},"done":false}
{"model":"llama2","created_at":"2024-01-12T20:40:01.253971Z","message":{"role":"assistant","content":" It"},"done":false}
{"model":"llama2","created_at":"2024-01-12T20:40:01.268295Z","message":{"role":"assistant","content":"'"},"done":false}
{"model":"llama2","created_at":"2024-01-12T20:40:01.282805Z","message":{"role":"assistant","content":"s"},"done":false}
{"model":"llama2","created_at":"2024-01-12T20:40:01.296887Z","message":{"role":"assistant","content":" nice"},"done":false}
{"model":"llama2","created_at":"2024-01-12T20:40:01.311215Z","message":{"role":"assistant","content":" to"},"done":false}
{"model":"llama2","created_at":"2024-01-12T20:40:01.325513Z","message":{"role":"assistant","content":" meet"},"done":false}
{"model":"llama2","created_at":"2024-01-12T20:40:01.339753Z","message":{"role":"assistant","content":" you"},"done":false}
{"model":"llama2","created_at":"2024-01-12T20:40:01.353986Z","message":{"role":"assistant","content":"."},"done":false}
{"model":"llama2","created_at":"2024-01-12T20:40:01.367968Z","message":{"role":"assistant","content":" "},"done":false}
Originally created by @BruceMacD on GitHub (Jan 12, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/1967 While testing #1963 I noticed that occasionally a small context window causes the response to hang (maybe indefinitely?). Here is an example: ``` curl http://localhost:11434/api/chat -d '{ "model": "llama2", "messages": [ { "role": "user", "content": "hi" }, { "role": "assistant", "content": "Hi there! How can I help you today?" }, { "role": "user", "content": "what is your name?" }, { "role": "assistant", "content": "My name is Bard." }, { "role": "user", "content": "my name is joe" } ], "options": { "num_ctx": 30 } }' {"model":"llama2","created_at":"2024-01-12T20:40:01.125385Z","message":{"role":"assistant","content":"Hello"},"done":false} {"model":"llama2","created_at":"2024-01-12T20:40:01.139753Z","message":{"role":"assistant","content":" Joe"},"done":false} {"model":"llama2","created_at":"2024-01-12T20:40:01.168206Z","message":{"role":"assistant","content":"!"},"done":false} {"model":"llama2","created_at":"2024-01-12T20:40:01.18237Z","message":{"role":"assistant","content":" *"},"done":false} {"model":"llama2","created_at":"2024-01-12T20:40:01.196786Z","message":{"role":"assistant","content":"g"},"done":false} {"model":"llama2","created_at":"2024-01-12T20:40:01.210965Z","message":{"role":"assistant","content":"igg"},"done":false} {"model":"llama2","created_at":"2024-01-12T20:40:01.225267Z","message":{"role":"assistant","content":"les"},"done":false} {"model":"llama2","created_at":"2024-01-12T20:40:01.23965Z","message":{"role":"assistant","content":"*"},"done":false} {"model":"llama2","created_at":"2024-01-12T20:40:01.253971Z","message":{"role":"assistant","content":" It"},"done":false} {"model":"llama2","created_at":"2024-01-12T20:40:01.268295Z","message":{"role":"assistant","content":"'"},"done":false} {"model":"llama2","created_at":"2024-01-12T20:40:01.282805Z","message":{"role":"assistant","content":"s"},"done":false} {"model":"llama2","created_at":"2024-01-12T20:40:01.296887Z","message":{"role":"assistant","content":" nice"},"done":false} {"model":"llama2","created_at":"2024-01-12T20:40:01.311215Z","message":{"role":"assistant","content":" to"},"done":false} {"model":"llama2","created_at":"2024-01-12T20:40:01.325513Z","message":{"role":"assistant","content":" meet"},"done":false} {"model":"llama2","created_at":"2024-01-12T20:40:01.339753Z","message":{"role":"assistant","content":" you"},"done":false} {"model":"llama2","created_at":"2024-01-12T20:40:01.353986Z","message":{"role":"assistant","content":"."},"done":false} {"model":"llama2","created_at":"2024-01-12T20:40:01.367968Z","message":{"role":"assistant","content":" "},"done":false} ```
GiteaMirror added the bug label 2026-04-22 03:36:21 -05:00
Author
Owner

@jmorganca commented on GitHub (May 10, 2024):

This should be fixed now however let's re-open it if that's not the case

<!-- gh-comment-id:2103669014 --> @jmorganca commented on GitHub (May 10, 2024): This _should_ be fixed now however let's re-open it if that's not the case
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#26895