Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,73 @@
|
|
| 1 |
---
|
|
|
|
|
|
|
| 2 |
license: mit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
license: mit
|
| 5 |
+
tags:
|
| 6 |
+
- post-transformer
|
| 7 |
+
- attention-free
|
| 8 |
+
- hamiltonian
|
| 9 |
+
- symplectic
|
| 10 |
+
- o1-memory
|
| 11 |
+
- pytorch
|
| 12 |
+
- sub-quadratic
|
| 13 |
+
pipeline_tag: text-generation
|
| 14 |
---
|
| 15 |
+
|
| 16 |
+
# TUPOI-300M: Symplectic Post-Transformer Language Model with O(1) Memory
|
| 17 |
+
|
| 18 |
+
<div align="center">
|
| 19 |
+
|
| 20 |
+
*A sub-quadratic, attention-free sequence modeling architecture that replaces dense attention matrices with a Symplectic Hamiltonian Integrator (Velocity-Verlet).*
|
| 21 |
+
|
| 22 |
+
**Author:** NARE LABS (*Built by 15 y.o. independent researcher*)
|
| 23 |
+
|
| 24 |
+
[](https://github.com/starface77/TUPOI)
|
| 25 |
+
[](https://opensource.org/licenses/MIT)
|
| 26 |
+
|
| 27 |
+
</div>
|
| 28 |
+
|
| 29 |
+
---
|
| 30 |
+
|
| 31 |
+
## 📌 Overview
|
| 32 |
+
|
| 33 |
+
**TUPOI-300M** is a 304M-parameter proof-of-concept post-transformer architecture that completely eliminates the Attention mechanism and the persistent KV-cache in favor of continuous Hamiltonian phase-space dynamics.
|
| 34 |
+
|
| 35 |
+
### Key Highlights:
|
| 36 |
+
- **Strictly Constant Memory ($O(1)$):** The persistent recurrent context state requires exactly **6.00 KB of VRAM** forever, regardless of whether generating 512 or 65,536 tokens.
|
| 37 |
+
- **Zero Information Dissipation:** Integrated via the symplectic Velocity-Verlet leapfrog scheme with Jacobian determinant $\det(J) \equiv 1.000000$ (Liouville's theorem).
|
| 38 |
+
- **Pretrained Scale:** 304.2M active parameters trained across 10,000 steps on TinyStories on a single NVIDIA Tesla T4 GPU.
|
| 39 |
+
|
| 40 |
+
---
|
| 41 |
+
|
| 42 |
+
## 🚀 Quickstart: Running Inference in Python
|
| 43 |
+
|
| 44 |
+
```python
|
| 45 |
+
import torch
|
| 46 |
+
import torch.nn.functional as F
|
| 47 |
+
import tiktoken
|
| 48 |
+
from huggingface_hub import hf_hub_download
|
| 49 |
+
|
| 50 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 51 |
+
|
| 52 |
+
# 1. Download model weights from HuggingFace
|
| 53 |
+
weights_path = hf_hub_download(repo_id="DanilKZ/TUPOI-1", filename="tupoi-300m.pt")
|
| 54 |
+
|
| 55 |
+
# 2. Clone repository code for architecture definitions:
|
| 56 |
+
# git clone https://github.com/starface77/TUPOI.git
|
| 57 |
+
from tupoi import TUPOI300M, generate_text
|
| 58 |
+
|
| 59 |
+
enc = tiktoken.get_encoding("gpt2")
|
| 60 |
+
model = TUPOI300M(vocab_size=enc.n_vocab, d_model=1024, num_layers=24, d_ff=4096, max_seq_len=512).to(device)
|
| 61 |
+
|
| 62 |
+
checkpoint = torch.load(weights_path, map_location=device)
|
| 63 |
+
sd = checkpoint["model_state_dict"] if "model_state_dict" in checkpoint else checkpoint
|
| 64 |
+
if "opinion_anchor.anchor_state" in sd:
|
| 65 |
+
del sd["opinion_anchor.anchor_state"]
|
| 66 |
+
|
| 67 |
+
model.load_state_dict(sd, strict=False)
|
| 68 |
+
model.eval()
|
| 69 |
+
|
| 70 |
+
# 3. Generate text
|
| 71 |
+
prompt = "Once upon a time, there was a little girl named Lily who"
|
| 72 |
+
output = generate_text(model, enc, prompt=prompt, max_new_tokens=50, temperature=0.7)
|
| 73 |
+
print(output)
|