HOW-TO · INF

How to compare file sizes between different quantization formats

intermediate10 minBy Fredoline Eruo
Target environment
Ubuntu 24.04 · Ollama 0.4.x
PREREQUISITES

Multiple quantized versions of the same model available in Ollama

What this does

Lists multiple model variants and extracts their sizes to create a human-readable comparison for informed quantization selection. The result is a side-by-side view showing exactly how much disk space each variant consumes.

Steps

  1. Filter model inventory for a specific base model. Isolates rows for each variant of the target model.

    ollama list | grep llama3
    

    Expected output: Rows such as llama3:q4_K_M, llama3:q5_K_M, llama3:q8_0, and llama3:latest.

  2. Extract variant names and sizes. Pipe through awk to display only the NAME and SIZE columns.

    ollama list | grep llama3 | awk '{print $1, $NF}'
    

    Expected output: Each variant name paired with its byte size.

  3. Calculate total disk consumed by all variants. Sums the sizes to evaluate storage impact.

    ollama list | grep llama3 | awk '{sum+=$NF} END {print "Total bytes:", sum}'
    

    Expected output: Aggregate byte count for all llama3 variants.

  • Record the local run evidence. Save the exact command, runtime or package version, model name if applicable, and observed output so the result can be reproduced later.

Verification

ollama list | grep llama3 | awk '{print $1, $NF}'
# Expected: list such as "llama3:q4_K_M 4.1G", "llama3:q5_K_M 5.2G", "llama3:q8_0 6.8G"

Common failures

  • grep no matches: Model name is incorrect; verify exact case with ollama list first.
  • column misalignment: The SIZE column index may vary by Ollama version; inspect raw table output to find the correct column.
  • no variants present: Pull additional quantization levels first with ollama pull <model>:<tag>.
  • suffix confusion: Byte suffixes may differ (G vs GB); compare within the same unit for accuracy.
  • whitespace issues: Ollama output may contain leading/trailing whitespace; use tr -s ' ' before parsing.

Related guides

RELATED GUIDES