Gemma4 College of Experts β€” Coding Specialist

Base model: google/gemma-4-26b-it
Architecture: MoE β€” 26B total / β‰ˆ4B active parameters (1 shared expert + 8 routed from a pool of 128 per MoE layer, 30 MoE layers)
Method: Activation-directed expert surgery β€” 128 β†’ 64 experts per layer (50% reduction)
Quantization: Q4_K_M (β‰ˆ9.7 GB on disk)
HF: JThomas-CoE/coe-gemma4-coding-hc-14b-a4b-q4 | Ollama: coe-gemma4-coding-14b-a4b:q4
Hub: JThomas-CoE on HuggingFace

HC (Hand-Curated) β€” The activation profiling corpus used to build this model's expert mask was assembled by hand, selecting high-quality domain-representative text from textbooks, problem sets, and technical references. This contrasts with the MMLU-Pro variants (-mmlu_pro- in the repo name) which were profiled on stratified subsets of the TIGER-Lab/MMLU-Pro benchmark dataset.


⚠️ Beta Release β€” Safety Disclaimer

These models are beta releases and should be treated as research artifacts, not production-ready systems.

Expert surgery selects and retains domain-relevant experts based on activation patterns observed during profiling. The pruning pipeline is designed solely to create a coherent domain specialist β€” it has no mechanism to identify which experts contribute to model alignment, ethical reasoning, or safety guardrails. As a result, experts responsible for enforcing those behaviours may have been inadvertently removed during the surgery process.

Appropriate use of any model in the College of Experts family is the sole responsibility of the end user. The authors make no representation that these models retain the safety properties of the parent google/gemma-4-26b-it model, and users should not rely on them as a substitute for models that have undergone safety evaluation.


⚠️ Critical Usage Note β€” Think-Off Mode

All models in this series must be used in thinking-off mode.

If you are using the Ollama API, pass "think": false in your request body. If you are accessing the model via a raw API (llama.cpp server, OpenAI-compatible endpoint, etc.) you must inject a closed thinking block at the start of the assistant turn:

messages = [
    {"role": "system",    "content": "Your system prompt here."},
    {"role": "user",      "content": "Your question here."},
    {"role": "assistant", "content": "<think></think>\n"},   # <-- required prefill
]

Why this is required: Expert surgery retains 50% of the expert pool per layer, selecting experts that are maximally active on domain content and chain-of-thought reasoning. A side effect is that the loop-suppression experts β€” which activate on metacognitive closure signals near the end of a <think> block β€” do not have a concentrated domain-specific activation signature and are disproportionately pruned. In think-on mode, this causes the model to enter a reasoning loop that exhausts the token budget without producing a final answer. In extreme cases, the loop rate is 60–70% on hard questions.

The <think></think> prefill works by consuming the opening <think> token before generation starts, so the model sees its thinking as already complete and proceeds directly to answering. This is the mechanism used in all benchmarks reported here.

What think-off mode does not disable: Gemma4's chain-of-thought training is deeply ingrained. Even with the think block closed, the model produces brief inline reasoning interleaved with its answer β€” shorter and more linear than a full scratchpad, but present. All benchmark figures in this README are measured in this constrained-implicit-CoT mode, which is more conservative than the full explicit CoT used by leaderboard entries.

Ollama Modelfile Template

FROM <model_path_or_ollama_tag>

PARAMETER temperature 0.6
PARAMETER repeat_penalty 1.05
PARAMETER num_ctx 8192
PARAMETER num_predict 16384
PARAMETER think false

SYSTEM """
You are an expert software engineer.
Write clean, readable, production-quality code in the requested language.
When solving an algorithmic or design problem, reason step-by-step and then output complete runnable code.
Use idiomatic patterns and language-appropriate conventions.
Return your complete answer, then stop with no further output.
"""

Temperature 0.6 is strongly recommended. Higher temperatures (β‰₯ 0.8) materially increase loop rates in think-off mode.


Q4 vs Q8 β€” Quantization Tradeoff Reference

Only the Q4_K_M variant is released for this model. The Q8_0 numbers below are provided as a reference illustration of the quantization tradeoff and were measured during internal evaluation.

Metric Q4_K_M (released) Q8_0 (reference, not released)
Overall (50 LCB problems) 78.0% (39/50) 88.0% (44/50)
Easy 96% 92%
Medium 60% 84%

The Q8 advantage is concentrated on medium-difficulty problems requiring precise multi-step reasoning. For routine generation tasks (single-function completion, code review, syntax translation) the Q4 variant is sufficient and saves β‰ˆ7.1 GB of VRAM versus the Q4 parent.

If your use case is dominated by hard, multi-step problems and you have a card with β‰₯ 24 GB VRAM, consider the Python HC specialist Q8 variant β€” the same underlying methodology applied to a Python-focused profiling corpus.


What Are These Models?

These models are produced by activation-directed expert surgery applied to the Gemma4 26B-A4B instruction-tuned model. The surgery does not change any weight values β€” it prunes the FFN weight tensors for experts that are not part of the domain-specialist mask, then saves the result as a smaller GGUF. The result is a model that loads approximately 7–8 GB less VRAM for 4 bit quantization than the parent while maintaining the same token throughput (active parameters per forward pass are unchanged: 9 experts fire per token regardless of pool size).

Memory Efficiency

Configuration VRAM (16k ctx) VRAM (64k ctx) Active params
Gemma4-26B parent (Q4_K_M) 19.4 GB 20.5 GB β‰ˆ4B
Specialist K=64 (Q4_K_M) 12.3 GB 13.4 GB β‰ˆ4B
Q4 savings vs Q4 parent 7.1 GB (37%) 7.1 GB (35%) unchanged

All figures directly measured in Ollama.

Throughput (tokens/second) is identical between the specialist and the parent at the same quantization because the number of expert weight tensors that participate in each forward pass is the same. The saving is purely in VRAM residency β€” half the expert weight tensors simply do not need to be loaded.


Benchmark β€” LiveCodeBench

Evaluation harness: Custom test-execution harness using local Python sandbox.
Suite: 50-problem LiveCodeBench subset β€” Easy (25) and Medium (25).
Mode: think_off (<think></think> prefill), temperature 0.6.
Model under test: Coding HC specialist Q4_K_M (gemma4-coding-K64-q4_K_M).

Difficulty Passed Total Pass Rate
Easy 24 25 96%
Medium 15 25 60%
Overall 39 50 78.0%

Easy problems are nearly saturated (96%). Medium problems require multi-step reasoning, edge-case handling, and algorithmic precision β€” the domain where quantization noise is most consequential.


Activation Profiling β€” How the Masks Are Built

Step 1 β€” Corpus Assembly

The coding corpus combines:

  • General programming textbook prose β€” data structures, algorithms, design patterns, software engineering principles spanning multiple languages
  • Multi-language implementation examples β€” Python, JavaScript/TypeScript, C++, Go, Rust, SQL β€” covering idiomatic usage and language-specific patterns
  • Algorithm derivation traces β€” worked Q&A pairs spanning sorting, searching, dynamic programming, graph algorithms, and combinatorics
  • API and standard-library documentation β€” common interface patterns, error handling idioms, concurrency primitives

Corpus size: approximately 45,000 tokens (coding_systems corpus). Profiling was run on the full parent model with router hooks capturing per-token expert selections across all 30 MoE layers.

Corpus size considerations. Choosing how much material to include for activation profiling involves two competing pressures. On one side, a corpus that is too small or too narrow may fail to activate the full set of experts that are genuinely relevant to the domain: rare but important concepts may appear in too few tokens to accumulate statistically reliable activation counts, leaving their associated experts underweighted or excluded from the mask. At β‰ˆ45k tokens the coding corpus is one of the smaller corpora in the CoE specialist family, and the coverage risk is more immediate than the dilution risk: the corpus was kept tight and high-quality rather than expanded with tangentially related general programming content, on the premise that a focused signal from a curated core is preferable to a noisier signal from a larger but less representative set. On the other side, if a meaningful fraction of the profiling tokens come from topics that sit at the edge of the domain, the resulting activation histogram begins to resemble a general-purpose model rather than a specialist: the "hot" expert cluster spreads outward and the mask selection becomes less discriminating. A more rigorous data-driven approach β€” one that measures the dispersion or entropy of the emerging activation cluster after each corpus increment and uses that as a stopping criterion β€” would provide principled feedback to calibrate corpus size from both directions. This remains an area of future work.

Step 2 β€” 3D Histogram Collection

The full parent model is run in forward-pass mode over the corpus with a hook attached to each MoE layer's router. For each token, the router selects the top-8 experts and assigns softmax weights. The hook accumulates a 3D histogram:

histograms[layer, expert, rank]   β€” integer count of selections
weight_sum[layer, expert, rank]   β€” sum of router softmax weights

rank runs from 0 (highest-weight expert, primary selection) to 7 (lowest-weight, filler). Capturing per-rank information preserves the router's confidence signal: a rank-0 firing (the expert is the router's first choice) is qualitatively different from a rank-7 firing (the expert fills the last slot with low confidence).

Step 3 β€” Utility Scoring

Each (layer, expert) pair receives a scalar utility score:

util[l,e]=βˆ‘k=07histograms[l,e,k]NtokensΓ—weight_sum[l,e,k]max⁑(histograms[l,e,k],1)\text{util}[l, e] = \sum_{k=0}^{7} \frac{\text{histograms}[l,e,k]}{N_\text{tokens}} \times \frac{\text{weight\_sum}[l,e,k]}{\max(\text{histograms}[l,e,k], 1)}

This is the frequency-weighted mean router confidence β€” how often the expert is selected, weighted by how much the router trusts it when it does fire. Experts that fire rarely but at high confidence (niche specialists) score proportionally higher than experts that fire frequently at marginal confidence (generalists).

Expert indices are local to each layer β€” expert N in layer 0 and expert N in layer 15 are completely independent entities with no shared weights. All selection and ranking operations are performed per-layer.

Step 4 β€” Three-Pass Mask Construction

Pass 1 β€” Domain baseline: Select the top-64 experts per layer by utility score. This captures the most domain-activated experts in the standard activation sense.

Pass 2 β€” Structural whitelist enforcement: A set of experts identified as those experts that have an average activation rank of less than 2 and a minimum number of activations of 10 or more regardless of overall utility ranking. These are then swapped into the model if they are not included already by utility rank by swapping with existing included experts with low average rank and low utility. Applied to ensure high-confidence structural experts are never displaced by marginally scoring domain specialists.

Pass 3 β€” CoT/reasoning arbitrage: Experts that activate strongly on domain-agnostic logic/reasoning chain-of-thought traces are swapped into the mask. Applied at a cap of 3 swaps per layer; β‰ˆ85–95 total swaps across 30 layers.

Step 5 β€” GGUF Surgery

The mask JSON specifies which 64 of 128 experts to retain per layer. The surgery script reads the parent GGUF, zeroes the ffn_gate, ffn_up, and ffn_down weight tensors for all non-mask experts, and writes the result as a new GGUF. Tensor norms are verified post-surgery; any NaN or Inf aborts the process. Attention layers, embedding layers, and the shared expert are untouched.


Citation / Attribution

Research and engineering by JThomas-CoE.

Base model: Gemma 4 26B-A4B-IT by Google. All specialist weights are derived from the publicly released checkpoint. Usage is subject to the Gemma Terms of Use.


License

Model weights: subject to the Gemma license (see above).
Code and tooling: PolyForm Noncommercial 1.0.0
Commercial licensing: see LICENSE-COMMERCIAL.md

Downloads last month
110
GGUF
Model size
14B params
Architecture
gemma4
Hardware compatibility
Log In to add your hardware

4-bit

Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support