---
title: "Discussion on \"Fine-tune gpt-oss-20b with Unsloth and run it in Ollama\" | Hashnode"
description: "Discussion on \"Fine-tune gpt-oss-20b with Unsloth and run it in Ollama\". QLoRA settings, VRAM, GGUF export and a working Ollama Modelfile for a fine-tuned gpt-oss-20b, including the Harmony template and stop token it needs."
url: "https://hashnode.com/posts/fine-tune-gpt-oss-20b-with-unsloth-and-run-it-in-ollama/6acde4dbefbf7f1d1effb388"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Fine-tune gpt-oss-20b with Unsloth and run it in Ollama](https://khadimhussain0.hashnode.dev/fine-tune-gpt-oss-20b-with-unsloth-and-run-it-in-ollama?utm_source=hashnode&utm_medium=feed)

QLoRA settings, VRAM, GGUF export and a working Ollama Modelfile for a fine-tuned gpt-oss-20b, including the Harmony template and stop token it needs.

Oct 13 · 10 min read · khadimhussain0.hashnode.dev  
Updated Oct 23  
Read the article

-   [#machine-learning](https://hashnode.com/tag/machine-learning)
-   [#llm](https://hashnode.com/tag/llm)
-   [#ollama](https://hashnode.com/tag/ollama)
-   [#python](https://hashnode.com/tag/python)

## Written by

[Khadim Hussain](https://hashnode.com/@khadimxai)

@khadimxai · Islamabad, Pakistan

  
[View profile](https://hashnode.com/@khadimxai)

AI engineer building AI agents, LLM and RAG systems, and computer vision. I write about what I test at khadim.tech.

I build AI agents, LLM and RAG systems, and computer vision pipelines, and I test new AI tools hands-on before writing about them. Top Rated Plus on Upwork. Write-ups and contact: https://khadim.tech

## Responses 2

Markdown supported · ⌘↵ to post

[Mihai\_LeanZero](https://hashnode.com/@mihaileanzero)

[Oct 13](https://hashnode.com/posts/fine-tune-gpt-oss-20b-with-unsloth-and-run-it-in-ollama/6acde4dbefbf7f1d1effb388/comment/6ace0131ef889bfa647a351a)

One thing worth checking on that Modelfile: the TEMPLATE only uses .Prompt, with no .Messages and no .Response. Going by template.go in the Ollama repo, a template with neither gets {{ .Response }} appended at parse time and then runs once per user/assistant pair in legacy mode. So from turn two on, the earlier answer lands right after the bare <|start|>assistant with no channel header and no <|end|>, and the hard-coded system block repeats in front of every pair (a SYSTEM line in the Modelfile is ignored too, since .System is never referenced). Single-shot ollama run would look fine, multi-turn chat is where I'd expect it to drift. Ranging over .Messages and writing each past assistant turn as a final-channel message closed with <|end|> should avoid it. I read this from the source, I haven't run it against a gpt-oss GGUF.

[Khadim Hussain](https://hashnode.com/@khadimxai)

[Oct 23](https://hashnode.com/posts/fine-tune-gpt-oss-20b-with-unsloth-and-run-it-in-ollama/6acde4dbefbf7f1d1effb388/comment/6ace0131ef889bfa647a351a#reply-6adbd5c4216c00c22c31bf7f)

You were right, thanks for reading it that closely. I checked `template.go` and rendered both templates on Ollama 0.40.7 with `_debug_render_only`: the old one put the first answer straight after a bare `<|start|>assistant`, with no channel header and no `<|end|>`, repeated the system block, and dropped `SYSTEM`. The post and the Modelfile in the GGUF repo now range over `.Messages`, send earlier answers back as final-channel messages closed with `<|end|>`, and turn `SYSTEM` into a developer message, the way Ollama's own gpt-oss template does. A single prompt renders byte for byte the same as before, which is why `ollama run` never showed it. I've credited you in the post.
