neuralworm commited on
Commit
a4d8bec
·
verified ·
1 Parent(s): 757ff71

Upload folder using huggingface_hub

Browse files
Files changed (4) hide show
  1. README.md +10 -29
  2. config.json +6 -6
  3. configuration_gemma_px.py +11 -0
  4. modeling_gemma_px.py +25 -0
README.md CHANGED
@@ -1,17 +1,6 @@
1
- ---
2
- license: gemma
3
- base_model: google/gemma-3-270m-it
4
- tags:
5
- - gemma-3
6
- - open-mythos
7
- - recursive-transformer
8
- - cognitive-routing
9
- - experimental
10
- ---
11
-
12
- # Gemma-3 270M-IT "Open-Mythos" (Phase 2.8)
13
 
14
- This is an experimental architectural modification of the **Google Gemma-3 270M-IT** base model. It implements the "Open-Mythos" (PX) architecture, introducing **Recursive Computational Headroom** and **Fluid Gaussian Cognitive Routing**.
15
 
16
  ## ⚠️ Transparency Notice
17
  **This is not a standard fine-tune.** It is a structural mod that changes how the transformer processes tokens at inference time.
@@ -21,23 +10,18 @@ This is an experimental architectural modification of the **Google Gemma-3 270M-
21
  ## 🚀 Key Innovations
22
 
23
  ### 1. Recursive Computational Headroom (PX)
24
- Unlike standard transformers that pass through each layer once, Open-Mythos allows the model to "re-read" and "think" through specific layers (L5-L12) multiple times. This effectively increases the depth of the model for complex tasks without adding new parameters.
25
 
26
  ### 2. Fluid Gaussian Cognitive Routing
27
- The model dynamically analyzes the "cognitive signature" (Kurtosis) of each prompt during the prefill phase. Based on this signature, it automatically routes the task through a specific "Cognitive Envelope":
28
- - **Math Mode:** Optimized for numerical precision (L5-L11).
29
- - **Logic Mode:** Optimized for multi-step reasoning (L8-L12).
30
- - **Creative Mode:** Optimized for semantic drift and metaphor (L10-L16).
31
- - **Synthesis Mode:** Optimized for extraction and summarization (L6-L14).
32
-
33
- Transitions between these modes are **continuous and fluid** using Gaussian blending, allowing the model to self-determine its reasoning path.
34
-
35
- ### 3. Numerical Stability (RMSNorm Fix)
36
- Implements a surgical fix for the Gemma-3 RMSNorm scaling (`1.0 + weight`) to prevent signal collapse during deep recursion, ensuring vocabulary integrity across high-entropy generations.
37
 
38
  ## 💻 Usage
39
 
40
- To use this model, you **must** set `trust_remote_code=True` because it uses custom modeling code to implement the recursive logic.
41
 
42
  ```python
43
  import torch
@@ -61,8 +45,5 @@ outputs = model.generate(**inputs, max_new_tokens=100)
61
  print(tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))
62
  ```
63
 
64
- ## 📊 Performance
65
- Open-Mythos (Phase 2.8) significantly improves zero-shot performance on "Logical Traps" and multi-step reasoning compared to the pure 270M baseline, while remaining multimodal-ready and regression-free for standard NLP tasks.
66
-
67
  ---
68
- *Created as part of the Open-Mythos Research Project (2026).*
 
1
+ # Gemma-3 270M-IT-PX (Phase 2.8)
 
 
 
 
 
 
 
 
 
 
 
2
 
3
+ This is an experimental architectural modification of the **Google Gemma-3 270M-IT** base model. It implements the **PX (Recursive Computational Headroom)** architecture and **Fluid Gaussian Cognitive Routing**.
4
 
5
  ## ⚠️ Transparency Notice
6
  **This is not a standard fine-tune.** It is a structural mod that changes how the transformer processes tokens at inference time.
 
10
  ## 🚀 Key Innovations
11
 
12
  ### 1. Recursive Computational Headroom (PX)
13
+ Unlike standard transformers that pass through each layer once, Gemma-3-PX allows the model to "re-read" and "think" through specific layers multiple times. This effectively increases the depth of the model for complex tasks without adding new parameters.
14
 
15
  ### 2. Fluid Gaussian Cognitive Routing
16
+ The model dynamically analyzes the "cognitive signature" (Kurtosis) of each prompt during the prefill phase and automatically routes the task through a specific "Cognitive Envelope":
17
+ - **Math Mode:** Optimized for numerical precision.
18
+ - **Logic Mode:** Optimized for multi-step reasoning.
19
+ - **Creative Mode:** Optimized for semantic drift and metaphor.
20
+ - **Synthesis Mode:** Optimized for extraction and summarization.
 
 
 
 
 
21
 
22
  ## 💻 Usage
23
 
24
+ To use this model, you **must** set `trust_remote_code=True`.
25
 
26
  ```python
27
  import torch
 
45
  print(tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))
46
  ```
47
 
 
 
 
48
  ---
49
+ *Developed by neuralworm (2026).*
config.json CHANGED
@@ -1,7 +1,7 @@
1
  {
2
  "_sliding_window_pattern": 6,
3
  "architectures": [
4
- "OpenMythosForCausalLM"
5
  ],
6
  "attention_bias": false,
7
  "attention_dropout": 0.0,
@@ -36,7 +36,7 @@
36
  "full_attention"
37
  ],
38
  "max_position_embeddings": 32768,
39
- "model_type": "open_mythos",
40
  "num_attention_heads": 4,
41
  "num_hidden_layers": 18,
42
  "num_key_value_heads": 1,
@@ -62,8 +62,8 @@
62
  "use_cache": true,
63
  "vocab_size": 262144,
64
  "auto_map": {
65
- "AutoConfig": "configuration_openmythos.OpenMythosConfig",
66
- "AutoModelForCausalLM": "modeling_openmythos.OpenMythosForCausalLM",
67
- "AutoModel": "modeling_openmythos.OpenMythosModel"
68
  }
69
- }
 
1
  {
2
  "_sliding_window_pattern": 6,
3
  "architectures": [
4
+ "Gemma3PXForCausalLM"
5
  ],
6
  "attention_bias": false,
7
  "attention_dropout": 0.0,
 
36
  "full_attention"
37
  ],
38
  "max_position_embeddings": 32768,
39
+ "model_type": "gemma_3_px",
40
  "num_attention_heads": 4,
41
  "num_hidden_layers": 18,
42
  "num_key_value_heads": 1,
 
62
  "use_cache": true,
63
  "vocab_size": 262144,
64
  "auto_map": {
65
+ "AutoConfig": "configuration_gemma_px.Gemma3PXConfig",
66
+ "AutoModelForCausalLM": "modeling_gemma_px.Gemma3PXForCausalLM",
67
+ "AutoModel": "modeling_gemma_px.Gemma3PXModel"
68
  }
69
+ }
configuration_gemma_px.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import PretrainedConfig
2
+ from transformers.models.gemma3.configuration_gemma3 import Gemma3TextConfig
3
+
4
+ class Gemma3PXConfig(Gemma3TextConfig):
5
+ model_type = "gemma_3_px"
6
+
7
+ def __init__(self, **kwargs):
8
+ super().__init__(**kwargs)
9
+ # Default config for 270m
10
+ self.px_routing_mode = kwargs.get("px_routing_mode", "adaptive")
11
+ self.px_gamma = kwargs.get("px_gamma", 0.10)
modeling_gemma_px.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers.models.gemma3.modeling_gemma3 import Gemma3ForCausalLM, Gemma3Model
2
+ from .configuration_gemma_px import Gemma3PXConfig
3
+ from .patch import apply_px_patch
4
+
5
+ class Gemma3PXForCausalLM(Gemma3ForCausalLM):
6
+ config_class = Gemma3PXConfig
7
+
8
+ def __init__(self, config):
9
+ super().__init__(config)
10
+ # We apply the patch immediately after initialization
11
+ # Extract default parameters from the config if they exist
12
+ routing_mode = getattr(config, "px_routing_mode", "adaptive")
13
+ gamma = getattr(config, "px_gamma", 0.10)
14
+
15
+ # We MUST start the initial prelude at Layer 5 so the Kurtosis probe
16
+ # (which is calibrated for L5) reads the correct tensor.
17
+ # The router will fast-forward the remaining layers if dynamic_start > 5.
18
+ apply_px_patch(self, recur_start=5, recur_end=12, routing_mode=routing_mode, gamma=gamma)
19
+
20
+ # For safety, if they instantiate the base model directly:
21
+ class Gemma3PXModel(Gemma3Model):
22
+ config_class = Gemma3PXConfig
23
+
24
+ def __init__(self, config):
25
+ super().__init__(config)