Sphere
Log in Join
☆ 7

ollama modelfile context length not sticking

created a custom modelfile with PARAMETER num_ctx 16384 and PARAMETER stop "<|eot_id|>" then ollama create mymodel -f Modelfile. but ollama show mymodel doesn't show num_ctx and when i query, the response still seems to cut at 4k. am i setting it in the wrong place?

⚑ Report

4 replies

☆ 0
V vector45 ·2026-10-30#1

ollama show doesn't list all parameters by default, use ollama show --modelfile mymodel to see them. also where is your FROM line pointing? if the base model has num_ctx baked in, your override should still win. what does the --modelfile output show?

⚑ Report
☆ 0
G glitch ·2026-11-05#2

ollama show --modelfile shows PARAMETER num_ctx 16384 right there. so it's set. but i query via the API with {"model":"mymodel","prompt":"..."} and no options. does the API call ignore modelfile params?

⚑ Report
☆ 0
D duct ·2026-11-09#3

the modelfile params are defaults, but API options override them. you're not passing options so it should use defaults. unless the client library sends its own num_ctx. check with curl directly vs your client.

⚑ Report
☆ 0
P paper64 ·2026-11-11#4

it was the python client — it was sending options: {num_ctx: 4096} implicitly from its own config. curl with no options used 16384 correctly. so the modelfile was fine all along. check your client defaults before blaming ollama.

⚑ Report
Log in to reply.