Skip to main content

Static validation for Ollama Modelfiles — catch broken FROM paths, bad PARAMETER values, and missing TEMPLATEs before running `ollama create`.

Project description

owist-modelfile-lint

Static validation for Ollama Modelfiles. Catch broken FROM paths, invalid PARAMETER values, and missing TEMPLATEs before you run ollama create and get a cryptic Go error three minutes into a model build.

Built by Openwist AI, maker of the LimitAI open model family.

The problem

ollama create parses your Modelfile on the Go side and fails late:

Error: invalid file magic

That's it. No line number, no hint about which instruction caused it, and you find out only after Ollama has already started reading your (possibly multi-gigabyte) model file. A typo'd PARAMETER key gets silently ignored instead of erroring. A missing TEMPLATE on an unrecognized base model ships a model with no chat formatting at all, and you don't notice until it responds with garbage.

owist-modelfile-lint reads your Modelfile before any of that, the same way ruff or eslint check source code before you run it.

Install

pip install owist-modelfile-lint

Usage

CLI

modelfile-lint ./Modelfile
[ERROR]   line 1: FROM path './sophia-q4.gguf' does not exist  (FROM005)
[ERROR]   line 5: PARAMETER 'temprature' is not a recognized Ollama parameter (did you mean 'temperature'?)  (PARAM002)
[WARNING] line 7: PARAMETER 'temperature' value 5.7 is outside the typical range [0.0, 2.0] (default: 0.8) — this is valid syntax but likely unintentional  (PARAM007)
[WARNING] general: no TEMPLATE instruction found and FROM points to a local file/directory — Ollama's chat-template auto-detection may fail for unrecognized architectures, producing a model with no chat formatting at all. Consider adding an explicit TEMPLATE.  (TPL002)

✗ ./Modelfile: 2 error(s), 2 warning(s)

Exit code is 0 when there are no errors (warnings don't fail the check), 1 otherwise — so it's a drop-in CI or pre-commit gate:

modelfile-lint ./Modelfile || exit 1

Other flags:

modelfile-lint ./Modelfile --quiet      # errors only, suppress warnings
modelfile-lint ./Modelfile --json       # machine-readable output
modelfile-lint ./Modelfile --no-color

Python API

from owist_modelfile_lint import lint

result = lint("Modelfile")

if not result.ok:
    for issue in result.issues:
        print(issue)
    raise SystemExit(1)
from owist_modelfile_lint import lint_text

# lint content that doesn't exist on disk yet, e.g. generated programmatically
result = lint_text("""
FROM llama3.2
PARAMETER temperature 0.7
SYSTEM You are a helpful assistant.
""")
print(result.ok)  # True

LintResult gives you .ok, .issues, .errors, .warnings, .infos, and is truthy/falsy based on .ok so if result: works too.

What it checks

Instruction Checks
FROM required and present exactly once; conventionally first; if it's a local path, the path exists; if it's a .gguf file, the magic bytes actually say GGUF; if it's a directory, it has .safetensors weights and a config.json
PARAMETER key is a real Ollama parameter (with "did you mean...?" suggestions for typos); value is the right type (int/float/string); value is in the typical sane range; duplicate non-repeatable parameters
TEMPLATE present when the base model isn't one Ollama can auto-detect; contains actual Go template variables ({{ .Prompt }}, {{ .Response }}) when present
SYSTEM not empty; warns on duplicates
ADAPTER requires a FROM; path exists; GGUF adapters are validated the same way as FROM
MESSAGE role is one of system / user / assistant; has content
structure unrecognized instructions, unterminated """ strings

This is static analysis — it never loads model weights, runs Ollama, or needs a GPU. A GGUF check reads 24 bytes of the file header, nothing more.

What it deliberately does not do

  • It does not validate that your TEMPLATE Go-template syntax is semantically correct for the model's actual chat format — that requires knowing what the base model expects, which is out of scope for a static linter.
  • It does not check model quality — see tinyeval (planned) for that.
  • It does not talk to the Ollama daemon or registry. Library model references like FROM llama3.2 are accepted as-is without checking whether that tag exists.

Why "owist"

Short for Openwist AI — we build the LimitAI open model family (Anan, Sophia) and got tired of debugging our own Modelfiles by trial and error.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

owist_modelfile_lint-0.1.1.tar.gz (18.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

owist_modelfile_lint-0.1.1-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file owist_modelfile_lint-0.1.1.tar.gz.

File metadata

  • Download URL: owist_modelfile_lint-0.1.1.tar.gz
  • Upload date:
  • Size: 18.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for owist_modelfile_lint-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1a0682ed1e8f2cb9dd34f2b9974998a2dd5bd7a11de785573b1dd542764a7060
MD5 ea892df2b1b1bf4594e8b58e140eae7d
BLAKE2b-256 e93e5079d4611c0a7075ec418776e784e190139ba3bf26a3209564f13150244d

See more details on using hashes here.

File details

Details for the file owist_modelfile_lint-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for owist_modelfile_lint-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0fba77b6b3d09dc09a05fdbdb8430ffc1b8f98b2bbdca00aff9eeefaae5917a9
MD5 17e9455503222f10ae4e2040f1773fd5
BLAKE2b-256 c4365ff7a5c778643f06484800f61df4c19d26e0e081c0c5db2bb485edb37571

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page