[GH-ISSUE #5909] " Error: json: cannot unmarshal array into Go struct field Params.eos_token_id of type int " while importing llama 3.1 8B safetensor model from huggingface #3688

Closed
opened 2026-04-12 14:30:14 -05:00 by GiteaMirror · 12 comments
Owner

Originally created by @sadegh-pz on GitHub (Jul 24, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/5909

Originally assigned to: @joshyan1 on GitHub.

What is the issue?

What is the problem?

I was importing the llama 3.1 8B model from huggingface (meta-llama/Meta-Llama-3.1-8B-Instruct) using ollama create -f Modelfile but i got this error:
Error: json: cannot unmarshal array into Go struct field Params.eos_token_id of type int
I found the shallow cause of the error. and i fixed it naively. but i wanted to know why this error happned and what is the better solution.

What I get from the error?

the Go struct gets int for eos_token_id.
But the config.json file and generation_config.json file contain "eos_token_id": [128001, 128008, 128009].
So they face type mismatch and we get the error.

What is my naive solution?

I changed the eos_token_id value to "eos_token_id": 128001 without a concrete reason why i chose 128001 instead of the others. and it solved the problem and a model is created.

Why this error happened? What is the correct solution?

I don't know. I'd be appreciated to know.

OS

Linux

GPU

Nvidia

CPU

Intel

Ollama version

0.2.8

Originally created by @sadegh-pz on GitHub (Jul 24, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/5909 Originally assigned to: @joshyan1 on GitHub. ### What is the issue? ## What is the problem? I was importing the llama 3.1 8B model from huggingface (`meta-llama/Meta-Llama-3.1-8B-Instruct`) using `ollama create -f Modelfile` but i got this error: `Error: json: cannot unmarshal array into Go struct field Params.eos_token_id of type int` I found the shallow cause of the error. and i fixed it naively. but i wanted to know why this error happned and what is the better solution. ## What I get from the error? the `Go struct` gets `int` for `eos_token_id`. But the `config.json` file and `generation_config.json` file contain `"eos_token_id": [128001, 128008, 128009]`. So they face type mismatch and we get the error. ## What is my naive solution? I changed the `eos_token_id` value to `"eos_token_id": 128001` without a concrete reason why i chose `128001` instead of the others. and it solved the problem and a model is created. ## Why this error happened? What is the correct solution? I don't know. I'd be appreciated to know. ### OS Linux ### GPU Nvidia ### CPU Intel ### Ollama version 0.2.8
GiteaMirror added the bug label 2026-04-12 14:30:14 -05:00
Author
Owner

@ygivenx commented on GitHub (Jul 24, 2024):

I see this error in the docker logs

error from daemon in stream: Error grabbing logs: invalid character 'l' after object key:value pair

<!-- gh-comment-id:2248632974 --> @ygivenx commented on GitHub (Jul 24, 2024): I see this error in the docker logs `error from daemon in stream: Error grabbing logs: invalid character 'l' after object key:value pair`
Author
Owner

@mingmars commented on GitHub (Jul 25, 2024):

ollama create llama3.1 -f lama31.txt
transferring model data
unpacking model metadata
Error: json: cannot unmarshal array into Go struct field Params.eos_token_id of type int

配置文件是:

FROM D:\LLaMA-Factory\Meta-Llama-3.1-8B-Instruct
TEMPLATE "{{ if .System }}<|start_header_id|>system<|end_header_id|>

{{ .System }}<|eot_id|>{{ end }}{{ if .Prompt }}<|start_header_id|>user<|end_header_id|>

{{ .Prompt }}<|eot_id|>{{ end }}<|start_header_id|>assistant<|end_header_id|>

{{ .Response }}<|eot_id|>"
PARAMETER stop <|start_header_id|>
PARAMETER stop <|end_header_id|>
PARAMETER stop <|eot_id|>
PARAMETER num_keep 24

<!-- gh-comment-id:2250209684 --> @mingmars commented on GitHub (Jul 25, 2024): ollama create llama3.1 -f lama31.txt transferring model data unpacking model metadata Error: json: cannot unmarshal array into Go struct field Params.eos_token_id of type int 配置文件是: FROM D:\LLaMA-Factory\Meta-Llama-3.1-8B-Instruct TEMPLATE "{{ if .System }}<|start_header_id|>system<|end_header_id|> {{ .System }}<|eot_id|>{{ end }}{{ if .Prompt }}<|start_header_id|>user<|end_header_id|> {{ .Prompt }}<|eot_id|>{{ end }}<|start_header_id|>assistant<|end_header_id|> {{ .Response }}<|eot_id|>" PARAMETER stop <|start_header_id|> PARAMETER stop <|end_header_id|> PARAMETER stop <|eot_id|> PARAMETER num_keep 24
Author
Owner

@dgallardox commented on GitHub (Jul 27, 2024):

This is not totally relevant but I was getting the exact same error in Postman when making a POST request to /api/generate. It turns out it was caused by quotes in the stream value. E.g.,:

{
"model":"llama3",
"prompt": "once upon a time",
"stream": "false" // this causes a problem
}

VS.

{
"model":"llama3",
"prompt": "once upon a time",
"stream": false // this works
}

You possibly have a similar syntax error somewhere?
<!-- gh-comment-id:2253701389 --> @dgallardox commented on GitHub (Jul 27, 2024): This is not totally relevant but I was getting the exact same error in Postman when making a POST request to `/api/generate`. It turns out it was caused by quotes in the stream value. E.g.,: ``` { "model":"llama3", "prompt": "once upon a time", "stream": "false" // this causes a problem } VS. { "model":"llama3", "prompt": "once upon a time", "stream": false // this works } You possibly have a similar syntax error somewhere?
Author
Owner

@Dudu0831 commented on GitHub (Jul 29, 2024):

I also encountered the same problem, upgrading to 3.0 has not been resolved

<!-- gh-comment-id:2255306767 --> @Dudu0831 commented on GitHub (Jul 29, 2024): I also encountered the same problem, upgrading to 3.0 has not been resolved
Author
Owner

@202030481266 commented on GitHub (Jul 29, 2024):

same problem

<!-- gh-comment-id:2256035627 --> @202030481266 commented on GitHub (Jul 29, 2024): same problem
Author
Owner

@hgaong commented on GitHub (Aug 1, 2024):

same problem

<!-- gh-comment-id:2262224466 --> @hgaong commented on GitHub (Aug 1, 2024): same problem
Author
Owner

@hgaong commented on GitHub (Aug 1, 2024):

I changed the eos_token_id value to "eos_token_id": 128001 without a concrete reason why i chose 128001 instead of the others. and it solved the problem and a model is created.

<!-- gh-comment-id:2262225217 --> @hgaong commented on GitHub (Aug 1, 2024): I changed the eos_token_id value to "eos_token_id": 128001 without a concrete reason why i chose 128001 instead of the others. and it solved the problem and a model is created.
Author
Owner

@nebula2020 commented on GitHub (Aug 2, 2024):

Same issue I have faced. Switching to gguf deployment now.

<!-- gh-comment-id:2264876781 --> @nebula2020 commented on GitHub (Aug 2, 2024): Same issue I have faced. Switching to gguf deployment now.
Author
Owner

@sergei202 commented on GitHub (Aug 15, 2024):

I was tearing my hair out with this issue and finally got it working:

What fixed it for me is changing the eos_token_id in config.json to 128001, as @hgaong had suggested.
That got the model created, but then it wouldn't stop correctly and ended up output trash.

I added to add this to the Modelfile before calling ollama create and that fixed it!

PARAMETER stop <|start_header_id|>
PARAMETER stop <|end_header_id|>
PARAMETER stop <|eot_id|>
TEMPLATE [removed for readability]
<!-- gh-comment-id:2292152741 --> @sergei202 commented on GitHub (Aug 15, 2024): I was tearing my hair out with this issue and finally got it working: What fixed it for me is changing the `eos_token_id` in `config.json` to `128001`, as @hgaong had suggested. That got the model created, but then it wouldn't stop correctly and ended up output trash. I added to add this to the `Modelfile` before calling `ollama create` and that fixed it! ``` PARAMETER stop <|start_header_id|> PARAMETER stop <|end_header_id|> PARAMETER stop <|eot_id|> TEMPLATE [removed for readability] ```
Author
Owner

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

I'm going to go ahead and close this. You shouldn't need to specify the TEMPLATE as it should get autodetected.

<!-- gh-comment-id:2323560733 --> @pdevine commented on GitHub (Sep 2, 2024): I'm going to go ahead and close this. You shouldn't need to specify the `TEMPLATE` as it should get autodetected.
Author
Owner

@nofreewill42 commented on GitHub (Nov 12, 2024):

I had the error:

(.venv) nofreewill@nofreewill:~/FineTuneLLM$ ollama create mymodel -f Modelfile 
transferring model data 100% 
converting model 
Error: json: cannot unmarshal array into Go struct field .model.merges of type string

Modelfile content with the error:

FROM ./finetuned_llama_32_3b_gguf
PARAMETER stop [INST]
PARAMETER stop [/INST]
TEMPLATE "[INST] {{ .Prompt }} [/INST]"

Fixed model file:

FROM ./finetuned_llama_32_3b_gguf/unsloth.Q4_K_M.gguf
PARAMETER stop [INST]
PARAMETER stop [/INST]
TEMPLATE "[INST] {{ .Prompt }} [/INST]"

Fix highlighted:
FROM ./finetuned_llama_32_3b_gguf/unsloth.Q4_K_M.gguf

<!-- gh-comment-id:2470241545 --> @nofreewill42 commented on GitHub (Nov 12, 2024): I had the error: ``` (.venv) nofreewill@nofreewill:~/FineTuneLLM$ ollama create mymodel -f Modelfile transferring model data 100% converting model Error: json: cannot unmarshal array into Go struct field .model.merges of type string ``` Modelfile content with the error: ``` FROM ./finetuned_llama_32_3b_gguf PARAMETER stop [INST] PARAMETER stop [/INST] TEMPLATE "[INST] {{ .Prompt }} [/INST]" ``` Fixed model file: ``` FROM ./finetuned_llama_32_3b_gguf/unsloth.Q4_K_M.gguf PARAMETER stop [INST] PARAMETER stop [/INST] TEMPLATE "[INST] {{ .Prompt }} [/INST]" ``` Fix highlighted: FROM ./finetuned_llama_32_3b_gguf/**unsloth.Q4_K_M.gguf**
Author
Owner

@rtrad89 commented on GitHub (Nov 21, 2024):

I was having a similar error when using "context": 1 in the request, so I replaced it with "context": [1] and the error was fixed.

<!-- gh-comment-id:2491030820 --> @rtrad89 commented on GitHub (Nov 21, 2024): I was having a similar error when using `"context": 1` in the request, so I replaced it with `"context": [1]` and the error was fixed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#3688