# Gemma4 College of Experts — Engineering Specialist
**Base model:** [google/gemma-4-26b-it](https://huggingface.co/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-engineering-hc-14b-a4b-q4` | **Ollama:** `coe-gemma4-engineering-14b-a4b:q4`
**Hub:** [JThomas-CoE on HuggingFace](https://huggingface.co/JThomas-CoE)
> **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:
```python
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 engineering practitioner.
Present solutions with clearly labelled steps, show all working, and state the engineering principle or standard applied at each step. List best practice guidelines and safety protocals when applicable.
For numerical problems, track units throughout and verify dimensional consistency.
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 and reduce numerical precision on applied problems.
---
## 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.
---
## Activation Profiling — How the Masks Are Built
### Step 1 — Corpus Assembly
The engineering corpus combines:
- **Engineering textbook prose** — core subfields including structural mechanics, thermodynamics, fluid dynamics, circuit analysis, signals and systems, materials science, and control theory
- **Problem-set Q&A pairs** — worked examples and applied calculation problems across mechanical, electrical, and civil engineering subfields
- **Applied mathematics coverage** — differential equations, linear algebra, numerical methods as applied in engineering contexts
- **Supplementary STEM bridging** — physics and applied mathematics content to ensure the expert mask spans the full quantitative reasoning chain from first principles to engineered systems
Corpus size: approximately 558,000 tokens (engineering_vocational + engineering_applied + engineering_tech sub-corpora, blended with supplemented v2 pass). 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 (e.g. control-loop stability analysis, Laplace transforms in circuit theory) may appear in too few tokens to accumulate statistically reliable activation counts, leaving their associated experts underweighted or excluded from the mask. On the other side, a corpus that grows too large — particularly if expansion is driven by including only tangentially related material to hit a token budget — risks diluting the activation signal. 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. The corpus assembled here was grown iteratively, with sub-corpus additions reviewed for domain relevance before inclusion. 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 arrest growth at the point of diminishing domain focus. 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:
$$\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 (supplemented):** 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. Additionally, the corpus was supplemented with a second round of higher-difficulty engineering problem traces to capture experts activated on multi-step applied calculation. This supplementation pass (`engineering-a-v2-supplemented`) is the version designated for this release.
### 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.
---
## Models in This Release
### Engineering Specialist (supplemented v2)
**HF:** `JThomas-CoE/coe-gemma4-engineering-hc-14b-a4b-q4` | **Ollama:** `coe-gemma4-engineering-14b-a4b:q4` (Q4_K_M)
Profiling corpus: engineering textbook prose across core subfields, applied calculation problem sets, physics/applied-math bridging content, supplemented with a higher-difficulty problem trace pass.
**MMLU-Pro Engineering** (969 questions, 10-choice MCQ, think_off):
| | HC Specialist K=64 | MMLU-Pro Specialist | Parent Q4 |
|---|---|---|---|
| Accuracy | **82.4%** (798/969) | 72.2% | 76.3% |
The HC engineering specialist scores **+6.1 pp above the unmodified parent** and **+10.2 pp above the MMLU-Pro profiled engineering specialist** on the same MMLU-Pro Engineering question set. The hand-curated corpus — spanning textbook depth across multiple engineering subfields — provides more comprehensive expert coverage than the MMLU-Pro benchmark-derived profiling set.
**Memory note:** 9 experts activate per token at both K=64 and K=128; the pool restriction saves ≈7.1 GB of VRAM at Q4 (measured, approximately context-independent) with identical throughput and zero post-surgery training.
**Related model:** An MMLU-Pro–derived engineering specialist (`JThomas-CoE/coe-gemma4-engineering-mmlu_pro-14b-a4b-q4`) produced via the automated pipeline is also available. See the [automated pipeline README](https://huggingface.co/JThomas-CoE) for methodology.
---
## Near/Far Transfer Benchmark — Measuring Semantic Localization
One of the core questions in the College of Experts project is whether activation-directed expert surgery produces genuine **semantic localization** — specialist models whose expert populations are structurally organized around knowledge domains, not just quantization artifacts.
To test this, we ran a 20-pair cross-domain transfer efficiency experiment. Each pair sends one specialist model to answer questions from a different domain's benchmark. "NEAR" pairs are semantically adjacent (physics → engineering), "FAR" pairs are semantically distant (law → engineering). If expert populations are semantically organized, NEAR visitors should transfer well and FAR visitors should collapse.
### Transfer Efficiency Metric
Raw accuracy is confounded by domain difficulty. We normalize by the parent model's accuracy on the same questions:
$$Y = \frac{\text{acc}_\text{visitor on target}}{\text{par}_\text{target}}$$
Y = 1.0 means the specialist recovers 100% of what the unmodified parent achieves on the target domain. Y > 1 means it exceeds the parent. This removes the domain difficulty confound.
### Engineering-Relevant Transfer Pairs
All benchmarks use OOD off5 split (40% of questions held out from profiling), think_off mode.
| # | Arm | Visitor | Target | n | Acc | Y=Acc/Par | σ\_Y |
|---|---|---|---|---|---|---|---|
| 05 | NEAR | physics | engineering | 97 | 63.9% | 0.880 | 0.067 |
| 06 | FAR | law | engineering | 97 | 12.4% | 0.170 | 0.046 |
| 18 | FAR | engineering | psychology | 80 | 62.5% | 0.752 | 0.065 |
**Pair 05 (NEAR):** The physics specialist — which shares significant expert overlap with engineering — recovers 88% of parent performance on engineering questions. This confirms that the engineering expert population lies in a semantically contiguous region of the expert space relative to physics.
**Pair 06 (FAR):** The law specialist collapses to 17% of parent performance on engineering questions (Y = 0.170). This is the strongest FAR pair result in the entire experiment for STEM targets — engineering's quantitative character is maximally inaccessible to a language-domain specialist.
**Pair 18 (FAR):** When the engineering specialist is sent to answer psychology questions — a semantically distant target — it retains 75.2% of parent performance. This is substantially higher than law's FAR performance on STEM targets, reflecting that engineering reasoning includes some general analytical capacity that partially transfers across domains.
### Key Finding
The near/far gap on engineering (0.880 NEAR vs 0.170 FAR, Δ = 0.710) is the largest absolute gap of any target domain in the full 20-pair experiment, providing strong evidence that the engineering expert population is tightly and distinctively organized around quantitative STEM reasoning.
The full 20-pair results table is available in the math specialist README: [`JThomas-CoE/coe-gemma4-math-hc-14b-a4b-q4`](https://huggingface.co/JThomas-CoE/coe-gemma4-math-hc-14b-a4b-q4).
---
## Citation / Attribution
Research and engineering by JThomas-CoE.
- **Project repository:** [College-of-Experts-AI](https://github.com/JThomas-CoE/College-of-Experts-AI) — code, tooling, and methodology documentation
- **Gemma4 methodology:** [gemma4/README.md](https://github.com/JThomas-CoE/College-of-Experts-AI/blob/main/gemma4/README.md)
- **Whitepaper:** [WHITEPAPER.md](https://github.com/JThomas-CoE/College-of-Experts-AI/blob/main/WHITEPAPER.md) — theoretical basis for expert specialization
- **Preprint:** [Separability of Intelligence](https://github.com/JThomas-CoE/College-of-Experts-AI/blob/main/qwen3.5/PREPRINT.md) — empirical evidence from the prior MoE specialist series
- **Model hub:** [huggingface.co/JThomas-CoE](https://huggingface.co/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](https://ai.google.dev/gemma/terms).
---
## License
Model weights: subject to the Gemma license (see above).
Code and tooling: PolyForm Noncommercial 1.0.0
Commercial licensing: see [LICENSE-COMMERCIAL.md](https://github.com/JThomas-CoE/College-of-Experts-AI/blob/main/LICENSE-COMMERCIAL.md)