sumitk commited on
Commit
c86974f
·
verified ·
1 Parent(s): 0d8b6af

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +88 -0
README.md ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Conveyor-Belt Diffusion LLM
3
+ emoji: 🥖
4
+ colorFrom: green
5
+ colorTo: purple
6
+ sdk: docker
7
+ app_port: 7860
8
+ license: mit
9
+ tags:
10
+ - diffusion-llm
11
+ - rolling-diffusion
12
+ - language-modeling
13
+ - tinystories
14
+ - pytorch
15
+ ---
16
+
17
+ # Conveyor-Belt Diffusion LLM (64-Slot Dual-Channel Elastic Planning Oven)
18
+
19
+ A **28.88M-parameter hybrid Autoregressive + Diffusion Language Model** where text generation works like a **64-slot bakery conveyor belt** (inspired by *Rolling Diffusion*, *FIFO-Diffusion*, *Diffusion Forcing*, and *AR-Diffusion*):
20
+
21
+ - **Input / Output Contract at every tick $t$:**
22
+ $$\text{Input: } \underbrace{[x_0, \dots, x_{t-1}]}_{\text{Frozen Causal KV Prefix}} + \underbrace{[d_0^{(t)}, d_1^{(t)}, \dots, d_{63}^{(t)}]}_{\text{64-Slot Conveyor \& Planning Belt}} \quad\longrightarrow\quad \text{Output: } \underbrace{x_t}_{\text{Popped Slot-0 Token}} + \underbrace{[d_0^{(t+1)}, \dots, d_{63}^{(t+1)}]}_{\text{Shifted \& Refined Belt}}$$
23
+
24
+ - **Live Demo & Pretrained Weights:**
25
+ - **Hugging Face Live Space:** [`https://huggingface.co/spaces/sumitk/diffusion-conveyer-llm`](https://huggingface.co/spaces/sumitk/diffusion-conveyer-llm)
26
+ - **Pretrained 24h Checkpoint (`best.pt`):** [`https://huggingface.co/sumitk/diffusion-conveyer-llm`](https://huggingface.co/sumitk/diffusion-conveyer-llm)
27
+
28
+ ---
29
+
30
+ ## Key Architectural Innovations
31
+
32
+ 1. **Dual-Channel "Soft-Vocab + Gated-Thought" Dough (`model.py`):**
33
+ - **Channel 1 (Lexical Anchor):** Expected vocabulary embedding $e_{\text{soft}, k} = p_k^\top E_{\text{vocab}}$ under a positional temperature schedule $\tau_k \in [0.5, 4.0]$ (soft and exploratory at the back of the belt, crisp at the front).
34
+ - **Channel 2 (Continuous Thought Highway):** Gated residual thought state $m_k \in \mathbb{R}^d$ initialized with forget-gate bias $+1.0$, fused via $\alpha_k = k / 63$ so **$\alpha_0 = 0$ exactly at Slot 0** (guaranteeing zero distribution mismatch when $x_t$ commits into the causal KV cache).
35
+ 2. **Two-Zone Human-Style Thinking & Speaking Belt:**
36
+ - **Front 25% Articulation Stream (`Slots 0..15`):** Shifts left by 1 slot every tick ($s_k = 1.0$), polishing immediate grammar toward `Slot 0`.
37
+ - **Mid-Belt Clause Expansion (`Slot 15`):** Synthesizes new intermediate phrase embeddings (`expand_head`) at the boundary between the paused planning zone and moving front conveyor.
38
+ - **Back 75% Elastic Planning Horizon (`Slots 16..63`):** Spans a $2\times$ wider lookahead horizon with a learned shift/pause gate $s_k \in (0, 1)$, holding sentence-level goals while clauses form in the middle.
39
+ 3. **Self-Healing Belt Recovery Training (`losses.py`):**
40
+ - Trained with 16-step unrolled BPTT, full-sequence causal LM supervision (`prefix_lm_weight=1.0`), front-belt shift-consistency KL, DAgger-style scheduled sampling, and mid-unroll belt corruption so the belt actively repairs noisy or contradictory plans.
41
+
42
+ ---
43
+
44
+ ## 24-Hour Training Results on 2,000,000 Real TinyStories
45
+
46
+ Trained for **24.00 hours (`122,743 steps`)** on a single RTX 5070 Ti GPU across **2,000,000 real TinyStories** (0% synthetic templates, 4,096 compact `tiktoken` BPE vocabulary with byte fallback for zero `<UNK>`):
47
+
48
+ | Metric | Value | Notes |
49
+ | :--- | :---: | :--- |
50
+ | **Held-Out Real Val Slot-0 Perplexity** | **`4.21`** | Down from `104.49` at step 500 (10,000 unseen real stories) |
51
+ | **Held-Out Real Val Slot-0 Top-1 Acc** | **`64.39%`** | Exact next-subword match at Conveyor Slot 0 |
52
+ | **Causal Prefix Trunk PPL / Top-1 Acc** | **`3.49` / `66.78%`** | Comparable to Microsoft Research's `TinyStories-28M/33M` (`CE 1.25`) |
53
+ | **Zero-Shot StoryCloze Commonsense** | **`100.0% (16/16)`** | 2-way physical, emotional & entity-tracking pairs (`+2.58 nats` margin) |
54
+ | **Word-Order Sensitivity KL** | **`3.674 nats`** | `KL(P(slot0 \| prompt) \|\| P(slot0 \| shuffled_prompt))` |
55
+ | **64-Slot Crystallization (Slot 63 $\to$ 0)** | **`8.19` $\to$ `0.48 nats`** | `17x` uncertainty reduction as thoughts travel from back to front |
56
+
57
+ ---
58
+
59
+ ## Quickstart
60
+
61
+ ### 1. Install
62
+ ```bash
63
+ pip install -e .
64
+ ```
65
+
66
+ ### 2. Launch the Interactive 64-Slot Conveyor Web Simulator
67
+ ```bash
68
+ PYTHONPATH=src python -m conveyer.web_sim --port 8766
69
+ ```
70
+ *(If `runs/tinystories/best.pt` is not present locally, it will automatically download the pretrained 28.88M checkpoint from `huggingface.co/sumitk/diffusion-conveyer-llm`.)*
71
+
72
+ ### 3. CLI Tick-by-Tick Generation & Belt Inspection
73
+ ```bash
74
+ PYTHONPATH=src python -m conveyer.infer \
75
+ --ckpt runs/tinystories/best.pt \
76
+ --prompt "Once upon a time, Lily and a little bunny walked into the green forest to find the golden key near the locked treasure chest. Suddenly a big lion" \
77
+ --tokens 80 --overlap 10
78
+ ```
79
+
80
+ ### 4. Run the Full Benchmark Suite
81
+ ```bash
82
+ PYTHONPATH=src python -m conveyer.eval --ckpt runs/tinystories/best.pt
83
+ ```
84
+
85
+ ### 5. Train / Resume 24-Hour Real TinyStories Run
86
+ ```bash
87
+ PYTHONPATH=src python -u -m conveyer.train --config configs/tinystories.yaml --resume auto
88
+ ```