frankenstein-transformer 0.6.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of frankenstein-transformer might be problematic. Click here for more details.

Files changed (190) hide show
  1. frankenstein_transformer-0.6.0/.cbmignore +2 -0
  2. frankenstein_transformer-0.6.0/.gitignore +38 -0
  3. frankenstein_transformer-0.6.0/LICENSE +21 -0
  4. frankenstein_transformer-0.6.0/PKG-INFO +321 -0
  5. frankenstein_transformer-0.6.0/README.md +285 -0
  6. frankenstein_transformer-0.6.0/pyproject.toml +153 -0
  7. frankenstein_transformer-0.6.0/src/__init__.py +0 -0
  8. frankenstein_transformer-0.6.0/src/cli.py +310 -0
  9. frankenstein_transformer-0.6.0/src/deploy/README.md +349 -0
  10. frankenstein_transformer-0.6.0/src/deploy/__init__.py +29 -0
  11. frankenstein_transformer-0.6.0/src/deploy/bitnet_gguf_export.py +508 -0
  12. frankenstein_transformer-0.6.0/src/deploy/deploy.py +386 -0
  13. frankenstein_transformer-0.6.0/src/deploy/deploy_pipeline.bat +67 -0
  14. frankenstein_transformer-0.6.0/src/deploy/deploy_pipeline.sh +61 -0
  15. frankenstein_transformer-0.6.0/src/deploy/example.py +107 -0
  16. frankenstein_transformer-0.6.0/src/deploy/inference.py +564 -0
  17. frankenstein_transformer-0.6.0/src/deploy/quantization.py +479 -0
  18. frankenstein_transformer-0.6.0/src/deploy/transformers_export.py +587 -0
  19. frankenstein_transformer-0.6.0/src/engine.py +1349 -0
  20. frankenstein_transformer-0.6.0/src/engine_hf_tokenizer.py +44 -0
  21. frankenstein_transformer-0.6.0/src/model/__init__.py +27 -0
  22. frankenstein_transformer-0.6.0/src/model/activation_function/__init__.py +121 -0
  23. frankenstein_transformer-0.6.0/src/model/activation_function/common.py +295 -0
  24. frankenstein_transformer-0.6.0/src/model/activation_function/exponential.py +408 -0
  25. frankenstein_transformer-0.6.0/src/model/activation_function/factory.py +259 -0
  26. frankenstein_transformer-0.6.0/src/model/activation_function/glu.py +132 -0
  27. frankenstein_transformer-0.6.0/src/model/activation_function/learnable.py +397 -0
  28. frankenstein_transformer-0.6.0/src/model/activation_function/rectified.py +336 -0
  29. frankenstein_transformer-0.6.0/src/model/attention/__init__.py +96 -0
  30. frankenstein_transformer-0.6.0/src/model/attention/common.py +327 -0
  31. frankenstein_transformer-0.6.0/src/model/attention/engram.py +352 -0
  32. frankenstein_transformer-0.6.0/src/model/attention/gated/__init__.py +35 -0
  33. frankenstein_transformer-0.6.0/src/model/attention/gated/deltanet_attn.py +171 -0
  34. frankenstein_transformer-0.6.0/src/model/attention/gated/falcon_attn.py +1003 -0
  35. frankenstein_transformer-0.6.0/src/model/attention/gated/falcon_common.py +321 -0
  36. frankenstein_transformer-0.6.0/src/model/attention/gated/fox_attn.py +159 -0
  37. frankenstein_transformer-0.6.0/src/model/attention/gated/gated_deltanet2_attn.py +239 -0
  38. frankenstein_transformer-0.6.0/src/model/attention/gated/gated_deltanet_attn.py +175 -0
  39. frankenstein_transformer-0.6.0/src/model/attention/gated/gated_softmax_attn.py +152 -0
  40. frankenstein_transformer-0.6.0/src/model/attention/gated/gla_attn.py +174 -0
  41. frankenstein_transformer-0.6.0/src/model/attention/gated/hgrn2_attn.py +172 -0
  42. frankenstein_transformer-0.6.0/src/model/attention/gated/kda_attn.py +218 -0
  43. frankenstein_transformer-0.6.0/src/model/attention/gated/retnet_attn.py +80 -0
  44. frankenstein_transformer-0.6.0/src/model/attention/grouped_query_attention.py +99 -0
  45. frankenstein_transformer-0.6.0/src/model/attention/latent/__init__.py +83 -0
  46. frankenstein_transformer-0.6.0/src/model/attention/latent/cca_attn.py +573 -0
  47. frankenstein_transformer-0.6.0/src/model/attention/latent/gma_attn.py +339 -0
  48. frankenstein_transformer-0.6.0/src/model/attention/latent/gqla_attn.py +164 -0
  49. frankenstein_transformer-0.6.0/src/model/attention/latent/gta_attn.py +143 -0
  50. frankenstein_transformer-0.6.0/src/model/attention/latent/iha_attn.py +140 -0
  51. frankenstein_transformer-0.6.0/src/model/attention/latent/mla_attn.py +136 -0
  52. frankenstein_transformer-0.6.0/src/model/attention/latent/mlra_attn.py +147 -0
  53. frankenstein_transformer-0.6.0/src/model/attention/latent/mtla_attn.py +167 -0
  54. frankenstein_transformer-0.6.0/src/model/attention/latent/tucker_attn.py +131 -0
  55. frankenstein_transformer-0.6.0/src/model/attention/ode.py +186 -0
  56. frankenstein_transformer-0.6.0/src/model/attention/retnet.py +149 -0
  57. frankenstein_transformer-0.6.0/src/model/attention/sigmoid.py +117 -0
  58. frankenstein_transformer-0.6.0/src/model/attention/sparse/__init__.py +21 -0
  59. frankenstein_transformer-0.6.0/src/model/attention/sparse/bigbird_attn.py +192 -0
  60. frankenstein_transformer-0.6.0/src/model/attention/sparse/fasa_attn.py +204 -0
  61. frankenstein_transformer-0.6.0/src/model/attention/sparse/longformer_attn.py +171 -0
  62. frankenstein_transformer-0.6.0/src/model/attention/sparse/msa_attn.py +264 -0
  63. frankenstein_transformer-0.6.0/src/model/attention/sparse/nsa_attn.py +266 -0
  64. frankenstein_transformer-0.6.0/src/model/attention/sparse/sparda_attn.py +208 -0
  65. frankenstein_transformer-0.6.0/src/model/attention/sparse/sparge_attn.py +203 -0
  66. frankenstein_transformer-0.6.0/src/model/attention/sparse/sparse_transformer_attn.py +230 -0
  67. frankenstein_transformer-0.6.0/src/model/attention/sparse/sparsek_attn.py +230 -0
  68. frankenstein_transformer-0.6.0/src/model/attention/ssog.py +401 -0
  69. frankenstein_transformer-0.6.0/src/model/attention/standard.py +113 -0
  70. frankenstein_transformer-0.6.0/src/model/attention/titan.py +128 -0
  71. frankenstein_transformer-0.6.0/src/model/config.py +1144 -0
  72. frankenstein_transformer-0.6.0/src/model/embeddings/__init__.py +40 -0
  73. frankenstein_transformer-0.6.0/src/model/embeddings/alibi.py +123 -0
  74. frankenstein_transformer-0.6.0/src/model/embeddings/bam.py +144 -0
  75. frankenstein_transformer-0.6.0/src/model/embeddings/factorized_embedding.py +82 -0
  76. frankenstein_transformer-0.6.0/src/model/embeddings/factory.py +151 -0
  77. frankenstein_transformer-0.6.0/src/model/embeddings/hope.py +105 -0
  78. frankenstein_transformer-0.6.0/src/model/embeddings/learned_absolute.py +77 -0
  79. frankenstein_transformer-0.6.0/src/model/embeddings/nope.py +47 -0
  80. frankenstein_transformer-0.6.0/src/model/embeddings/pape.py +197 -0
  81. frankenstein_transformer-0.6.0/src/model/embeddings/pape_efficient.py +199 -0
  82. frankenstein_transformer-0.6.0/src/model/embeddings/pape_ri.py +186 -0
  83. frankenstein_transformer-0.6.0/src/model/embeddings/rope.py +99 -0
  84. frankenstein_transformer-0.6.0/src/model/embeddings/sinusoidal.py +193 -0
  85. frankenstein_transformer-0.6.0/src/model/embeddings/ssmax.py +95 -0
  86. frankenstein_transformer-0.6.0/src/model/frankenstein_decoder.py +166 -0
  87. frankenstein_transformer-0.6.0/src/model/frankenstein_encoder.py +327 -0
  88. frankenstein_transformer-0.6.0/src/model/frankenstein_vit.py +568 -0
  89. frankenstein_transformer-0.6.0/src/model/hybrid_layer.py +565 -0
  90. frankenstein_transformer-0.6.0/src/model/hyperloop.py +304 -0
  91. frankenstein_transformer-0.6.0/src/model/mhc.py +249 -0
  92. frankenstein_transformer-0.6.0/src/model/norm/__init__.py +25 -0
  93. frankenstein_transformer-0.6.0/src/model/norm/derf.py +53 -0
  94. frankenstein_transformer-0.6.0/src/model/norm/dynamic_tanh.py +51 -0
  95. frankenstein_transformer-0.6.0/src/model/norm/factory.py +56 -0
  96. frankenstein_transformer-0.6.0/src/model/norm/flash.py +371 -0
  97. frankenstein_transformer-0.6.0/src/model/norm/rms.py +84 -0
  98. frankenstein_transformer-0.6.0/src/model/optimizer/__init__.py +50 -0
  99. frankenstein_transformer-0.6.0/src/model/optimizer/adafactor.py +157 -0
  100. frankenstein_transformer-0.6.0/src/model/optimizer/adamw.py +37 -0
  101. frankenstein_transformer-0.6.0/src/model/optimizer/adan.py +50 -0
  102. frankenstein_transformer-0.6.0/src/model/optimizer/ademamix.py +40 -0
  103. frankenstein_transformer-0.6.0/src/model/optimizer/adopt.py +40 -0
  104. frankenstein_transformer-0.6.0/src/model/optimizer/anon.py +207 -0
  105. frankenstein_transformer-0.6.0/src/model/optimizer/apollo.py +354 -0
  106. frankenstein_transformer-0.6.0/src/model/optimizer/apollo_mini.py +93 -0
  107. frankenstein_transformer-0.6.0/src/model/optimizer/base.py +194 -0
  108. frankenstein_transformer-0.6.0/src/model/optimizer/cautious_adamw.py +77 -0
  109. frankenstein_transformer-0.6.0/src/model/optimizer/factory.py +305 -0
  110. frankenstein_transformer-0.6.0/src/model/optimizer/galore_adamw.py +168 -0
  111. frankenstein_transformer-0.6.0/src/model/optimizer/lamb.py +111 -0
  112. frankenstein_transformer-0.6.0/src/model/optimizer/lion.py +103 -0
  113. frankenstein_transformer-0.6.0/src/model/optimizer/mars_adamw.py +40 -0
  114. frankenstein_transformer-0.6.0/src/model/optimizer/muon.py +142 -0
  115. frankenstein_transformer-0.6.0/src/model/optimizer/prodigy.py +145 -0
  116. frankenstein_transformer-0.6.0/src/model/optimizer/q_apollo.py +210 -0
  117. frankenstein_transformer-0.6.0/src/model/optimizer/radam.py +39 -0
  118. frankenstein_transformer-0.6.0/src/model/optimizer/schedulefree_adamw.py +41 -0
  119. frankenstein_transformer-0.6.0/src/model/optimizer/sgd_momentum.py +45 -0
  120. frankenstein_transformer-0.6.0/src/model/optimizer/shampoo.py +36 -0
  121. frankenstein_transformer-0.6.0/src/model/optimizer/soap.py +38 -0
  122. frankenstein_transformer-0.6.0/src/model/optimizer/sophia.py +138 -0
  123. frankenstein_transformer-0.6.0/src/model/optimizer/turbo_muon.py +140 -0
  124. frankenstein_transformer-0.6.0/src/model/residuals/__init__.py +39 -0
  125. frankenstein_transformer-0.6.0/src/model/residuals/base.py +163 -0
  126. frankenstein_transformer-0.6.0/src/model/residuals/block_attn_res.py +300 -0
  127. frankenstein_transformer-0.6.0/src/model/residuals/factory.py +99 -0
  128. frankenstein_transformer-0.6.0/src/model/residuals/full_attn_res.py +276 -0
  129. frankenstein_transformer-0.6.0/src/model/residuals/no_residual.py +69 -0
  130. frankenstein_transformer-0.6.0/src/model/residuals/standard.py +63 -0
  131. frankenstein_transformer-0.6.0/src/sbert/README.md +407 -0
  132. frankenstein_transformer-0.6.0/src/sbert/__init__.py +18 -0
  133. frankenstein_transformer-0.6.0/src/sbert/example_usage.py +296 -0
  134. frankenstein_transformer-0.6.0/src/sbert/inference_sbert.py +581 -0
  135. frankenstein_transformer-0.6.0/src/sbert/train_sbert.py +1787 -0
  136. frankenstein_transformer-0.6.0/src/schema/_base_model.yaml +24 -0
  137. frankenstein_transformer-0.6.0/src/schema/_conditional_rules.yaml +218 -0
  138. frankenstein_transformer-0.6.0/src/schema/_examples.yaml +101 -0
  139. frankenstein_transformer-0.6.0/src/schema/_image.yaml +271 -0
  140. frankenstein_transformer-0.6.0/src/schema/_model/_attention_cca.yaml +230 -0
  141. frankenstein_transformer-0.6.0/src/schema/_model/_attention_engram.yaml +103 -0
  142. frankenstein_transformer-0.6.0/src/schema/_model/_attention_falcon.yaml +251 -0
  143. frankenstein_transformer-0.6.0/src/schema/_model/_attention_gma.yaml +190 -0
  144. frankenstein_transformer-0.6.0/src/schema/_model/_attention_latent.yaml +271 -0
  145. frankenstein_transformer-0.6.0/src/schema/_model/_attention_ode.yaml +47 -0
  146. frankenstein_transformer-0.6.0/src/schema/_model/_attention_retnet.yaml +26 -0
  147. frankenstein_transformer-0.6.0/src/schema/_model/_attention_sparse.yaml +101 -0
  148. frankenstein_transformer-0.6.0/src/schema/_model/_attention_ssog.yaml +229 -0
  149. frankenstein_transformer-0.6.0/src/schema/_model/_bitnet.yaml +65 -0
  150. frankenstein_transformer-0.6.0/src/schema/_model/_classification_head.yaml +57 -0
  151. frankenstein_transformer-0.6.0/src/schema/_model/_dims.yaml +363 -0
  152. frankenstein_transformer-0.6.0/src/schema/_model/_embedding.yaml +96 -0
  153. frankenstein_transformer-0.6.0/src/schema/_model/_ffn.yaml +227 -0
  154. frankenstein_transformer-0.6.0/src/schema/_model/_mhc.yaml +318 -0
  155. frankenstein_transformer-0.6.0/src/schema/_model/_mixture_of_depths.yaml +58 -0
  156. frankenstein_transformer-0.6.0/src/schema/_model/_moe.yaml +70 -0
  157. frankenstein_transformer-0.6.0/src/schema/_model/_norm.yaml +110 -0
  158. frankenstein_transformer-0.6.0/src/schema/_model/_positional_encoding.yaml +347 -0
  159. frankenstein_transformer-0.6.0/src/schema/_model/_residuals.yaml +341 -0
  160. frankenstein_transformer-0.6.0/src/schema/_model/_ssmax.yaml +44 -0
  161. frankenstein_transformer-0.6.0/src/schema/_model.yaml +108 -0
  162. frankenstein_transformer-0.6.0/src/schema/_model_class.yaml +29 -0
  163. frankenstein_transformer-0.6.0/src/schema/_optimizer.yaml +291 -0
  164. frankenstein_transformer-0.6.0/src/schema/_sbert.yaml +367 -0
  165. frankenstein_transformer-0.6.0/src/schema/_text_dataset.yaml +96 -0
  166. frankenstein_transformer-0.6.0/src/schema/_tokenizer.yaml +284 -0
  167. frankenstein_transformer-0.6.0/src/schema/_training.yaml +1404 -0
  168. frankenstein_transformer-0.6.0/src/schema/_vision_classification.yaml +32 -0
  169. frankenstein_transformer-0.6.0/src/schema/_vision_dataset.yaml +135 -0
  170. frankenstein_transformer-0.6.0/src/schema/_vision_segmentation.yaml +57 -0
  171. frankenstein_transformer-0.6.0/src/schema.yaml +32 -0
  172. frankenstein_transformer-0.6.0/src/streamlit_gui/__init__.py +5 -0
  173. frankenstein_transformer-0.6.0/src/streamlit_gui/app.py +1330 -0
  174. frankenstein_transformer-0.6.0/src/tokenizer/__init__.py +0 -0
  175. frankenstein_transformer-0.6.0/src/tokenizer/spm_spa_redpajama35.py +284 -0
  176. frankenstein_transformer-0.6.0/src/tokenizer/train_tokenizer.py +223 -0
  177. frankenstein_transformer-0.6.0/src/training/__init__.py +0 -0
  178. frankenstein_transformer-0.6.0/src/training/config_loader.py +400 -0
  179. frankenstein_transformer-0.6.0/src/training/main.py +871 -0
  180. frankenstein_transformer-0.6.0/src/training/streaming_mlm_dataset.py +1021 -0
  181. frankenstein_transformer-0.6.0/src/training/text_dataset_builder.py +417 -0
  182. frankenstein_transformer-0.6.0/src/training/trainer.py +2062 -0
  183. frankenstein_transformer-0.6.0/src/training/vision_dataset.py +352 -0
  184. frankenstein_transformer-0.6.0/src/utils/__init__.py +3 -0
  185. frankenstein_transformer-0.6.0/src/utils/config_flatten.py +539 -0
  186. frankenstein_transformer-0.6.0/src/utils/device.py +62 -0
  187. frankenstein_transformer-0.6.0/src/utils/gpu_temp_guard.py +890 -0
  188. frankenstein_transformer-0.6.0/src/utils/hf_compat.py +198 -0
  189. frankenstein_transformer-0.6.0/src/utils/schema_loader.py +70 -0
  190. frankenstein_transformer-0.6.0/src/utils/storage_manager.py +85 -0
@@ -0,0 +1,2 @@
1
+ !src/deploy/
2
+ !src/deploy/**
@@ -0,0 +1,38 @@
1
+ .venv/
2
+ uv.lock
3
+ wandb/
4
+ output/
5
+ dist/
6
+ **/__pycache__/
7
+ **/*.pyc
8
+ **/temp_data/
9
+ **/logs/
10
+
11
+ **/checkpoints
12
+ **/es_redpajama_50k.model
13
+ **/es_redpajama_50k.vocab
14
+ **/nohup.out**
15
+ **/training_metrics.csv
16
+
17
+ docs/**/*.aux
18
+ docs/**/*.log
19
+ docs/**/*.out
20
+ docs/**/*.toc
21
+ docs/**/*.bbl
22
+ docs/**/*.blg
23
+ docs/_build/
24
+ docs/pdoc/
25
+
26
+ *.csv
27
+
28
+ .opencode/node_modules/
29
+
30
+ # Exhaustive end-to-end harness workspace (generated tokenizers, checkpoints, deploys)
31
+ full_tests/tmp/
32
+ full_tests/runs/
33
+ full_tests/**/__pycache__/
34
+ full_tests/**/*.pyc
35
+ full_tests/**/*.model
36
+ full_tests/**/*.vocab
37
+
38
+ erickfmm.github.io/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Erick Merino
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,321 @@
1
+ Metadata-Version: 2.5
2
+ Name: frankenstein-transformer
3
+ Version: 0.6.0
4
+ Summary: Config-driven, schema-validated training library and CLI for building, training, and deploying hybrid Transformer architectures (attention mixers, BitNet, MoE, SBERT, and Vision Transformers).
5
+ Author-email: Erick Merino <erickfmm@gmail.com>
6
+ License: MIT
7
+ License-File: LICENSE
8
+ Requires-Python: >=3.10
9
+ Requires-Dist: datasets>=3.0.0
10
+ Requires-Dist: numpy<3.0,>=1.26.0
11
+ Requires-Dist: psutil>=5.9.0
12
+ Requires-Dist: pyyaml>=6.0.1
13
+ Requires-Dist: torch>=2.0
14
+ Requires-Dist: tqdm>=4.66.0
15
+ Requires-Dist: transformers<6.0.0,>=4.45.0
16
+ Provides-Extra: cpu
17
+ Requires-Dist: torch==2.7.0+cpu; extra == 'cpu'
18
+ Provides-Extra: cu118
19
+ Requires-Dist: torch==2.6.0+cu118; extra == 'cu118'
20
+ Provides-Extra: cu126
21
+ Requires-Dist: torch==2.7.0+cu126; extra == 'cu126'
22
+ Provides-Extra: cu128
23
+ Requires-Dist: torch==2.7.0+cu128; extra == 'cu128'
24
+ Provides-Extra: sbert
25
+ Requires-Dist: sentence-transformers<5.2.0,>=3.3.0; (python_version < '3.10') and extra == 'sbert'
26
+ Requires-Dist: sentence-transformers>=5.2.0; (python_version >= '3.10') and extra == 'sbert'
27
+ Requires-Dist: sentencepiece>=0.2.0; extra == 'sbert'
28
+ Provides-Extra: train
29
+ Requires-Dist: sentence-transformers<5.2.0,>=3.3.0; (python_version < '3.10') and extra == 'train'
30
+ Requires-Dist: sentence-transformers>=5.2.0; (python_version >= '3.10') and extra == 'train'
31
+ Requires-Dist: sentencepiece>=0.2.0; extra == 'train'
32
+ Requires-Dist: streamlit>=1.39.0; extra == 'train'
33
+ Provides-Extra: web
34
+ Requires-Dist: streamlit>=1.39.0; extra == 'web'
35
+ Description-Content-Type: text/markdown
36
+
37
+ # Frankenstein Transformer
38
+
39
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
40
+ [![PyTorch 2.0+](https://img.shields.io/badge/PyTorch-2.0+-ee4c2c.svg)](https://pytorch.org/)
41
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
42
+ [![CI](https://img.shields.io/badge/CI-passing-brightgreen.svg)](https://github.com/erickfmm/frankenstein-transformer/actions)
43
+ [![PyPI](https://img.shields.io/pypi/v/frankenstein-transformer?color=blue&logo=pypi)](https://pypi.org/project/frankenstein-transformer/)
44
+ [![Docs](https://img.shields.io/badge/docs-readthedocs-blue.svg)](https://frankenstein-transformer.readthedocs.io/en/latest/)
45
+
46
+ **See [frankenstein-transformer](https://erickfmm.github.io/frankenstein-transformer/index.html) for a web interface to configure your YAML!**
47
+
48
+ ![web capture](docs/webcapture.gif)
49
+
50
+ ## At a Glance
51
+
52
+ A **schema-first, config-driven transformer experimentation toolkit**: pick mixers, optimizers, norms and positional encodings from one strict JSON-Schema-validated YAML — no code changes needed.
53
+
54
+ | Mixers | Optimizers | Pos. Encodings | Model Classes | Training Tasks | Presets | CLI Commands |
55
+ |:------:|:----------:|:--------------:|:-------------:|:--------------:|:-------:|:------------:|
56
+ | **42** | **23** | **11** | **3** | **6** | **122** | **4** |
57
+
58
+ ## How It Works
59
+
60
+ ```mermaid
61
+ flowchart LR
62
+ A["YAML Config"] --> B{"Schema Validation<br/>(JSON Schema + rules)"}
63
+ B -- valid --> C["Train<br/>23 optimizer families<br/>AMP · schedulers · thermal guard"]
64
+ B -- error --> A
65
+ C --> D["Checkpoint"]
66
+ D --> E["Deploy<br/>(quantize · export)"]
67
+ E --> F["Infer<br/>batch · interactive · benchmark"]
68
+ E --> G["Export<br/>HuggingFace · GGUF"]
69
+
70
+ style A fill:#e8f0fe,stroke:#4285f4,color:#1a1a1a
71
+ style B fill:#fff4d6,stroke:#f4b400,color:#1a1a1a
72
+ style C fill:#e6f4ea,stroke:#34a853,color:#1a1a1a
73
+ style D fill:#f1f3f4,stroke:#9aa0a6,color:#1a1a1a
74
+ style E fill:#fce8e6,stroke:#ea4335,color:#1a1a1a
75
+ style F fill:#e6f4ea,stroke:#34a853,color:#1a1a1a
76
+ style G fill:#e6f4ea,stroke:#34a853,color:#1a1a1a
77
+ ```
78
+
79
+ ## Model Classes & Tasks
80
+
81
+ ```mermaid
82
+ flowchart TB
83
+ subgraph CLASSES["Model Classes"]
84
+ direction LR
85
+ E["frankenstein<br/><i>encoder (mixed attention)</i>"]
86
+ D["frankensteindecoder<br/><i>causal decoder</i>"]
87
+ V["frankenstein_vit<br/><i>vision transformer</i>"]
88
+ end
89
+ subgraph TASKS["Training Tasks"]
90
+ direction LR
91
+ T1["mlm · sbert"]
92
+ T2["causal_lm"]
93
+ T3["patch_prediction · classification · segmentation"]
94
+ end
95
+ E --> T1
96
+ D --> T2
97
+ V --> T3
98
+
99
+ style E fill:#e8f0fe,stroke:#4285f4,color:#1a1a1a
100
+ style D fill:#e8f0fe,stroke:#4285f4,color:#1a1a1a
101
+ style V fill:#e8f0fe,stroke:#4285f4,color:#1a1a1a
102
+ style T1 fill:#e6f4ea,stroke:#34a853,color:#1a1a1a
103
+ style T2 fill:#e6f4ea,stroke:#34a853,color:#1a1a1a
104
+ style T3 fill:#e6f4ea,stroke:#34a853,color:#1a1a1a
105
+ ```
106
+
107
+ ## Quick Start
108
+
109
+ Python **>= 3.10** required.
110
+
111
+ | Method | Command |
112
+ |--------|---------|
113
+ | **uv** (recommended, CUDA 11.8) | `git clone https://github.com/erickfmm/frankenstein-transformer.git && cd frankenstein-transformer && uv sync --extra cu118 --extra train` |
114
+ | **uv** (CPU only) | `uv sync --extra cpu --extra train` |
115
+ | **pip** | `python -m venv .venv && source .venv/bin/activate && pip install -e ".[train]"` |
116
+ | **PyPI** | `pip install frankenstein-transformer` |
117
+
118
+ Run uv-installed commands through `uv run --extra cu118 --extra train <cmd>` (e.g. `uv run --extra cu118 --extra train frankenstein-transformer --help`). Other torch extras: `cu126` (driver ≥ 560), `cu128` (driver ≥ 570).
119
+
120
+ Verify: `frankenstein-transformer --help`
121
+
122
+ List available named presets: `frankenstein-transformer train --list-configs`
123
+
124
+ ## Feature Matrix
125
+
126
+ | Feature | Scale |
127
+ |---------|-------|
128
+ | Sequence mixer architectures | 42 across 8 categories (Dense, GQA, Recurrent, Sparse, Gated, Fast-Weight, Latent, Geometric) |
129
+ | Optimizer families | 23 across 6 categories |
130
+ | Positional encodings | 11 model-wide (`rope`, `hope`, `nope`, `alibi`, `bam`, `pape*`, `sinusoidal_*`, `learned_absolute`) with per-mixer opt-out |
131
+ | Model classes | `frankenstein`, `frankensteindecoder`, `frankenstein_vit` + reusable in-process engine API |
132
+ | Training tasks | `mlm`, `sbert`, `causal_lm`, `patch_prediction`, `classification`, `segmentation` |
133
+ | Normalization types | `layer_norm`, `dynamic_tanh`, `derf`, `rms_norm`, `prms_norm`, `flash_norm` |
134
+ | Config presets | 34 named presets + 88 example configs (schema smoke-tested in CI) |
135
+ | CLI subcommands | 4 (`train`, `deploy`, `infer`, `web-server`) |
136
+ | Web configuration UI | Streamlit schema-driven YAML builder |
137
+ | Quantized deployment | BitNet + checkpoint export pipeline (HF Transformers / GGUF) |
138
+ | SBERT workflows | Training + inference (similarity, search, cluster, encode) |
139
+ | DashAI integration | `dashai-frankenstein` plugin (MLM classifier, causal decoder, ViT classifier, ViT segmenter) |
140
+
141
+ ## Architecture Decision Table
142
+
143
+ | Model Class | Mode | Use Case |
144
+ |-------------|------|----------|
145
+ | `frankenstein` | Encoder | Full-featured MLM pre-training with mixed attention, MoE, and all 42 mixer types |
146
+ | `frankensteindecoder` | Decoder | Autoregressive causal decoder for LLM-style generation; forces `mode: decoder` |
147
+ | `frankenstein_vit` | Encoder (vision) | Vision Transformer (arXiv:2010.11929) for image understanding: patch prediction, classification, segmentation (arXiv:2503.19108); forces `mode: encoder`, requires `image:` + `dataset:` blocks |
148
+
149
+ See [configs/README.md](configs/README.md) for preset details and [docs/specs/](docs/specs/) for architecture deep-dives.
150
+
151
+ ## CLI Command Reference
152
+
153
+ | Subcommand | Purpose | Example |
154
+ |------------|---------|---------|
155
+ | `train` | Run schema-validated training | `frankenstein-transformer train --config-name frankenstein --device auto` |
156
+ | `deploy` | Export checkpoint to deployment artifacts (`quantized`/`standard`) or formats (`transformers`, `gguf`) | `frankenstein-transformer deploy --checkpoint ckpt.pt --output deployed/ --format quantized` |
157
+ | `infer` | Batch/interactive/benchmark inference (`--task mlm`) or SBERT similarity/search/cluster/encode (`--task sbert`) | `frankenstein-transformer infer --model deployed/ --text "hello" --device auto` |
158
+ | `web-server` | Launch Streamlit config builder UI | `frankenstein-transformer web-server` |
159
+
160
+ All model-executing commands accept `--device auto|cpu|cuda|mps`.
161
+
162
+ ## Mixer Categories
163
+
164
+ | Category | Code Names | Description |
165
+ |----------|------------|-------------|
166
+ | **Dense** (2) | `standard_attn`, `sigmoid_attn` | Full quadratic attention variants |
167
+ | **GQA** (1) | `gqa_attn` | Grouped-query attention with configurable KV heads |
168
+ | **Recurrent** (6) | `retnet`, `retnet_attn`, `mamba`, `ode`, `titan_attn`, `engram_attn` | Retention networks, state-space models, continuous-depth ODE layers, memory-augmented attention, and n-gram memory |
169
+ | **Sparse** (9) | `sparse_transformer_attn`, `longformer_attn`, `bigbird_attn`, `sparsek_attn`, `nsa_attn`, `sparge_attn` ⚠️, `fasa_attn` ⚠️, `msa_attn`, `sparda_attn` | Factorized, sliding-window, token-selection, and block-sparse (GQA-based) patterns |
170
+ | **Gated** (8) | `gla_attn`, `deltanet_attn`, `gated_deltanet_attn`, `gated_deltanet2_attn`, `hgrn2_attn`, `fox_attn`, `gated_softmax_attn`, `kda_attn` | Linear attention with multiplicative gates, delta rules, and gated softmax |
171
+ | **Fast-Weight** (6) | `falcon1_attn`, `falcon2_attn`, `falcon3_attn`, `falcon1a_attn`, `falcon2a_attn`, `falcon3a_attn` | Fast-weight / online-learning attention with per-layer fast-weight update rules |
172
+ | **Latent** (10) | `mla_attn`, `gqla_attn`, `mlra_attn`, `tucker_attn`, `iha_attn`, `gta_attn`, `mtla_attn`, `cca_attn`, `ccgqa_attn`, `gma_attn` | KV-compression and head-mixing variants generalising GQA (latent attention, Tucker factorisation, interleaved pseudo-heads, temporal merging, compressed convolutional attention, Gaussian mixture attention) |
173
+ | **Geometric** (1) | `ssog_attn` | Separable Sum of Gaussians — geometric field attention |
174
+
175
+ ⚠️ `sparge_attn` and `fasa_attn` are **eval-only** — training raises a runtime error.
176
+
177
+ Configure via `layer_pattern` in YAML. See [src/schema.yaml](src/schema.yaml) for the full mixer reference table and [docs/specs/attention-mixers.md](docs/specs/attention-mixers.md) for the taxonomy deep-dive.
178
+
179
+ ## Optimizer Categories
180
+
181
+ | Category | Optimizers | Count |
182
+ |----------|------------|-------|
183
+ | **Classical** | `sgd_momentum`, `adamw`, `radam`, `adan`, `adopt`, `ademamix`, `lamb` | 7 |
184
+ | **Variance Reduction** | `mars_adamw`, `cautious_adamw` | 2 |
185
+ | **Memory-Efficient** | `adafactor`, `galore_adamw`, `lion`, `apollo`, `apollo_mini`, `q_apollo` | 6 |
186
+ | **Schedule-Free** | `schedulefree_adamw`, `prodigy` | 2 |
187
+ | **Second-Order** | `sophia`, `shampoo`, `soap` | 3 |
188
+ | **Geometry-Oriented** | `muon`, `turbo_muon`, `anon` | 3 |
189
+
190
+ Parameters use prefixed keys: `<optimizer_class>-<group>_<param>` (e.g. `adamw-lr_embeddings`, `muon-ns_steps`). See [configs/README.md](configs/README.md) for the full parameter reference.
191
+
192
+ ## Engine API & DashAI Plugin
193
+
194
+ Beyond the CLI, a thin **in-process engine API** ([src/engine.py](src/engine.py)) exposes model construction, tokenizer setup, dataset wiring, and the training loop as plain Python functions — no argparse, no subprocesses:
195
+
196
+ ```python
197
+ from src.engine import build_model, train_from_config, save_checkpoint, load_checkpoint
198
+ ```
199
+
200
+ This engine powers the **`dashai-frankenstein` plugin**, which registers Frankenstein's model classes as [DashAI](https://github.com/DashAIOpen/DashAI) components (5 `dashai.plugins` entry points): `FrankensteinMLMModel` (text classification via MLM encoder), `FrankensteinDecoderModel` (generative), `FrankensteinViTClassifier`, and `FrankensteinViTSegmenter` (+ `SegmentationTask`). The package is published on [PyPI](https://pypi.org/project/frankenstein-transformer/); see [docs/dashai-plugin-audit.md](docs/dashai-plugin-audit.md) for the integration design.
201
+
202
+ ## Documentation Map
203
+
204
+ | Resource | Content |
205
+ |----------|---------|
206
+ | [configs/README.md](configs/README.md) | Schema walkthrough, preset details, optimizer parameter reference |
207
+ | [src/schema.yaml](src/schema.yaml) | Authoritative training config schema (source of truth) |
208
+ | [docs/README.md](docs/README.md) | CLI reference and workflow guide |
209
+ | [docs/paper/paper.pdf](docs/paper/paper.pdf) | Technical report (English) |
210
+ | [docs/paper-es/paper-es.pdf](docs/paper-es/paper-es.pdf) | Technical report (Spanish) |
211
+ | [docs/specs/](docs/specs/) | Architecture and feature specifications |
212
+ | [docs/specs/vision.md](docs/specs/vision.md) | Vision Transformer (frankenstein_vit) spec — patch prediction, classification, segmentation |
213
+ | [docs/specs/attention-mixers.md](docs/specs/attention-mixers.md) | Mixer taxonomy (42 variants / 8 categories) and selection guide |
214
+ | [docs/dashai-plugin-audit.md](docs/dashai-plugin-audit.md) | DashAI plugin integration design and status |
215
+ | [frankenstein-transformer.readthedocs.io](https://frankenstein-transformer.readthedocs.io/en/latest/) | Full hosted documentation (specs, API, papers, bibliography) |
216
+ | [docs/transformers_compatibility.md](docs/transformers_compatibility.md) | HuggingFace export compatibility guide |
217
+
218
+ ## Quick Training Example
219
+
220
+ Minimal YAML config (`my_config.yaml`) — only the 5 required model fields plus task; everything else uses FrankensteinModelConfig/TrainingConfig defaults:
221
+
222
+ ```yaml
223
+ model_class: frankenstein
224
+ model:
225
+ vocab_size: 30522
226
+ hidden_size: 256
227
+ num_layers: 4
228
+ num_heads: 8
229
+ layer_pattern: [standard_attn, standard_attn, standard_attn, standard_attn]
230
+ training:
231
+ task: mlm
232
+ batch_size: 8
233
+ max_length: 128
234
+ mlm_probability: 0.15
235
+ max_samples: 100000
236
+ dataset_batch_size: 10000
237
+ num_workers: 4
238
+ cache_dir: "./temp_data/cache"
239
+ optimizer:
240
+ optimizer_class: adamw
241
+ parameters:
242
+ adamw-lr_embeddings: 1e-4
243
+ adamw-lr_norms: 1e-4
244
+ adamw-lr_attention: 1e-4
245
+ adamw-lr_other: 1e-4
246
+ adamw-wd_embeddings: 0.01
247
+ adamw-wd_norms: 0.01
248
+ adamw-wd_attention: 0.01
249
+ adamw-wd_other: 0.01
250
+ adamw-betas_embeddings: [0.9, 0.95]
251
+ adamw-betas_norms: [0.9, 0.95]
252
+ adamw-betas_attention: [0.9, 0.95]
253
+ adamw-betas_other: [0.9, 0.95]
254
+ adamw-eps_embeddings: 1e-8
255
+ adamw-eps_norms: 1e-8
256
+ adamw-eps_attention: 1e-8
257
+ adamw-eps_other: 1e-8
258
+ scheduler_total_steps: 1000
259
+ ```
260
+
261
+ Unspecified model fields fall back to FrankensteinModelConfig defaults (`num_loops=2`, `dropout=0.1`, `norm_type=dynamic_tanh`, `use_moe=true`, `ffn_activation=silu`, etc.). Unspecified training fields fall back to TrainingConfig defaults (`scheduler_type=cosine`, `grad_clip_max_norm=5.0`, `gpu_temp_guard_enabled=true`, etc.). Override only what you need to change.
262
+
263
+ Run:
264
+
265
+ ```bash
266
+ frankenstein-transformer train --config my_config.yaml --device auto
267
+ ```
268
+
269
+ ## Vision Transformer (frankenstein_vit) Example
270
+
271
+ The `frankenstein_vit` model class (arXiv:2010.11929) splits images into patches, embeds them, and processes the sequence through the same HybridLayer stack as the text models. It supports three tasks: `patch_prediction` (autosupervised masked patch prediction), `classification` (image classification), and `segmentation` (per-pixel or EoMT query-based, arXiv:2503.19108).
272
+
273
+ Minimal classification YAML (`vit_config.yaml`):
274
+
275
+ ```yaml
276
+ model_class: frankenstein_vit
277
+ model:
278
+ dims:
279
+ hidden_size: 768
280
+ num_layers: 12
281
+ num_heads: 12
282
+ layer_pattern: [standard_attn]
283
+ mode: encoder
284
+ norm: {type: layer_norm}
285
+ use_moe: false
286
+ use_bitnet: false
287
+ ffn_activation: gelu
288
+ ffn_hidden_size: 3072
289
+ image:
290
+ image_size: {height: 224, width: 224}
291
+ patch_size: 16
292
+ in_channels: 3
293
+ pos_embedding_type: learned_1d
294
+ cls_token: true
295
+ pooling_mode: cls
296
+ num_classes: 10
297
+ dataset:
298
+ dataset_name: cifar10
299
+ rescale: {height: 224, width: 224}
300
+ training:
301
+ task: classification
302
+ batch_size: 512
303
+ num_epochs: 90
304
+ optimizer:
305
+ optimizer_class: adamw
306
+ parameters:
307
+ adamw-lr_other: 0.001
308
+ adamw-wd_other: 0.1
309
+ classification:
310
+ batch_size: 512
311
+ num_epochs: 90
312
+ learning_rate: 0.001
313
+ ```
314
+
315
+ Run: `frankenstein-transformer train --config vit_config.yaml --device auto`
316
+
317
+ See [configs/frankenstein_vit_base.yaml](configs/frankenstein_vit_base.yaml) for the full ViT-Base/16 preset and [docs/specs/vision.md](docs/specs/vision.md) for the complete specification.
318
+
319
+ ## License
320
+
321
+ MIT License — Copyright (c) 2026 Erick Merino. See [LICENSE](LICENSE) for full text.
@@ -0,0 +1,285 @@
1
+ # Frankenstein Transformer
2
+
3
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
4
+ [![PyTorch 2.0+](https://img.shields.io/badge/PyTorch-2.0+-ee4c2c.svg)](https://pytorch.org/)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
6
+ [![CI](https://img.shields.io/badge/CI-passing-brightgreen.svg)](https://github.com/erickfmm/frankenstein-transformer/actions)
7
+ [![PyPI](https://img.shields.io/pypi/v/frankenstein-transformer?color=blue&logo=pypi)](https://pypi.org/project/frankenstein-transformer/)
8
+ [![Docs](https://img.shields.io/badge/docs-readthedocs-blue.svg)](https://frankenstein-transformer.readthedocs.io/en/latest/)
9
+
10
+ **See [frankenstein-transformer](https://erickfmm.github.io/frankenstein-transformer/index.html) for a web interface to configure your YAML!**
11
+
12
+ ![web capture](docs/webcapture.gif)
13
+
14
+ ## At a Glance
15
+
16
+ A **schema-first, config-driven transformer experimentation toolkit**: pick mixers, optimizers, norms and positional encodings from one strict JSON-Schema-validated YAML — no code changes needed.
17
+
18
+ | Mixers | Optimizers | Pos. Encodings | Model Classes | Training Tasks | Presets | CLI Commands |
19
+ |:------:|:----------:|:--------------:|:-------------:|:--------------:|:-------:|:------------:|
20
+ | **42** | **23** | **11** | **3** | **6** | **122** | **4** |
21
+
22
+ ## How It Works
23
+
24
+ ```mermaid
25
+ flowchart LR
26
+ A["YAML Config"] --> B{"Schema Validation<br/>(JSON Schema + rules)"}
27
+ B -- valid --> C["Train<br/>23 optimizer families<br/>AMP · schedulers · thermal guard"]
28
+ B -- error --> A
29
+ C --> D["Checkpoint"]
30
+ D --> E["Deploy<br/>(quantize · export)"]
31
+ E --> F["Infer<br/>batch · interactive · benchmark"]
32
+ E --> G["Export<br/>HuggingFace · GGUF"]
33
+
34
+ style A fill:#e8f0fe,stroke:#4285f4,color:#1a1a1a
35
+ style B fill:#fff4d6,stroke:#f4b400,color:#1a1a1a
36
+ style C fill:#e6f4ea,stroke:#34a853,color:#1a1a1a
37
+ style D fill:#f1f3f4,stroke:#9aa0a6,color:#1a1a1a
38
+ style E fill:#fce8e6,stroke:#ea4335,color:#1a1a1a
39
+ style F fill:#e6f4ea,stroke:#34a853,color:#1a1a1a
40
+ style G fill:#e6f4ea,stroke:#34a853,color:#1a1a1a
41
+ ```
42
+
43
+ ## Model Classes & Tasks
44
+
45
+ ```mermaid
46
+ flowchart TB
47
+ subgraph CLASSES["Model Classes"]
48
+ direction LR
49
+ E["frankenstein<br/><i>encoder (mixed attention)</i>"]
50
+ D["frankensteindecoder<br/><i>causal decoder</i>"]
51
+ V["frankenstein_vit<br/><i>vision transformer</i>"]
52
+ end
53
+ subgraph TASKS["Training Tasks"]
54
+ direction LR
55
+ T1["mlm · sbert"]
56
+ T2["causal_lm"]
57
+ T3["patch_prediction · classification · segmentation"]
58
+ end
59
+ E --> T1
60
+ D --> T2
61
+ V --> T3
62
+
63
+ style E fill:#e8f0fe,stroke:#4285f4,color:#1a1a1a
64
+ style D fill:#e8f0fe,stroke:#4285f4,color:#1a1a1a
65
+ style V fill:#e8f0fe,stroke:#4285f4,color:#1a1a1a
66
+ style T1 fill:#e6f4ea,stroke:#34a853,color:#1a1a1a
67
+ style T2 fill:#e6f4ea,stroke:#34a853,color:#1a1a1a
68
+ style T3 fill:#e6f4ea,stroke:#34a853,color:#1a1a1a
69
+ ```
70
+
71
+ ## Quick Start
72
+
73
+ Python **>= 3.10** required.
74
+
75
+ | Method | Command |
76
+ |--------|---------|
77
+ | **uv** (recommended, CUDA 11.8) | `git clone https://github.com/erickfmm/frankenstein-transformer.git && cd frankenstein-transformer && uv sync --extra cu118 --extra train` |
78
+ | **uv** (CPU only) | `uv sync --extra cpu --extra train` |
79
+ | **pip** | `python -m venv .venv && source .venv/bin/activate && pip install -e ".[train]"` |
80
+ | **PyPI** | `pip install frankenstein-transformer` |
81
+
82
+ Run uv-installed commands through `uv run --extra cu118 --extra train <cmd>` (e.g. `uv run --extra cu118 --extra train frankenstein-transformer --help`). Other torch extras: `cu126` (driver ≥ 560), `cu128` (driver ≥ 570).
83
+
84
+ Verify: `frankenstein-transformer --help`
85
+
86
+ List available named presets: `frankenstein-transformer train --list-configs`
87
+
88
+ ## Feature Matrix
89
+
90
+ | Feature | Scale |
91
+ |---------|-------|
92
+ | Sequence mixer architectures | 42 across 8 categories (Dense, GQA, Recurrent, Sparse, Gated, Fast-Weight, Latent, Geometric) |
93
+ | Optimizer families | 23 across 6 categories |
94
+ | Positional encodings | 11 model-wide (`rope`, `hope`, `nope`, `alibi`, `bam`, `pape*`, `sinusoidal_*`, `learned_absolute`) with per-mixer opt-out |
95
+ | Model classes | `frankenstein`, `frankensteindecoder`, `frankenstein_vit` + reusable in-process engine API |
96
+ | Training tasks | `mlm`, `sbert`, `causal_lm`, `patch_prediction`, `classification`, `segmentation` |
97
+ | Normalization types | `layer_norm`, `dynamic_tanh`, `derf`, `rms_norm`, `prms_norm`, `flash_norm` |
98
+ | Config presets | 34 named presets + 88 example configs (schema smoke-tested in CI) |
99
+ | CLI subcommands | 4 (`train`, `deploy`, `infer`, `web-server`) |
100
+ | Web configuration UI | Streamlit schema-driven YAML builder |
101
+ | Quantized deployment | BitNet + checkpoint export pipeline (HF Transformers / GGUF) |
102
+ | SBERT workflows | Training + inference (similarity, search, cluster, encode) |
103
+ | DashAI integration | `dashai-frankenstein` plugin (MLM classifier, causal decoder, ViT classifier, ViT segmenter) |
104
+
105
+ ## Architecture Decision Table
106
+
107
+ | Model Class | Mode | Use Case |
108
+ |-------------|------|----------|
109
+ | `frankenstein` | Encoder | Full-featured MLM pre-training with mixed attention, MoE, and all 42 mixer types |
110
+ | `frankensteindecoder` | Decoder | Autoregressive causal decoder for LLM-style generation; forces `mode: decoder` |
111
+ | `frankenstein_vit` | Encoder (vision) | Vision Transformer (arXiv:2010.11929) for image understanding: patch prediction, classification, segmentation (arXiv:2503.19108); forces `mode: encoder`, requires `image:` + `dataset:` blocks |
112
+
113
+ See [configs/README.md](configs/README.md) for preset details and [docs/specs/](docs/specs/) for architecture deep-dives.
114
+
115
+ ## CLI Command Reference
116
+
117
+ | Subcommand | Purpose | Example |
118
+ |------------|---------|---------|
119
+ | `train` | Run schema-validated training | `frankenstein-transformer train --config-name frankenstein --device auto` |
120
+ | `deploy` | Export checkpoint to deployment artifacts (`quantized`/`standard`) or formats (`transformers`, `gguf`) | `frankenstein-transformer deploy --checkpoint ckpt.pt --output deployed/ --format quantized` |
121
+ | `infer` | Batch/interactive/benchmark inference (`--task mlm`) or SBERT similarity/search/cluster/encode (`--task sbert`) | `frankenstein-transformer infer --model deployed/ --text "hello" --device auto` |
122
+ | `web-server` | Launch Streamlit config builder UI | `frankenstein-transformer web-server` |
123
+
124
+ All model-executing commands accept `--device auto|cpu|cuda|mps`.
125
+
126
+ ## Mixer Categories
127
+
128
+ | Category | Code Names | Description |
129
+ |----------|------------|-------------|
130
+ | **Dense** (2) | `standard_attn`, `sigmoid_attn` | Full quadratic attention variants |
131
+ | **GQA** (1) | `gqa_attn` | Grouped-query attention with configurable KV heads |
132
+ | **Recurrent** (6) | `retnet`, `retnet_attn`, `mamba`, `ode`, `titan_attn`, `engram_attn` | Retention networks, state-space models, continuous-depth ODE layers, memory-augmented attention, and n-gram memory |
133
+ | **Sparse** (9) | `sparse_transformer_attn`, `longformer_attn`, `bigbird_attn`, `sparsek_attn`, `nsa_attn`, `sparge_attn` ⚠️, `fasa_attn` ⚠️, `msa_attn`, `sparda_attn` | Factorized, sliding-window, token-selection, and block-sparse (GQA-based) patterns |
134
+ | **Gated** (8) | `gla_attn`, `deltanet_attn`, `gated_deltanet_attn`, `gated_deltanet2_attn`, `hgrn2_attn`, `fox_attn`, `gated_softmax_attn`, `kda_attn` | Linear attention with multiplicative gates, delta rules, and gated softmax |
135
+ | **Fast-Weight** (6) | `falcon1_attn`, `falcon2_attn`, `falcon3_attn`, `falcon1a_attn`, `falcon2a_attn`, `falcon3a_attn` | Fast-weight / online-learning attention with per-layer fast-weight update rules |
136
+ | **Latent** (10) | `mla_attn`, `gqla_attn`, `mlra_attn`, `tucker_attn`, `iha_attn`, `gta_attn`, `mtla_attn`, `cca_attn`, `ccgqa_attn`, `gma_attn` | KV-compression and head-mixing variants generalising GQA (latent attention, Tucker factorisation, interleaved pseudo-heads, temporal merging, compressed convolutional attention, Gaussian mixture attention) |
137
+ | **Geometric** (1) | `ssog_attn` | Separable Sum of Gaussians — geometric field attention |
138
+
139
+ ⚠️ `sparge_attn` and `fasa_attn` are **eval-only** — training raises a runtime error.
140
+
141
+ Configure via `layer_pattern` in YAML. See [src/schema.yaml](src/schema.yaml) for the full mixer reference table and [docs/specs/attention-mixers.md](docs/specs/attention-mixers.md) for the taxonomy deep-dive.
142
+
143
+ ## Optimizer Categories
144
+
145
+ | Category | Optimizers | Count |
146
+ |----------|------------|-------|
147
+ | **Classical** | `sgd_momentum`, `adamw`, `radam`, `adan`, `adopt`, `ademamix`, `lamb` | 7 |
148
+ | **Variance Reduction** | `mars_adamw`, `cautious_adamw` | 2 |
149
+ | **Memory-Efficient** | `adafactor`, `galore_adamw`, `lion`, `apollo`, `apollo_mini`, `q_apollo` | 6 |
150
+ | **Schedule-Free** | `schedulefree_adamw`, `prodigy` | 2 |
151
+ | **Second-Order** | `sophia`, `shampoo`, `soap` | 3 |
152
+ | **Geometry-Oriented** | `muon`, `turbo_muon`, `anon` | 3 |
153
+
154
+ Parameters use prefixed keys: `<optimizer_class>-<group>_<param>` (e.g. `adamw-lr_embeddings`, `muon-ns_steps`). See [configs/README.md](configs/README.md) for the full parameter reference.
155
+
156
+ ## Engine API & DashAI Plugin
157
+
158
+ Beyond the CLI, a thin **in-process engine API** ([src/engine.py](src/engine.py)) exposes model construction, tokenizer setup, dataset wiring, and the training loop as plain Python functions — no argparse, no subprocesses:
159
+
160
+ ```python
161
+ from src.engine import build_model, train_from_config, save_checkpoint, load_checkpoint
162
+ ```
163
+
164
+ This engine powers the **`dashai-frankenstein` plugin**, which registers Frankenstein's model classes as [DashAI](https://github.com/DashAIOpen/DashAI) components (5 `dashai.plugins` entry points): `FrankensteinMLMModel` (text classification via MLM encoder), `FrankensteinDecoderModel` (generative), `FrankensteinViTClassifier`, and `FrankensteinViTSegmenter` (+ `SegmentationTask`). The package is published on [PyPI](https://pypi.org/project/frankenstein-transformer/); see [docs/dashai-plugin-audit.md](docs/dashai-plugin-audit.md) for the integration design.
165
+
166
+ ## Documentation Map
167
+
168
+ | Resource | Content |
169
+ |----------|---------|
170
+ | [configs/README.md](configs/README.md) | Schema walkthrough, preset details, optimizer parameter reference |
171
+ | [src/schema.yaml](src/schema.yaml) | Authoritative training config schema (source of truth) |
172
+ | [docs/README.md](docs/README.md) | CLI reference and workflow guide |
173
+ | [docs/paper/paper.pdf](docs/paper/paper.pdf) | Technical report (English) |
174
+ | [docs/paper-es/paper-es.pdf](docs/paper-es/paper-es.pdf) | Technical report (Spanish) |
175
+ | [docs/specs/](docs/specs/) | Architecture and feature specifications |
176
+ | [docs/specs/vision.md](docs/specs/vision.md) | Vision Transformer (frankenstein_vit) spec — patch prediction, classification, segmentation |
177
+ | [docs/specs/attention-mixers.md](docs/specs/attention-mixers.md) | Mixer taxonomy (42 variants / 8 categories) and selection guide |
178
+ | [docs/dashai-plugin-audit.md](docs/dashai-plugin-audit.md) | DashAI plugin integration design and status |
179
+ | [frankenstein-transformer.readthedocs.io](https://frankenstein-transformer.readthedocs.io/en/latest/) | Full hosted documentation (specs, API, papers, bibliography) |
180
+ | [docs/transformers_compatibility.md](docs/transformers_compatibility.md) | HuggingFace export compatibility guide |
181
+
182
+ ## Quick Training Example
183
+
184
+ Minimal YAML config (`my_config.yaml`) — only the 5 required model fields plus task; everything else uses FrankensteinModelConfig/TrainingConfig defaults:
185
+
186
+ ```yaml
187
+ model_class: frankenstein
188
+ model:
189
+ vocab_size: 30522
190
+ hidden_size: 256
191
+ num_layers: 4
192
+ num_heads: 8
193
+ layer_pattern: [standard_attn, standard_attn, standard_attn, standard_attn]
194
+ training:
195
+ task: mlm
196
+ batch_size: 8
197
+ max_length: 128
198
+ mlm_probability: 0.15
199
+ max_samples: 100000
200
+ dataset_batch_size: 10000
201
+ num_workers: 4
202
+ cache_dir: "./temp_data/cache"
203
+ optimizer:
204
+ optimizer_class: adamw
205
+ parameters:
206
+ adamw-lr_embeddings: 1e-4
207
+ adamw-lr_norms: 1e-4
208
+ adamw-lr_attention: 1e-4
209
+ adamw-lr_other: 1e-4
210
+ adamw-wd_embeddings: 0.01
211
+ adamw-wd_norms: 0.01
212
+ adamw-wd_attention: 0.01
213
+ adamw-wd_other: 0.01
214
+ adamw-betas_embeddings: [0.9, 0.95]
215
+ adamw-betas_norms: [0.9, 0.95]
216
+ adamw-betas_attention: [0.9, 0.95]
217
+ adamw-betas_other: [0.9, 0.95]
218
+ adamw-eps_embeddings: 1e-8
219
+ adamw-eps_norms: 1e-8
220
+ adamw-eps_attention: 1e-8
221
+ adamw-eps_other: 1e-8
222
+ scheduler_total_steps: 1000
223
+ ```
224
+
225
+ Unspecified model fields fall back to FrankensteinModelConfig defaults (`num_loops=2`, `dropout=0.1`, `norm_type=dynamic_tanh`, `use_moe=true`, `ffn_activation=silu`, etc.). Unspecified training fields fall back to TrainingConfig defaults (`scheduler_type=cosine`, `grad_clip_max_norm=5.0`, `gpu_temp_guard_enabled=true`, etc.). Override only what you need to change.
226
+
227
+ Run:
228
+
229
+ ```bash
230
+ frankenstein-transformer train --config my_config.yaml --device auto
231
+ ```
232
+
233
+ ## Vision Transformer (frankenstein_vit) Example
234
+
235
+ The `frankenstein_vit` model class (arXiv:2010.11929) splits images into patches, embeds them, and processes the sequence through the same HybridLayer stack as the text models. It supports three tasks: `patch_prediction` (autosupervised masked patch prediction), `classification` (image classification), and `segmentation` (per-pixel or EoMT query-based, arXiv:2503.19108).
236
+
237
+ Minimal classification YAML (`vit_config.yaml`):
238
+
239
+ ```yaml
240
+ model_class: frankenstein_vit
241
+ model:
242
+ dims:
243
+ hidden_size: 768
244
+ num_layers: 12
245
+ num_heads: 12
246
+ layer_pattern: [standard_attn]
247
+ mode: encoder
248
+ norm: {type: layer_norm}
249
+ use_moe: false
250
+ use_bitnet: false
251
+ ffn_activation: gelu
252
+ ffn_hidden_size: 3072
253
+ image:
254
+ image_size: {height: 224, width: 224}
255
+ patch_size: 16
256
+ in_channels: 3
257
+ pos_embedding_type: learned_1d
258
+ cls_token: true
259
+ pooling_mode: cls
260
+ num_classes: 10
261
+ dataset:
262
+ dataset_name: cifar10
263
+ rescale: {height: 224, width: 224}
264
+ training:
265
+ task: classification
266
+ batch_size: 512
267
+ num_epochs: 90
268
+ optimizer:
269
+ optimizer_class: adamw
270
+ parameters:
271
+ adamw-lr_other: 0.001
272
+ adamw-wd_other: 0.1
273
+ classification:
274
+ batch_size: 512
275
+ num_epochs: 90
276
+ learning_rate: 0.001
277
+ ```
278
+
279
+ Run: `frankenstein-transformer train --config vit_config.yaml --device auto`
280
+
281
+ See [configs/frankenstein_vit_base.yaml](configs/frankenstein_vit_base.yaml) for the full ViT-Base/16 preset and [docs/specs/vision.md](docs/specs/vision.md) for the complete specification.
282
+
283
+ ## License
284
+
285
+ MIT License — Copyright (c) 2026 Erick Merino. See [LICENSE](LICENSE) for full text.