[GH-ISSUE #3629] Wrong handling of empty stop-parameter ( on empty array ) via Ollama API #27996

Closed
opened 2026-04-22 05:42:44 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @TheMasterFX on GitHub (Apr 13, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/3629

What is the issue?

Some implementations of the Ollama API (e.g. Langchain.llm ollama) are always sending an empty "stop": [] instead of "stop": null or just not even sending the stop parameter at all. When "stop": [] is send in the Json request, the default stop Token (set by the Modelfile) is overwritten, leading sometimes to a very long text, end ending with the stop string, e.g. <|im_end|> in the case of dolphin-mistral.

What did you expect to see?

Stop parameter stays untouched.

Steps to reproduce

from langchain.llms import Ollama

lang_client = Ollama(model="dolphin-mistral:latest")
response = lang_client.invoke("Hello")
print(response)

Output: Hello! How can I assist you today?<|im_end|>

Or:
curl -X POST http://localhost:11434/api/generate -d '{ "model": "dolphin-mistral:latest","prompt":"Hello" ,"options": {"stop": []}, "stream": false}'

Are there any recent changes that introduced the issue?

I never saw it working.

Or is it the fault of the 3rd party implementations like langchain?

OS

Windows

Architecture

amd64

Platform

No response

Ollama version

0.1.31

GPU

Nvidia

GPU info

+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 546.01                 Driver Version: 546.01       CUDA Version: 12.3     |
|-----------------------------------------+----------------------+----------------------+
| GPU  Name                     TCC/WDDM  | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |         Memory-Usage | GPU-Util  Compute M. |
|                                         |                      |               MIG M. |
|=========================================+======================+======================|
|   0  NVIDIA GeForce RTX 3080      WDDM  | 00000000:02:00.0  On |                  N/A |
|  0%   47C    P8              27W / 370W |   6294MiB / 10240MiB |      0%      Default |
|                                         |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+

CPU

Intel

Other software

No response

Originally created by @TheMasterFX on GitHub (Apr 13, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/3629 ### What is the issue? Some implementations of the Ollama API (e.g. Langchain.llm ollama) are always sending an empty `"stop": []` instead of `"stop": null` or just not even sending the stop parameter at all. When `"stop": []` is send in the Json request, the default stop Token (set by the Modelfile) is overwritten, leading sometimes to a very long text, end ending with the stop string, e.g. <|im_end|> in the case of dolphin-mistral. ### What did you expect to see? Stop parameter stays untouched. ### Steps to reproduce ``` from langchain.llms import Ollama lang_client = Ollama(model="dolphin-mistral:latest") response = lang_client.invoke("Hello") print(response) ``` Output: `Hello! How can I assist you today?<|im_end|>` Or: `curl -X POST http://localhost:11434/api/generate -d '{ "model": "dolphin-mistral:latest","prompt":"Hello" ,"options": {"stop": []}, "stream": false}'` ### Are there any recent changes that introduced the issue? I never saw it working. Or is it the fault of the 3rd party implementations like langchain? ### OS Windows ### Architecture amd64 ### Platform _No response_ ### Ollama version 0.1.31 ### GPU Nvidia ### GPU info ``` +---------------------------------------------------------------------------------------+ | NVIDIA-SMI 546.01 Driver Version: 546.01 CUDA Version: 12.3 | |-----------------------------------------+----------------------+----------------------+ | GPU Name TCC/WDDM | Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. | | | | MIG M. | |=========================================+======================+======================| | 0 NVIDIA GeForce RTX 3080 WDDM | 00000000:02:00.0 On | N/A | | 0% 47C P8 27W / 370W | 6294MiB / 10240MiB | 0% Default | | | | N/A | +-----------------------------------------+----------------------+----------------------+ ``` ### CPU Intel ### Other software _No response_
GiteaMirror added the bug label 2026-04-22 05:42:44 -05:00
Author
Owner

@pdevine commented on GitHub (Jul 18, 2024):

@TheMasterFX Sorry for the slow response. I think this ended up getting fixed a while ago as I'm not able to duplicate it:

% curl -X POST http://localhost:11434/api/generate -d '{ "model": "dolphin-mistral:latest","prompt":"Hello" ,"options": {"stop": []}, "stream": false}'
{"model":"dolphin-mistral:latest","created_at":"2024-07-18T18:56:00.790381Z","response":"Hi! How can I assist you today? What do you need help with?","done":true,"done_reason":"stop","context":[32001,1587,13,1976,460,15052,721,262,28725,264,10865,16107,13892,28723,13,32000,28705,13,32001,2188,13,16230,32000,28705,13,32001,13892,13,23809,28808,1602,541,315,6031,368,3154,28804,1824,511,368,927,1316,395,28804],"total_duration":4645989208,"load_duration":4286676208,"prompt_eval_count":29,"prompt_eval_duration":93417000,"eval_count":17,"eval_duration":264221000}%

I'm going to go ahead and close the issue. LMK if you're still seeing the problem.

<!-- gh-comment-id:2237330406 --> @pdevine commented on GitHub (Jul 18, 2024): @TheMasterFX Sorry for the slow response. I think this ended up getting fixed a while ago as I'm not able to duplicate it: ``` % curl -X POST http://localhost:11434/api/generate -d '{ "model": "dolphin-mistral:latest","prompt":"Hello" ,"options": {"stop": []}, "stream": false}' {"model":"dolphin-mistral:latest","created_at":"2024-07-18T18:56:00.790381Z","response":"Hi! How can I assist you today? What do you need help with?","done":true,"done_reason":"stop","context":[32001,1587,13,1976,460,15052,721,262,28725,264,10865,16107,13892,28723,13,32000,28705,13,32001,2188,13,16230,32000,28705,13,32001,13892,13,23809,28808,1602,541,315,6031,368,3154,28804,1824,511,368,927,1316,395,28804],"total_duration":4645989208,"load_duration":4286676208,"prompt_eval_count":29,"prompt_eval_duration":93417000,"eval_count":17,"eval_duration":264221000}% ``` I'm going to go ahead and close the issue. LMK if you're still seeing the problem.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#27996