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
+
tags:
|
| 5 |
+
- vindex
|
| 6 |
+
- larql
|
| 7 |
+
- gemma4
|
| 8 |
+
- gguf
|
| 9 |
+
- mechanistic-interpretability
|
| 10 |
+
- knowledge-editing
|
| 11 |
+
- constellation-edits
|
| 12 |
+
base_model: google/gemma-4-e2b-it
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
# Gemma 4 e2b — LarQL Vindex v0.2
|
| 16 |
+
|
| 17 |
+
First-ever published [LarQL](https://github.com/chrishayuk/larql) vindex for Google's Gemma 4.
|
| 18 |
+
|
| 19 |
+
A **vindex** is a transformer's weights decompiled into a queryable feature database — entity associations, circuit structure, and knowledge-editing surfaces exposed as APIs. No GPU required for most operations.
|
| 20 |
+
|
| 21 |
+
## What this is / What this is not
|
| 22 |
+
|
| 23 |
+
| ✅ What this IS | ❌ What this IS NOT |
|
| 24 |
+
|----------------|-------------------|
|
| 25 |
+
| A feature-space index for Gemma4-e2b-it | A language model |
|
| 26 |
+
| Exposes entity associations via `/v1/walk` | `/v1/infer` does NOT produce factual completions |
|
| 27 |
+
| Enables rank-1 knowledge edits (DELETE/INSERT) | Not a replacement for the base Gemma4 weights |
|
| 28 |
+
| Circuit analysis (broadcast→domain→entity→prediction) | Not a general inference engine |
|
| 29 |
+
|
| 30 |
+
**Critical note on `/v1/infer`:** This endpoint returns a feature-modulated projection of the host model's activations — not a coherent text-generation distribution. Output is incoherent subword tokens by design (the vindex is a feature graph, not a full transformer forward pass). For factual completion, use `google/gemma-4-e2b-it` directly. Use `/v1/walk` and `/v1/patch` for the validated operations this vindex is designed for.
|
| 31 |
+
|
| 32 |
+
**Validated surfaces:** `/v1/walk` (entity-association retrieval), `/v1/describe` (feature neighborhood), `/v1/patch` DELETE/INSERT (rank-1 weight editing, Gate 3 confirmed).
|
| 33 |
+
|
| 34 |
+
## Quick start
|
| 35 |
+
|
| 36 |
+
```bash
|
| 37 |
+
# Install LarQL (requires our fork with Gemma 4 support until upstreamed)
|
| 38 |
+
git clone https://github.com/Divinci-AI/larql.git
|
| 39 |
+
cd larql && cargo build --release
|
| 40 |
+
|
| 41 |
+
# Set environment variables
|
| 42 |
+
export LARQL_SERVICE_URL=<your_larql_cloud_run_url>
|
| 43 |
+
export INTERNAL_LARQL_S2S_TOKEN=<your_s2s_token>
|
| 44 |
+
|
| 45 |
+
# Query entity associations
|
| 46 |
+
curl "$LARQL_SERVICE_URL/v1/walk?prompt=Paris&layers=14-27&top=10" \
|
| 47 |
+
-H "Authorization: Bearer $INTERNAL_LARQL_S2S_TOKEN"
|
| 48 |
+
|
| 49 |
+
# Gate 3 repro: DELETE the Paris→capital feature then verify suppression
|
| 50 |
+
curl -X POST "$LARQL_SERVICE_URL/v1/patches/apply" \
|
| 51 |
+
-H "Authorization: Bearer $INTERNAL_LARQL_S2S_TOKEN" \
|
| 52 |
+
-H "Content-Type: application/json" \
|
| 53 |
+
-d '{"name":"delete-paris-capital","patch":{"version":1,"base_model":"gemma4-e2b","created_at":"2026-04-20T00:00:00Z","operations":[{"op":"delete","entity":"Paris","relation":"capital","target":"서울","weight":1.0,"layer":27,"feature":11179}]}}'
|
| 54 |
+
|
| 55 |
+
# Before: feature 11179 (gate_score=18.1) present in walk
|
| 56 |
+
# After: feature 11179 absent from walk (complete suppression confirmed)
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
## Contents
|
| 60 |
+
|
| 61 |
+
| File | Size | Description |
|
| 62 |
+
|------|------|-------------|
|
| 63 |
+
| `gate_vectors.bin` | 1.0 GB | FFN gate matrices, per-layer variable (f16) |
|
| 64 |
+
| `down_features.bin` | ~1.0 GB | Down-projection transposed [features × hidden], enables walk-mode feature retrieval |
|
| 65 |
+
| `embeddings.bin` | 768 MB | Token embeddings, 262,144 × 1,536 (f16) |
|
| 66 |
+
| `down_meta.bin` | 29 MB | Feature labels via vocab projection |
|
| 67 |
+
| `feature_clusters.jsonl` | 4 MB | K-means clusters over gate features |
|
| 68 |
+
| `relation_clusters.json` | 15 MB | Wikidata relation matching |
|
| 69 |
+
| `norms.bin` | 423 KB | Per-layer normalization weights |
|
| 70 |
+
| `tokenizer.json` | 11 MB | Substitute tokenizer (Qwen 2.5 — real Gemma 4 tokenizer was gated during extraction) |
|
| 71 |
+
| `index.json` | 5 KB | Metadata: 35 layers, hidden=1536, variable FFN (6144 → 12288) |
|
| 72 |
+
| `manifest.json` | 1.1 KB | Vindex version manifest |
|
| 73 |
+
|
| 74 |
+
Total: ~2.8 GB (without full weight files)
|
| 75 |
+
|
| 76 |
+
> **Note on `down_features.bin`:** Generated from `down_weights.bin` via a Python transposition step that handles Gemma 4's variable intermediate sizes per layer (L0-14: 6144, L15-34: 12288). The Rust `build_down_features` binary segfaults on variable intermediate sizes; our fix is the Python Cloud Build step in `build-larql-service.sh`. Required for walk-mode feature retrieval.
|
| 77 |
+
|
| 78 |
+
## Gate 3 Validation (DELETE patch confirmed)
|
| 79 |
+
|
| 80 |
+
Gate 3 test: DELETE patch on Paris → 서울 (Seoul/capital) feature at layer 27, feature 11179.
|
| 81 |
+
|
| 82 |
+
| Metric | Before DELETE | After DELETE |
|
| 83 |
+
|--------|--------------|-------------|
|
| 84 |
+
| Feature 11179 gate_score | 18.10 | ABSENT |
|
| 85 |
+
| Paris capital rank | #2 overall | Absent from top-25 |
|
| 86 |
+
| Walk hits | Feature 11179 present (score 18.1) | Feature 11179 completely absent |
|
| 87 |
+
|
| 88 |
+
**Walk vs dense diverge** after fix: confirms `down_features.bin` is loaded and active.
|
| 89 |
+
|
| 90 |
+
```
|
| 91 |
+
Before: feature=11179 score=18.10 target='서울' ← rank #1
|
| 92 |
+
After: feature=7327 score=9.40 target='PMA' ← 서울 COMPLETELY ABSENT
|
| 93 |
+
```
|
| 94 |
+
|
| 95 |
+
Gate 3 result: **PASS ✓**
|
| 96 |
+
|
| 97 |
+
## Architecture details
|
| 98 |
+
|
| 99 |
+
- **Architecture**: Gemma 4 dense (e2b variant)
|
| 100 |
+
- **Layers**: 35 (L0-14: FFN=6144, L15-34: FFN=12288 — per-layer variable)
|
| 101 |
+
- **Hidden size**: 1536
|
| 102 |
+
- **Head dim**: 256
|
| 103 |
+
- **Attention**: 8 Q heads, 1 KV head (GQA 8:1)
|
| 104 |
+
- **Quantization source**: Q4_K GGUF
|
| 105 |
+
|
| 106 |
+
## Research findings
|
| 107 |
+
|
| 108 |
+
This vindex enabled the following findings (see `notebooks/PAPER_universal_constants.md` in [Divinci-AI/server](https://github.com/Divinci-AI/server)):
|
| 109 |
+
|
| 110 |
+
**Five universal constants across transformer architectures:**
|
| 111 |
+
1. ~12% dominant FFN sparsity (scale-invariant)
|
| 112 |
+
2. Top-8 output concentration (~99.7% at each position)
|
| 113 |
+
3. ~0.97 gate coherence across all layers
|
| 114 |
+
4. ~0.042 layer temperature (log-activation variance)
|
| 115 |
+
5. Broadcast → Domain → Entity → Prediction circuit (4-stage)
|
| 116 |
+
|
| 117 |
+
**Predictive formula:** `active_experts ≈ 1/dominant_sparsity` predicts Gemma 4's top-8 MoE routing within 4% error from structural analysis alone.
|
| 118 |
+
|
| 119 |
+
**Constellation Edits (knowledge editing):** Rank-1 DELETE at the TRACE-identified crown layer (L25 for geography facts) achieves FQ=1.00 in 80ms with full reversibility. Gradient ascent fails due to softmax saturation (gradient=0 at P=1.0 float32). Cross-architecture validation: Mistral-7B FQ=1.00/MU=0.88 (structural rank-1), Qwen2.5-1.5B FQ=1.00 (ROME-style k*). See `notebooks/PAPER_CONSTELLATION_EDITS_DRAFT.md`.
|
| 120 |
+
|
| 121 |
+
## Important notes
|
| 122 |
+
|
| 123 |
+
1. **Substitute tokenizer**: Feature labels show Qwen 2.5 tokens (151,643-vocab), not Gemma 4 tokens. Gate vectors are correct Gemma 4 weights; only the label mapping is approximate.
|
| 124 |
+
|
| 125 |
+
2. **Built with patched LarQL**: 7 bug fixes required for Gemma 4 (column-major loading, Q4_K block size, variable FFN size support, etc.). See https://github.com/Divinci-AI/larql and upstream PR https://github.com/chrishayuk/larql/pull/24.
|
| 126 |
+
|
| 127 |
+
3. **License**: CC-BY-NC 4.0. Academic and research use. Contact [mike@divinci.ai](mailto:mike@divinci.ai) for commercial licensing.
|
| 128 |
+
|
| 129 |
+
## Citation
|
| 130 |
+
|
| 131 |
+
```bibtex
|
| 132 |
+
@misc{mooring2026universalconstants,
|
| 133 |
+
title={Universal Constants of Transformer Intelligence},
|
| 134 |
+
author={Mooring, Mike},
|
| 135 |
+
year={2026},
|
| 136 |
+
note={Preprint. arXiv forthcoming.}
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
@misc{mooring2026constellation,
|
| 140 |
+
title={Constellation Edits: Training-Free Knowledge Injection and Auditable Unlearning via Multi-Layer Feature Patches},
|
| 141 |
+
author={Mooring, Mike},
|
| 142 |
+
year={2026},
|
| 143 |
+
note={Preprint. arXiv forthcoming.}
|
| 144 |
+
}
|
| 145 |
+
```
|
| 146 |
+
|
| 147 |
+
## Acknowledgments
|
| 148 |
+
|
| 149 |
+
Chris Hayuk for creating LarQL. Google DeepMind for Gemma 4. Cloudflare for frontier model hosting.
|