# Gemma4 College of Experts — Physics 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-physics-14b-a4b-q4` | **Ollama:** `coe-gemma4-physics-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 physics practitioner.
Present solutions with clearly labelled steps, show all working, and state the physical principle applied at each step. If your answer is in regard to experimental work or live demonstrations include best practice and safety guidelines as appropriate.
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
A domain-representative text corpus is assembled: textbook prose, problem-set Q&A pairs, structured reference material, and (for technical domains) model-generated think-on traces on domain questions. Corpus size: approximately 234,000 tokens across the blended physics and physics_hydrated sub-corpora.
**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. 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 physics_hydrated sub-corpus (extended think-on traces covering a broader sweep of physics topics) was included precisely to address depth coverage, but each addition was evaluated against the risk of broadening the domain signal too far toward general STEM reasoning. 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 filing (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 physics, chemistry, math, and engineering specialists.
**Pass 3 — CoT/reasoning arbitrage:** Experts that activate strongly on domain agnostic logic/reasoning chain-of-thought traces are swapped into the mask in the same manner as the whitelist experts. This installs logic/reasoning chain-of-thought capacity that is not reliably captured by domain-text profiling alone. Applied at a cap of 6 swaps per layer with the additional requirement that the swap candidate have higher utility than the expert it is replacing; ≈160–175 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.
---
## Models in This Release
### Physics Specialist
**HF:** `JThomas-CoE/coe-gemma4-physics-hc-14b-a4b-q4` | **Ollama:** `coe-gemma4-physics-14b-a4b:q4` (Q4_K_M)
Profiling corpus: physics textbook prose across core subfields, hydrated-KB physics problem sets, model-generated think-off Q&A traces on 92 physics questions, and original think-on traces for chain-of-thought coverage. Mask type: domain-baseline + structural whitelist enforcement + CoT/reasoning arbitrage (swapactive).
**92-question physics benchmark** (think_off, 12 subfields):
| Metric | Score |
|---|---|
| FULL | **75/92 (81.5%)** |
| PARTIAL | 11/92 (12.0%) |
| FAIL | 6/92 (6.5%) — all stochastic |
All 6 FAIL cases were re-run 4× each (24 additional inferences). Zero consistent failures — all 6 pass on at least 3 of 4 additional draws. Under a 2-draw retry policy the effective FULL rate is approximately 87–88%. The CoE framework's automatic loop/empty detection and quality-gated retry ladder makes the production failure rate approach zero.
Per-subfield breakdown (all think_off):
| Subfield | FULL% |
|---|---|
| solid_state | 100% |
| special_relativity | 100% |
| fluid_mechanics | 100% |
| optics_nonlinear | 100% |
| electromagnetism | 91% |
| general_relativity | 86% |
| quantum_mechanics | 80% |
| particle_physics | 88% |
| thermodynamics | 90% |
| optics | 50% |
| classical_mechanics | 63%* |
| nuclear_physics | 75%* |
*Stochastic instability on single-shot run; reruns confirm higher true accuracy.
**MMLU-Pro Physics** (1,299 questions, 10-choice MCQ, think_off):
| | HC Specialist K=64 | Parent Q4¹ | Δ (pass@1) |
|---|---|---|---|
| pass@1 | 79.9% (≈1038/1299) | **87.3%** (453/519) | −7.4 pp |
| pass@5 | **90.7%** (1178/1299) | not evaluated | — |
¹ Parent evaluated on 4 OOD splits (n=519, ±1.5 pp 1σ) vs HC on full 1,299 questions (±0.8 pp 1σ). The parent figure has roughly 2× the uncertainty of the HC figure; treat the −7.4 pp pass@1 gap as directionally reliable but not precisely calibrated.
**Interpretation.** The HC physics corpus was assembled from textbook prose, problem-set derivations, and think-on traces — not from MMLU-Pro-style 10-choice MCQ. The −7.4 pp pass@1 deficit relative to parent on MMLU-Pro questions is therefore expected: the expert mask is optimised for open-ended derivation, not letter-selection. The pass@5 recovery to 90.7% confirms that the domain knowledge is present and accessible — given multiple attempts the model reaches the correct answer — but the single-shot MCQ register is not the natural output format for this specialist. The 92-question custom derivation benchmark (above) is the primary measure of HC physics capability.
**Recommended configuration:** T=0.6. KB injection via `<context>` block is the highest-leverage deployment improvement — the physics specialist verifiably prefers injected constant values over memorized ones. A calculation backend (Python `math.pow` / `math.exp`) eliminates the small-arithmetic final-step error class entirely and is strongly recommended for deployed workflows.
**Related model:** An MMLU-Pro–derived physics specialist (`JThomas-CoE/coe-gemma4-physics-mmlu_pro-14b-a4b-q4`) produced via the automated pipeline is also available. See [HF_README_coe-gemma4-mmlu_pro_batch.md](https://huggingface.co/JThomas-CoE) for the automated-pipeline methodology and comparison.
---
## 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 → math), "FAR" pairs are semantically distant (law → math). 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: a score of 70% on law (hard for every model) and 70% on math (easy for every model) are not equivalent — normalizing by the parent baseline makes them comparable.
### Structural Similarity Predictors
Two measures of how similar two specialists' expert populations are:
- **F-score (binary):** fraction of experts in the visitor's mask that also appear in the target's mask after subtraction of experts found in all masks (set overlap)
- **Agg-cos (budget-weighted cosine):** cosine similarity between the two models' per-layer activation utility vectors, weighted by expert budget
Both are computed from the activation histograms at zero inference cost.
### Full 20-Pair Results
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 | F-score | Agg-cos |
|---|---|---|---|---|---|---|---|---|---|
| 01 | NEAR | physics | math | 135 | 88.9% | 0.945 | 0.029 | 0.787 | 0.764 |
| 02 | FAR | law | math | 135 | 18.5% | 0.197 | 0.036 | 0.485 | 0.440 |
| 03 | NEAR | chemistry | physics | 130 | 83.1% | 0.952 | 0.038 | 0.855 | 0.842 |
| 04 | FAR | law | physics | 130 | 10.0% | 0.115 | 0.030 | 0.448 | 0.396 |
| 05 | NEAR | physics | engineering | 97 | 63.9% | 0.880 | 0.067 | 0.854 | 0.841 |
| 06 | FAR | law | engineering | 97 | 12.4% | 0.170 | 0.046 | 0.421 | 0.367 |
| 07 | NEAR | math | cs | 41 | 90.2% | **1.089** | 0.056 | 0.723 | 0.700 |
| 08 | FAR | law | cs | 41 | 51.2% | 0.618 | 0.094 | 0.485 | 0.437 |
| 09 | NEAR | physics | chemistry | 113 | 74.3% | 0.844 | 0.047 | 0.855 | 0.842 |
| 10 | FAR | law | chemistry | 113 | 13.3% | 0.151 | 0.036 | 0.413 | 0.363 |
| 11 | NEAR | psychology | biology | 72 | 75.0% | 0.834 | 0.057 | 0.749 | 0.721 |
| 12 | FAR | business | biology | 72 | 54.2% | 0.603 | 0.065 | 0.576 | 0.534 |
| 13 | NEAR | psychology | economics | 84 | 65.5% | 0.745 | 0.059 | 0.739 | 0.713 |
| 14 | FAR | chemistry | economics | 84 | 65.5% | 0.745 | 0.059 | 0.571 | 0.535 |
| 15 | NEAR | math | business | 79 | 77.2% | 0.884 | 0.054 | 0.756 | 0.732 |
| 16 | FAR | law | business | 79 | 13.9% | 0.159 | 0.045 | 0.541 | 0.499 |
| 17 | NEAR | biology | psychology | 80 | 65.0% | 0.782 | 0.064 | 0.749 | 0.721 |
| 18 | FAR | engineering | psychology | 80 | 62.5% | 0.752 | 0.065 | 0.486 | 0.436 |
| 19 | NEAR | economics | law | 110 | 45.5% | 0.730 | 0.076 | 0.701 | 0.676 |
| 20 | FAR | chemistry | law | 110 | 33.6% | 0.540 | 0.072 | 0.413 | 0.363 |
### Key Observations
- **Every NEAR pair outperforms its FAR counterpart.** The near/far gap never reverses. This is the primary finding: semantic proximity in the specialist's training domain predicts transfer efficiency.
- **Physics appears in four NEAR pairs** (rows 01, 03, 05, 09) and achieves Y = 0.945, 0.952, 0.880, and 0.844 respectively — consistently strong transfer to adjacent STEM domains. Law collapses to Y = 0.115 on physics (row 04), the sharpest far-transfer collapse in the experiment.
- **Law collapses on all STEM targets** (Y = 0.115–0.197 on physics/engineering/chemistry). This is the strongest evidence that the expert populations are genuinely semantically organized — the law specialist's experts are not incidentally narrow, they are specifically legal.
- **Chemistry → economics = psychology → economics (pair 13/14 tie):** Both achieve Y = 0.745. Economics sits at an intersection of quantitative (chemistry-accessible) and social-science (psychology-accessible) reasoning.
### Correlation with Structural Predictors
Pearson r against transfer efficiency Y (n = 20):
| Predictor | r |
|---|---|
| F-score (expert set overlap) | 0.800 |
| Agg-cos (budget-weighted cosine) | 0.791 |
| Layer variance of alignment (Std/Agg) | −0.746 |
| Raw specialist home accuracy (confounded) | 0.858* |
*Confounded by domain difficulty; collapses to r ≈ 0.615 after normalizing by parent baseline.
**Best multi-predictor model** (Agg-cos + layer-heterogeneity + normalized specialist quality):
R² = 0.796, adj-R² = 0.757, p = 1.28 × 10⁻⁷
### Scatter Plots
Two-panel scatter plot: transfer efficiency (Y) vs F-score (left, r = 0.800) and vs OLS composite fitted value (right, r = 0.892).

NEAR pairs (blue circles) cluster in the top-right of both panels; FAR pairs (red squares) cluster bottom-left. Error bars are ±1σ (binomial standard error propagated through the parent normalization).
---
## Architectural Background — College of Experts
These models are the surgical specialist components of a broader **College of Experts (CoE)** architecture. The full system routes queries to the appropriate specialist at the task level (not the token level), each specialist serving its domain at reduced VRAM cost. A lightweight supervisor model analyzes the incoming query and dispatches to the most capable specialist.
The key insight enabling this approach: Gemma4-26B-A4B's MoE routing is **semantically organized**. Experts that activate strongly on physics problems do not activate strongly on legal reasoning, and vice versa. This is not imposed by training — it emerges from the model's internal organization. The activation profiling and near/far transfer experiments in this release are the empirical demonstration of that structure. The very nature of MoE architectures made this possibility likely and we have found qualitative evidence for it previously in other MoE models (Qwen family) but this work supports it unequivocally and in a different model system.
By fixing K=64 (50% of the expert pool) and selecting the 64 experts most relevant to each domain, we produce a model that:
1. Uses identical VRAM to the original architecture per forward pass (9 experts fire per token either way)
2. Reduces total memory residency by ≈38% at Q4, eliminating the need to keep 64 cold experts in memory
3. Concentrates the active compute on experts that are actually useful for the task
The practical result is near SOTA-competitive performance at consumer-grade hardware footprints. A similar framework applied at enterprise scale — where the reduction in memory per token generated is on the order of hundreds of GB per instance — could make a significant difference in server farm capacity and cost.
---
## Known Limitations
1. **Think-on mode is not reliable.** See the ⚠️ section above. Do not use think_on without a substantially larger token budget (≥ 32,768 num_predict) and expect degraded performance relative to think_off even then.
2. **Arithmetic precision.** The physics specialist produces small floating-point arithmetic errors on hard exponentiation (e.g. Re^0.8, fractional power of 5-digit numbers). The formula and reasoning are almost always correct; the mental arithmetic at the final step is not. A calculation backend (Python tool call, `math.pow` / `math.exp`) eliminates this class of error entirely and is strongly recommended for engineering and physics workflows; however a compatible runtime backend is required. Ollama integration for tool calls is currently problematic and left to future work.
3. **No retrieval augmentation out of the box.** KB injection dramatically improves performance on applied problems. The physics specialist has been verified to prefer injected constant values over memorized ones when provided via the `<context>` block pattern. Building a retrieval pipeline around a domain-specific corpus is the highest-leverage deployment improvement available.
4. **Loop instability at high temperature.** T ≥ 0.8 materially increases loop rates in think_off mode. Use T = 0.6 for all production deployments.
5. **Vision capability — out of scope.** The Gemma4-26B-A4B parent model is natively multimodal (text + image input). All activation profiling in this release was conducted exclusively on text corpora. No effort was made to specifically retain or specifically remove the vision-processing expert population; vision experts were subject to the same 50% selection as all others, with the mask driven entirely by text-domain activation signal. Preliminary testing suggests a nominally coherent remnant of vision capability survives surgery, but fidelity relative to the parent has not been characterized. Vision input should not be treated as a benchmarked or supported capability. Systematic profiling of vision-domain experts and deliberate preservation of the vision pathway is left to future work.
---
## 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)