Ollama Change Model Context Window by Editing Modelfile

1) Export the model’s current Modelfile

ollama show --modelfile llama3.2 > Modelfile

(Replace llama3.2 with your model name.) (Ollama 文档)

That output typically includes a comment like:

“To build a new Modelfile based on this one, replace the FROM line with: FROM llama3.2:latest” (Ollama 文档)

2) Edit the FROM line

Open Modelfile and change the top line to the exact tag you want, e.g.

FROM llama3.2:latest

(or whatever specific tag you’re using).

3) Add your context size override (and anything else)

Add:

PARAMETER num_ctx 8192

PARAMETER is the official way to set runtime defaults like context length inside a Modelfile. (Ollama 文档)

4) Create a new derived model name

ollama create llama3.2-8k -f ./Modelfile

Now you have a separate model entry with that default.


Example Modelfile (minimal)

FROM llama3.2:latest
PARAMETER num_ctx 8192

A couple practical tips

  • Don’t just crank num_ctx blindly: higher context increases memory usage and can slow inference; also you can’t exceed what the base model supports in practice.
  • If you want to verify what got baked in, you can re-check:ollama show --modelfile llama3.2-8k

If you paste the output of ollama show --modelfile <your-model> (just the first ~30 lines), I can tell you exactly what to keep vs. what’s safe to delete, and suggest a sensible num_ctx for your hardware.


作 者:motorbottle
链 接: https://blog.motorbottle.site/archives/739
来 源:Motor's Blog
版 权 声 明:本博客所有文章除特别声明(如【转载】)外,均采用CC BY-NC-SA 4.0许可协议。文章版权归作者所有,未经允许请勿转载!


暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇