A GGUF file is several gigabytes, and a download can corrupt silently. Computing its SHA-256 hash and comparing it with the hash published by the model publisher proves the file on disk is the file that was released, before you load it into any tool.
What you need
- A downloaded GGUF file on disk
- The SHA-256 hash published by the model publisher, from its model page
- A terminal with sha256sum available
Step 1: Get the published hash
Open the model page where you downloaded the GGUF and copy the SHA-256 hash listed for that exact file and quant. A hash for a different quant, such as Q8_0 instead of Q4_K_M, will not match.
Step 2: Compute the hash of your file
Run sha256sum model-Q4_K_M.gguf. The command reads the whole file and prints one 64-character hex string. Ollama does the same check itself when pulling a model, reporting verifying sha256 digest before it writes the manifest.
Step 3: Compare and act on a mismatch
If the two strings match exactly, the file is verified; record the hash next to your benchmark notes so later comparisons are reproducible. If they differ, delete the file, re-download it, and verify again; do not load a file that fails the check.
Worked example: verify a 4.9 GB Q4_K_M file
The table below is a synthetic example. The sha256sum usage and the digest verification come from the cited guides; the hash shown is illustrative, not a real file hash.
| Step | Action | Expected result |
|---|---|---|
| Published | Copy hash from model page | 64 hex characters |
| Compute | sha256sum model-Q4_K_M.gguf | One 64-character hash |
| Compare | Strings equal | File verified |
Expected result (UNTESTED). the computed hash matches the published hash character for character, confirming the download is intact. This check was not run live; the commands and the digest behaviour come from the cited guides.
Limits
- A hash only proves the file matches the publisher listing; it says nothing about the model quality.
- Each quant file has its own hash; compare against the right one.
- Computing a hash reads the whole file, which takes a while on multi-gigabyte files.
- If the publisher lists no hash, there is nothing to compare against; prefer publishers that do.
