[GH-ISSUE #3793] Can`t get correct response via API if the content has Chinese words #2341

Closed
opened 2026-04-12 12:39:47 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @wei-z-git on GitHub (Apr 21, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/3793

What is the issue?

When I try to get response with chinese words using API, like

Use API

In Chinese

Request

$  curl http://localhost:11434/api/chat -d '{   "model": "llama3",   "messages":[{"role":"user","content": "为什么天空是蓝色的"}] ,"stream": false}'

It seems the llama didn`t get my point.
Response:

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   623  100   520  100   103    352     69  0:00:01  0:00:01 --:--:--   422{"model":"llama3","created_at":"2024-04-21T07:36:14.7121197Z","message":{"role":"assistant","content":"It looks like you're having some fun with the characters! Unfortunately, I'm a language model, I don't understand what's going on with all those symbols. Can you please rephrase or ask me a question in plain English? I'd be happy to help if I can! 😊"},"done":true,"total_duration":1260881000,"load_duration":2802800,"prompt_eval_count":15,"prompt_eval_duration":361040000,"eval_count":60,"eval_duration":894948000}

In English

And if I ask the same question in English, it can understand:

curl http://localhost:11434/api/chat -d '{   "model": "llama3",   "messages":[{"role":"user","content": "why the sky is blue"}] ,"stream": false}'

Res:

% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2211    0  2107  100   104    342     16  0:00:06  0:00:06 --:--:--   537{"model":"llama3","created_at":"2024-04-21T07:34:50.999231Z","message":{"role":"assistant","content":"The sky appears blue to our eyes because of a fascinating phenomenon called scattering. Here's why:\n\n1. **Light from the sun**: When sunlight enters Earth's atmosphere, it consists of all the colors of the visible spectrum (red, orange, yellow, green, blue, indigo, and violet).\n2. **Atmospheric particles**: The atmosphere is filled with tiny molecules of gases like nitrogen (N2) and oxygen (O2), as well as aerosols like dust, water vapor, and pollutants.\n3. **Scattering**: When light from the sun encounters these atmospheric particles, it scatters in all directions. This scattering occurs because the particles are much smaller than the wavelength of light.\n4. **Blue light dominates**: The shorter wavelengths of blue light (around 450-495 nanometers) scatter more efficiently than longer wavelengths like red and orange light. This is because the smaller particles are better at interacting with the shorter, higher-energy blue photons.\n5. **Our eyes perceive the sky**: As we look up at the sky, our eyes detect the scattered blue light, which appears to us as the color blue.\n\nSome interesting facts about why the sky appears blue:\n\n* The exact shade of blue can vary depending on atmospheric conditions like pollution levels and water vapor content.\n* During sunrise and sunset, when the sun's rays have to travel longer distances through the atmosphere, the scattering effect is more pronounced, making the sky appear more red or orange due to the dominance of longer wavelengths.\n* In space, without an atmosphere, the sky would appear black because there are no particles to scatter light.\n\nSo, to summarize: The sky appears blue because the shorter wavelengths of blue light scatter more efficiently than other colors when interacting with atmospheric particles, making it the most visible color to our eyes."},"done":true,"total_duration":5936881200,"load_duration":2144400,"prompt_eval_count":10,"prompt_eval_duration":365781000,"eval_count":363,"eval_duration":5566471000}

Use terminal

But with the same model, when I use terminal, it can works even I use chinese:
image

OS

Windows

GPU

Nvidia

CPU

Intel

Ollama version

0.1.32

Originally created by @wei-z-git on GitHub (Apr 21, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/3793 ### What is the issue? When I try to get response with chinese words using API, like ## Use API ### In Chinese Request ```shell $ curl http://localhost:11434/api/chat -d '{ "model": "llama3", "messages":[{"role":"user","content": "为什么天空是蓝色的"}] ,"stream": false}' ``` It seems the llama didn`t get my point. Response: ``` % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 623 100 520 100 103 352 69 0:00:01 0:00:01 --:--:-- 422{"model":"llama3","created_at":"2024-04-21T07:36:14.7121197Z","message":{"role":"assistant","content":"It looks like you're having some fun with the characters! Unfortunately, I'm a language model, I don't understand what's going on with all those symbols. Can you please rephrase or ask me a question in plain English? I'd be happy to help if I can! 😊"},"done":true,"total_duration":1260881000,"load_duration":2802800,"prompt_eval_count":15,"prompt_eval_duration":361040000,"eval_count":60,"eval_duration":894948000} ``` ### In English And if I ask the same question in English, it can understand: ``` curl http://localhost:11434/api/chat -d '{ "model": "llama3", "messages":[{"role":"user","content": "why the sky is blue"}] ,"stream": false}' ``` Res: ```shell % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 2211 0 2107 100 104 342 16 0:00:06 0:00:06 --:--:-- 537{"model":"llama3","created_at":"2024-04-21T07:34:50.999231Z","message":{"role":"assistant","content":"The sky appears blue to our eyes because of a fascinating phenomenon called scattering. Here's why:\n\n1. **Light from the sun**: When sunlight enters Earth's atmosphere, it consists of all the colors of the visible spectrum (red, orange, yellow, green, blue, indigo, and violet).\n2. **Atmospheric particles**: The atmosphere is filled with tiny molecules of gases like nitrogen (N2) and oxygen (O2), as well as aerosols like dust, water vapor, and pollutants.\n3. **Scattering**: When light from the sun encounters these atmospheric particles, it scatters in all directions. This scattering occurs because the particles are much smaller than the wavelength of light.\n4. **Blue light dominates**: The shorter wavelengths of blue light (around 450-495 nanometers) scatter more efficiently than longer wavelengths like red and orange light. This is because the smaller particles are better at interacting with the shorter, higher-energy blue photons.\n5. **Our eyes perceive the sky**: As we look up at the sky, our eyes detect the scattered blue light, which appears to us as the color blue.\n\nSome interesting facts about why the sky appears blue:\n\n* The exact shade of blue can vary depending on atmospheric conditions like pollution levels and water vapor content.\n* During sunrise and sunset, when the sun's rays have to travel longer distances through the atmosphere, the scattering effect is more pronounced, making the sky appear more red or orange due to the dominance of longer wavelengths.\n* In space, without an atmosphere, the sky would appear black because there are no particles to scatter light.\n\nSo, to summarize: The sky appears blue because the shorter wavelengths of blue light scatter more efficiently than other colors when interacting with atmospheric particles, making it the most visible color to our eyes."},"done":true,"total_duration":5936881200,"load_duration":2144400,"prompt_eval_count":10,"prompt_eval_duration":365781000,"eval_count":363,"eval_duration":5566471000} ``` ## Use terminal But with the same model, when I use terminal, it can works even I use chinese: ![image](https://github.com/ollama/ollama/assets/32572815/05ad3a29-115c-406e-be06-27e563a9630b) ### OS Windows ### GPU Nvidia ### CPU Intel ### Ollama version 0.1.32
GiteaMirror added the bug label 2026-04-12 12:39:47 -05:00
Author
Owner

@jmorganca commented on GitHub (Jun 4, 2024):

Hi there, this should work now – make sure the terminal you are sending via curl supports utf-8. Let me know if that's not the case 😊

<!-- gh-comment-id:2148519198 --> @jmorganca commented on GitHub (Jun 4, 2024): Hi there, this should work now – make sure the terminal you are sending via `curl` supports utf-8. Let me know 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#2341