RunOfflineTools Logo RunOfflineTools
⚑ Accurate Linter β€’ Ollama CLI Specification Compliant

Ollama Modelfile Validator & Template Tester

Inspect, lint, and debug your Ollama Modelfiles before running ollama create. Catch missing base models, unquoted stop sequences, and Go template syntax errors with instant 1-click auto-repair.

Verified Ollama Modelfile Presets

Load tested, community-standard Modelfiles with correct stop tokens and Go template syntax.

Modelfile Editor Valid Syntax
πŸš€ How to apply on your machine:
# 1. Save as a file named "Modelfile", then build:
$ ollama create llama33 -f ./Modelfile
# 2. Run your customized model:
$ ollama run llama33

Linter Diagnostics (0)0 errors Β· 0 warnings

Modelfile syntax is 100% compliant
Base model specified, parameters within valid bounds, and required stop sequence directives formatted.
Context Window (`num_ctx`):8,192 tokens
Estimated KV Cache Overhead:~2048 MB VRAM

βœ… Balanced context length fits comfortably on standard 8GB-16GB consumer GPUs.

Template Simulator (Live Preview)

See exactly how Ollama formats your prompt before streaming it to the model:

<|start_header_id|>system<|end_header_id|>

You are an expert engineer.<|eot_id|><|start_header_id|>user<|end_header_id|>

Explain race conditions in Go in 2 sentences.<|eot_id|><|start_header_id|>assistant<|end_header_id|>

[MODEL GENERATES RESPONSE HERE]<|eot_id|>

Understanding the Ollama Modelfile Architecture

An Ollama Modelfile is the definitive configuration layer that sits between your underlying transformer weights (GGUF or Safetensors) and the local runtime inference engine. Just as a Dockerfile packages software dependencies and runtime directives into a container, a Modelfile instructs Ollama how to allocate GPU memory, apply sampling parameters, format conversational turns, and enforce stop tokens.

The 8 Core Modelfile Directives

FROM (Required)

Specifies the base model tag (e.g., llama3.3:70b) or local file path (./model.gguf).

PARAMETER

Controls runtime inference: temperature, num_ctx, top_p, top_k, stop.

SYSTEM

Configures persistent system steering instructions wrapped in triple quotes """.

TEMPLATE

Go-template syntax formatting conversational turns between system, user, and assistant.

MESSAGE

Injects few-shot historical turns (MESSAGE user ..., MESSAGE assistant ...).

CAPABILITY

Declares model specializations, such as CAPABILITY decision.

REQUIRES

Enforces a minimum Ollama daemon version (e.g., REQUIRES 0.14.0).

LICENSE

Attaches distribution or legal licensing terms to the packaged model manifest.

Top 4 Modelfile Mistakes Caught by This Linter

1. Array Syntax in Stop Sequences

In frameworks like LangChain or OpenAI API SDKs, stop tokens are passed as a JSON list (e.g. ["stop1", "stop2"]). In an Ollama Modelfile, writing PARAMETER stop ["<|im_end|>", "<|eot_id|>"] is invalid syntax. Ollama requires each sequence on its own separate line:

# Correct Ollama Stop Syntax:
PARAMETER stop "<|im_start|>"
PARAMETER stop "<|im_end|>"
PARAMETER stop "<|eot_id|>"

2. Forgetting Context Window Scaling (`num_ctx`)

Many open-weight models advertise 32k or 128k context windows on HuggingFace. However, when loaded in Ollama, they frequently truncate memory after 2,048 or 4,096 tokens because num_ctx was left unset. Setting PARAMETER num_ctx 16384 or 32768 expands the context window to fit full codebases, documents, and multi-turn conversations.

3. Broken Go Template Variable Matching

Ollama parses templates with Go's standard text/template engine. If your template omits {{ .Prompt }}, incoming user questions are dropped and never passed to the LLM attention layers. Furthermore, unclosed conditionals (e.g., missing {{ end }}) will cause ollama create to abort with a template compile failure.

4. Unescaped Multiline Triple Quotes

When authoring long system prompts or license texts, always enclose the text block in triple double quotes """. Ensure the prompt content itself does not contain three consecutive quotes in a row, as this prematurely closes the block in the parser.

Step-by-Step Workflow: How to Build & Deploy

  1. Validate or Generate: Paste your existing Modelfile into the editor above or select one of the curated presets (Llama 3.3, Qwen 2.5 Coder, DeepSeek R1).
  2. Save the File: Click Download or save the text locally as a file named exactly Modelfile in your project directory.
  3. Compile with Ollama: Open your terminal and run ollama create my-custom-model -f ./Modelfile. Ollama creates a local manifest in seconds by referencing base weights.
  4. Test Interactively: Launch an interactive terminal session with ollama run my-custom-model.
  5. Inspect Active Configuration: To verify active parameters at any time, execute ollama show --modelfile my-custom-model.