PastelRuntime commited on
Commit
2e25538
·
verified ·
1 Parent(s): a5fb781

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +35 -42
README.md CHANGED
@@ -13,66 +13,59 @@ library_name: pytorch
13
 
14
  # KB-Diffusion Model B — word-level masked diffusion
15
 
16
- A 4.75M-parameter masked diffusion language model trained on 8,000 five-letter
17
- English words. This is the "generalization companion" experiment suggested in
18
- [KB-Diffusion](https://github.com/PastelRuntime/KB-Diffusion-Optimized) (an
19
- 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.
 
22
 
23
- It does, with a much harder hypothesis space. Trained in ~11 minutes on a free
24
- Kaggle T4.
25
 
26
- ## The recipe (identical in shape to the keyboard model)
27
-
28
- - Bidirectional transformer, no causal mask: vocab 27 (a-z + [MASK]), seq len 5,
29
- dim 256, 6 layers, 4 heads, ff 1024
30
- - LLaDA-style training: masking ratio t ~ U(0.05, 1), cross-entropy on masked
31
- positions only, weighted by 1/t
32
- - AdamW, lr 3e-4, 8000 steps, batch 1024
33
 
34
- ## Results
35
 
36
- 256 samples per sampler, checked against the full ~16k list of English
37
- 5-letter words:
38
 
39
- | Sampler | Valid English | Unique |
40
  |---|---|---|
41
- | One-shot parallel (all 5 letters at once) | 2.0% | 256/256 |
42
- | k=2 commits per step | 39.5% | 256/256 |
43
- | Ancestral (commit 1, re-condition, repeat) | 68.4% | 254/256 |
44
- | Greedy ancestral (no sampling) | 100% | 1/64 ("bales") |
45
 
46
- The model's from-scratch letter predictions also track exact analytic unigram
47
- statistics to mean total variation 0.0374 the "transformer learns Bayes'
48
- rule from corrupted examples" effect, at 8000 classes instead of 4.
49
 
50
- Two takeaways:
51
-
52
- 1. The sampler is half the model. Identical weights produce 2% or 68% valid
53
- output depending only on how commitments are made. Coherence is bought
54
- with iteration, not parameters.
55
- 2. 68.4% of outputs were valid English but only 66.4% came from the training
56
- list — it generalizes past its vocabulary, producing words it never saw.
57
 
58
  ## Usage
59
 
60
  ```python
61
  import torch
62
- from model_b_word_diffusion import Net, CH, MASK, N # from the GitHub repo
63
 
64
- model = Net()
65
- sd = torch.load("modelb_v2.pt", map_location="cpu", weights_only=True)
66
  model.load_state_dict(sd)
67
  model.eval()
68
- # then use the ancestral confidence-commit sampler from the repo's script
69
  ```
70
 
71
- See the GitHub repo for the full training/eval script and writeup.
72
-
73
  ## Intended use & limitations
74
 
75
- An educational experiment, not a production model. 27-token vocabulary,
76
- 5-position sequences, memorization-adjacent scale on purpose. It exists to
77
- make the masked-diffusion mechanism (parallel prediction, confidence
78
- commits, re-masking, posterior sharpening) measurable and visible.
 
 
13
 
14
  # KB-Diffusion Model B — word-level masked diffusion
15
 
16
+ Masked diffusion language models trained on 8,000 five-letter English
17
+ words. The "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 more than more parameters.
23
 
24
+ Two checkpoints, same LLaDA-style recipe (t ~ U(0.05, 1) masking, 1/t-weighted
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 finding
36
 
37
+ Identical v2 weights, different decoding:
 
38
 
39
+ | Decoding | Valid English | Cost (passes) |
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
+ A 27-point validity jump from temperature alone, at zero extra compute. The
46
+ sampler is half the modeltwice over.
 
47
 
48
+ Full methodology, negative results (revision sampling not worth it at N=5;
49
+ rare-prefix Bayes tracking degrades), prompting study, and per-sampler
50
+ tables: see `docs/model-b.md` in the GitHub repo.
 
 
 
 
51
 
52
  ## Usage
53
 
54
  ```python
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 script
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 show how much decoding strategy contributes to
71
+ generation quality on frozen weights.