CoolFace
Modelpublic

KikoCis/gemma-4-31b-it-IQ3_XS-GGUF

sourceHugging Faceapache-2.0updated 3mo agoView on Hugging Face
1likes219downloads
Model Card

Gemma 4 31B IT โ€” IQ3_XS GGUF

Gemma 4 31B Instruct quantized to IQ3_XS (3.40 BPW, 13.1GB) using llama.cpp with importance matrix calibration on CLI/package management data.

Matches f16 baseline on Char-F1 (84.76%) at 1/4.7 the size (50-example NL2Bash benchmark).

### ๐Ÿ’ก Looking for the smallest possible variant? Try our [gemma-4-31b-it-IQ2_M-GGUF](https://huggingface.co/KikoCis/gemma-4-31b-it-IQ2_M-GGUF) โ€” 10.17 GB with F1 84.71% and BLEU-4 22.39 (beats f16 at 6ร— smaller). Custom CLI-tuned imatrix on IQ2_M.

Key Stats

MetricValue
Base modelgoogle/gemma-4-31b-it
QuantizationIQ3_XS (3.40 BPW)
Size13.1 GB
Layers60 (full model, no pruning)
NL2Bash Char-F184.76% (= f16 baseline)
CLI 7/77/7 with thinking enabled

NL2Bash Benchmark โ€” Full Comparison

50 examples from the official Stanford/Tellina test split, reasoning OFF, max_tokens=200, temp=0.1, sorted by Char-F1.

ModelSizeBPWChar-F1BLEU-1BLEU-2BLEU-4EM
Unsloth UD-IQ3_XXS11.84 GB~2.9885.06%46.3034.6420.2612%
Base f16 (full precision)61.4 GB16.084.76%43.9433.8421.0212%
Base IQ3_XS (this model)13.1 GB3.4084.76%42.7731.4618.958%
โœจ [Sibling IQ2_M (CLI imatrix)](https://huggingface.co/KikoCis/gemma-4-31b-it-IQ2_M-GGUF)10.17 GB2.8484.71%44.7234.3622.3912%
Unsloth UD-IQ2_M10.75 GB~2.7084.02%42.3831.7318.6410%
Unsloth UD-IQ2_XXS8.53 GB~2.0676.82%33.0322.1711.490%
Base Q2_K (3rd party)11.0 GB2.7058.60%18.8212.796.920%

Key observations

  • โ€”This IQ3_XS ties f16 on Char-F1 (84.76% vs 84.76%) and comes within 2 F1 of the best available quantization
  • โ€”Unsloth Dynamic 2.0 is the Pareto frontier: UD-IQ2M (10.75 GB) is strictly better than plain Q2K (+25.4 F1 points at same BPW) thanks to per-layer adaptive bit allocation and Gemma-4-specific imatrix
  • โ€”Q2_K at 2.7 BPW collapses on Gemma 4 (F1 58.6%, produces repetitive output). Standard 2-bit scalar quantization is not viable for this architecture
  • โ€”f16 only wins on token-exact metrics (BLEU-4, EM) โ€” IQ3_XS produces semantically equivalent commands with minor stylistic variations (different flag order, quoting style)

Recommendation

  • โ€”Smallest working quant: Unsloth UD-IQ2_M (10.75 GB, F1 84%)
  • โ€”Best overall: Unsloth UD-IQ3_XXS (11.84 GB, F1 85%)
  • โ€”This model (IQ3_XS, 13.1 GB): simpler imatrix calibration (CLI-focused), slightly larger but within 0.3 F1 of UD-IQ3_XXS

Full per-question predictions + layer analysis study: https://huggingface.co/datasets/KikoCis/gemma4-31b-layer-study

CLI Benchmark Results (7/7 with thinking)

Tested with llama-cli -cnv --reasoning on --reasoning-budget 512:

TestResult
Install neofetch on Void Linuxsudo xbps-install -S neofetch
Install htop on Ubuntusudo apt install htop
Search ripgrep on Archpacman -Ss ripgrep
Search packages on Voidxbps-query -S <package_name>
Add cargo to PATH in zshecho 'export PATH="$HOME/.cargo/bin:$PATH"' >> ~/.zshrc
Install jq on macOSbrew install jq
Grep TODO in /var/wwwgrep -r "TODO" /var/www

Usage

bash
# llama.cpp with thinking
llama-cli -m gemma4-31b-IQ3_XS.gguf -cnv -ngl 99 --ctx-size 8192 \
  --reasoning on --reasoning-budget 512

# Ollama
cat > Modelfile << 'EOF'
FROM ./gemma4-31b-IQ3_XS.gguf
PARAMETER temperature 0.1
PARAMETER num_ctx 8192
EOF
ollama create gemma4-31b-iq3xs -f Modelfile

Quantization Details

  • โ€”Tool: llama.cpp (build 0d049d6)
  • โ€”Imatrix: Computed from 200 chunks of synthetic CLI/package management data
  • โ€”Source: Converted from google/gemma-4-31b-it safetensors via convert_hf_to_gguf.py
  • โ€”Architecture: Gemma4 with sliding + full attention pattern (every 6th layer is full attention)

Hardware Requirements

  • โ€”Minimum RAM: 16GB (with partial offload)
  • โ€”Recommended: Apple Silicon with 32GB+ unified memory
  • โ€”Performance: ~21 tok/s on Apple Silicon (128GB unified) with full GPU offload

Benchmark Methodology

  • โ€”NL2Bash test set: 50 examples from the official deterministic split (RANDOM_SEED=100, fold 11 from TellinaTool/nl2bash)
  • โ€”Inference: Each question runs as an isolated llama-cli subprocess with -p prompt, --reasoning off, --ctx-size 4096, --max-tokens 200, --temp 0.1
  • โ€”Scoring: NLTK BLEU corpus-level + character-level F1 + exact match
  • โ€”Reproducibility: All scripts and JSONL predictions are public at the dataset repo above

Real-World Agent Test Warning (April 2026)

Benchmark scores do not predict agent capability. In Docker-based autonomous testing, fine-tuned E4B models (95% BFCL) scored 0/10 while the unfine-tuned base scored 6/10. Fine-tuning for BFCL destroyed general reasoning (error recovery, strategy adaptation, anti-repetition). Fine-tuned E4B models have been withdrawn. For autonomous agent tasks, use the base Gemma 4 model or a larger model at higher BPW. See: The Benchmark Trap โ€” Full Study