Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -13,41 +13,48 @@ library_name: pytorch
|
|
| 13 |
|
| 14 |
# KB-Diffusion Model B β word-level masked diffusion
|
| 15 |
|
| 16 |
-
Masked diffusion language models trained on
|
| 17 |
-
|
| 18 |
[KB-Diffusion](https://github.com/PastelRuntime/KB-Diffusion-Optimized)
|
| 19 |
(an educational masked-diffusion project by Bijan Bowen / OminousIndustries):
|
| 20 |
swap the repo's four keyboard layouts for thousands of words and see if the
|
| 21 |
same recipe still works. It does β and iterating on decoding strategy turned
|
| 22 |
-
out to matter
|
|
|
|
| 23 |
|
| 24 |
-
|
| 25 |
CE, bidirectional transformer, no causal mask):
|
| 26 |
|
| 27 |
-
| | v2 | v3 |
|
| 28 |
-
|---|---|---|
|
| 29 |
-
| Params | 4.75M (6 layers) | 6.33M (8 layers) |
|
| 30 |
-
| Steps | 8,000 | 12,000 + cosine LR |
|
| 31 |
-
| Best valid English | 95.5% | **98.4%** |
|
| 32 |
-
| Unique words / 512 | 409 | **428** |
|
| 33 |
-
| Unigram TV vs exact Bayes | 0.0374 | **0.0135** |
|
| 34 |
|
| 35 |
-
## The headline
|
| 36 |
|
| 37 |
-
|
|
|
|
|
|
|
| 38 |
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
| Ancestral, temperature 1.0 | 68.8% | 5 |
|
| 42 |
-
| Ancestral, temperature 0.5 | **95.5%** | 5 |
|
| 43 |
-
| Revision-capable (re-mask weak commits) | 77.1% | 22.5 |
|
| 44 |
|
| 45 |
-
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
## Usage
|
| 53 |
|
|
@@ -55,17 +62,17 @@ tables: see `docs/model-b.md` in the GitHub repo.
|
|
| 55 |
import torch
|
| 56 |
from model_b_word_diffusion_v3 import Net, CH, MASK, N # from the GitHub repo
|
| 57 |
|
| 58 |
-
model = Net(layers=8) # v3
|
| 59 |
sd = torch.load("modelb_v3.pt", map_location="cpu", weights_only=True)
|
| 60 |
model.load_state_dict(sd)
|
| 61 |
model.eval()
|
| 62 |
-
# ancestral confidence-commit sampler, temperature 0.5 β see repo
|
| 63 |
```
|
| 64 |
|
| 65 |
## Intended use & limitations
|
| 66 |
|
| 67 |
-
Educational artifact, not a production model: 27-token vocab, 5-position
|
| 68 |
sequences. It exists to make the masked-diffusion mechanism (parallel
|
| 69 |
-
prediction, confidence commits, re-masking, posterior sharpening)
|
| 70 |
-
measurable β and to
|
| 71 |
-
|
|
|
|
| 13 |
|
| 14 |
# KB-Diffusion Model B β word-level masked diffusion
|
| 15 |
|
| 16 |
+
Masked diffusion language models trained on English words. The
|
| 17 |
+
"generalization companion" experiment from
|
| 18 |
[KB-Diffusion](https://github.com/PastelRuntime/KB-Diffusion-Optimized)
|
| 19 |
(an educational masked-diffusion project by Bijan Bowen / OminousIndustries):
|
| 20 |
swap the repo's four keyboard layouts for thousands of words and see if the
|
| 21 |
same recipe still works. It does β and iterating on decoding strategy turned
|
| 22 |
+
out to matter as much as architecture, with sequence length flipping which
|
| 23 |
+
sampler wins.
|
| 24 |
|
| 25 |
+
Three checkpoints, same LLaDA-style recipe (t ~ U(0.05, 1) masking, 1/t-weighted
|
| 26 |
CE, bidirectional transformer, no causal mask):
|
| 27 |
|
| 28 |
+
| | v2 (N=5) | v3 (N=5) | N=10 |
|
| 29 |
+
|---|---|---|---|
|
| 30 |
+
| Params | 4.75M (6 layers) | 6.33M (8 layers) | 6.34M (8 layers) |
|
| 31 |
+
| Steps | 8,000 | 12,000 + cosine LR | 12,000 + cosine LR |
|
| 32 |
+
| Best valid English | 95.5% (T=0.5) | **98.4%** (T=0.5) | 74.2% (revision + T=0.5) |
|
| 33 |
+
| Unique words / 512 | 409 | **428** | 200 |
|
| 34 |
+
| Unigram TV vs exact Bayes | 0.0374 | **0.0135** | 0.019 |
|
| 35 |
|
| 36 |
+
## The headline findings
|
| 37 |
|
| 38 |
+
**1. Temperature is the free win** (v2, frozen weights): ancestral sampling
|
| 39 |
+
at T=1.0 gives 68.8% valid English; T=0.5 gives 95.5%. Same weights, same
|
| 40 |
+
5 forward passes, +27 points.
|
| 41 |
|
| 42 |
+
**2. Decoding strategy > extra parameters**: v2 read well (95.5%) beats v3
|
| 43 |
+
read poorly (82.6% at T=1.0).
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
+
**3. Sequence length flips the sampler winner.** At N=5, revision-capable
|
| 46 |
+
sampling (un-commit weak letters, re-mask, retry) *loses* to plain
|
| 47 |
+
low-temperature sampling (77.1% vs 95.5%). At N=10 it *wins* (74.2% vs
|
| 48 |
+
63.3%) β early mistakes poison enough downstream positions that
|
| 49 |
+
un-committing them pays for its 4x compute. The "diffusion can revise"
|
| 50 |
+
capability has a measured regime where it wins.
|
| 51 |
|
| 52 |
+
**4. The parallel/iterative gap explodes with length**: one-shot sampling
|
| 53 |
+
falls 2.0% (N=5) β 0.0% of 512 samples (N=10). This is why real diffusion
|
| 54 |
+
LMs commit few tokens at a time.
|
| 55 |
+
|
| 56 |
+
Full methodology, negative results, and per-sampler tables: `docs/model-b.md`
|
| 57 |
+
in the GitHub repo.
|
| 58 |
|
| 59 |
## Usage
|
| 60 |
|
|
|
|
| 62 |
import torch
|
| 63 |
from model_b_word_diffusion_v3 import Net, CH, MASK, N # from the GitHub repo
|
| 64 |
|
| 65 |
+
model = Net(layers=8) # v3; use model_b_word_diffusion_n10.py for N=10
|
| 66 |
sd = torch.load("modelb_v3.pt", map_location="cpu", weights_only=True)
|
| 67 |
model.load_state_dict(sd)
|
| 68 |
model.eval()
|
| 69 |
+
# ancestral confidence-commit sampler, temperature 0.5 β see repo scripts
|
| 70 |
```
|
| 71 |
|
| 72 |
## Intended use & limitations
|
| 73 |
|
| 74 |
+
Educational artifact, not a production model: 27-token vocab, 5/10-position
|
| 75 |
sequences. It exists to make the masked-diffusion mechanism (parallel
|
| 76 |
+
prediction, confidence commits, re-masking, revision, posterior sharpening)
|
| 77 |
+
measurable β and to map how decoding strategy and sequence length interact
|
| 78 |
+
on frozen weights.
|