muyo commited on
Commit
0d20f7b
·
verified ·
1 Parent(s): 259909a

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +24 -93
README.md CHANGED
@@ -8,22 +8,20 @@ tags:
8
  - uniform-diffusion
9
  ---
10
 
 
 
11
  # Sumi-7B
12
 
13
- Sumi is a **7B uniform (discrete) diffusion language model**. Unlike an autoregressive
14
- LM, it does not predict the next token left-to-right. Instead it runs **full
15
- bidirectional attention** over the whole sequence and is trained to *denoise*: given a
16
- sequence whose tokens have been randomly corrupted to uniformly-sampled vocabulary
17
- tokens, it predicts the clean tokens at every position at once. Generation starts from a
18
- canvas of random tokens appended to the prompt and **iteratively denoises** it.
19
 
20
- - Architecture: Llama-style transformer (RoPE, SwiGLU, RMSNorm, GQA) run **non-causally**, with an **off-by-one ("attention-sink") softmax**.
21
- - 36 layers, hidden 4096, 32 heads / 8 KV heads, vocab 100,278, context 4,864.
22
- - `model_type: "sumi"`, loaded via `trust_remote_code=True`.
23
 
24
- > **Requirements:** `transformers >= 5.8` and `torch >= 2.4` (any recent GPU). The model
25
- > ships its own modeling code; pass `trust_remote_code=True`. The tokenizer is bundled in
26
- > this repo.
27
 
28
  ## Quickstart
29
 
@@ -31,104 +29,37 @@ canvas of random tokens appended to the prompt and **iteratively denoises** it.
31
  import torch
32
  from transformers import AutoModelForMaskGeneration, AutoTokenizer
33
 
34
- model_id = "tohoku-nlp/sumi-7b" # <-- this repo
35
-
36
  tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
37
  model = AutoModelForMaskGeneration.from_pretrained(
38
  model_id, trust_remote_code=True, dtype=torch.bfloat16
39
  ).to("cuda").eval()
40
 
41
- prompt = "The capital of France is"
42
  inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
43
-
44
  out = model.generate(
45
  **inputs,
46
- max_new_tokens=64, # how many tokens to generate (denoised in place)
47
- num_denoising_steps=128, # refinement iterations — set higher for better quality
48
- temperature=0.7, # sampling temperature
 
49
  )
50
  print(tokenizer.decode(out.sequences[0], skip_special_tokens=True))
51
  ```
52
 
53
- `generate` returns a `SumiGenerationOutput` whose `.sequences` is `[batch, prompt_len +
54
- max_new_tokens]` (prompt followed by the generated completion). It is a drop-in custom
55
- generation loop — `AutoModelForMaskGeneration` also works and is the semantically exact
56
- auto-class.
57
-
58
- ## Generation parameters
59
-
60
- The diffusion generation loop replaces the usual autoregressive decoding knobs. The
61
- parameters you will normally set:
62
-
63
- | parameter | default | description |
64
- |---|---|---|
65
- | `max_new_tokens` | — (required) | Length of the completion. These tokens are initialised at random and denoised; the prompt stays fixed. |
66
- | `num_denoising_steps` | `128` | Number of denoising iterations. More steps → better quality at higher cost; quality saturates after a couple hundred. **This is the main quality/compute dial.** |
67
- | `sampler` | `"ancestral"` | `"ancestral"` — stochastic sampling from the analytic diffusion posterior (good general-purpose default). `"adaptive"` — confidence-based: each step commits only the most-confident position(s) and revises the rest, which gives sharper, more coherent outputs on structured tasks (e.g. code, math). |
68
- | `temperature` | `1.0` | Sampling temperature. **`0.7` is the recommended canonical setting.** Lower → more decisive denoising. |
69
- | `seed` / `generator` | `None` | Set a `seed` (int) or pass a `torch.Generator` for reproducible samples. |
70
-
71
- ```python
72
- # More coherent / "decisive" decoding, e.g. for code or math:
73
- out = model.generate(**inputs, max_new_tokens=256,
74
- num_denoising_steps=256, sampler="adaptive", temperature=0.7)
75
- ```
76
-
77
- ### Advanced knobs
78
-
79
- You rarely need these; defaults are fine for normal use.
80
-
81
- | parameter | default | description |
82
- |---|---|---|
83
- | `tokens_per_step` | `1` | `adaptive` sampler only: how many positions to commit per step. Keep at `1`. |
84
- | `schedule` | `"linear"` | `ancestral` only: log-SNR noise schedule, `"linear"` or `"cosine"`. |
85
- | `min_log_snr` / `max_log_snr` | `-9.0` / `9.0` | `ancestral` only: bounds of the SNR schedule. |
86
- | `frozen` | `None` | Pin `(position, token_id)` pairs at fixed canvas positions (kept fixed during denoising). Used for in-filling and for the `[EOS][BOS]` document-boundary **anchor** used in evaluation. |
87
- | `denoise_end` | `None` | Per-row exclusive upper bound; freezes the tail of the canvas so the step budget concentrates on the content window. |
88
-
89
- ## How it works
90
-
91
- 1. The prompt is placed at the front of a canvas of length `prompt_len + max_new_tokens`.
92
- 2. The completion region is filled with **uniformly random** vocabulary tokens (there is
93
- no `[MASK]` token — this is *uniform* diffusion).
94
- 3. For `num_denoising_steps`, the model does one bidirectional forward over the whole
95
- canvas and updates the completion region (the prompt is frozen). `ancestral` resamples
96
- every completion position from the analytic posterior each step; `adaptive` commits the
97
- highest-confidence position(s) and leaves the rest for later steps.
98
- 4. The final denoised canvas is returned.
99
-
100
- There is no KV cache (every step is a full bidirectional pass), so cost scales with
101
- `num_denoising_steps × sequence_length²`.
102
-
103
- ## Evaluation
104
-
105
- Sumi is scored with diffusion-native metrics: a Monte-Carlo estimate of the diffusion
106
- **NELBO** for multiple-choice / log-likelihood tasks, and iterative denoising for
107
- generative tasks. A companion [`lm-evaluation-harness`](https://github.com/EleutherAI/lm-evaluation-harness)
108
- plugin (`sumi-eval`, `--model sumi`) implements this end-to-end.
109
-
110
- Representative 0-shot results (the HF conversion reproduces the original training-stack
111
- model — ARC-Easy acc_norm agrees within sampling CI and the diffusion NELBO is a byte-exact
112
- port):
113
-
114
- | task | metric | score |
115
- |---|---|---|
116
- | ARC-Easy | acc_norm | ≈ 0.69 |
117
- | HumanEval | pass@1 | 0.226 |
118
 
119
- (HumanEval generated with `sampler="adaptive"`, `num_denoising_steps=256`,
120
- `max_new_tokens=256`; scored on the raw model output, with no answer-extraction.)
121
 
122
  ## Citation
123
 
124
  ```bibtex
125
- @misc{ye2025sumi,
126
- title={Sumi : Open Uniform Diffusion Language Model from Scratch},
127
- author={Mengyu Ye and Keito Kudo and Wataru Ikeda and Ryosuke Matsuda and Keisuke Sakaguchi and Jun Suziki},
128
  year={2026},
129
- eprint={2606.xxxxx},
130
  archivePrefix={arXiv},
131
- primaryClass={cs.LG},
132
- url={https://arxiv.org/abs/2606.xxxxx},
133
- }
134
  ```
 
8
  - uniform-diffusion
9
  ---
10
 
11
+
12
+
13
  # Sumi-7B
14
 
15
+ <p align="left">
16
+ <a href="https://www.nlp.ecei.tohoku.ac.jp/projects/sumi/"><img src="https://img.shields.io/badge/%F0%9F%8C%90%20Project%20HP-1f72b8" alt="Project Page"></a>
17
+ <a href="https://arxiv.org/abs/2606.19005"><img src="https://img.shields.io/badge/arXiv-2606.19005-b31b1b?logo=arxiv&logoColor=white" alt="arXiv"></a>
18
+ </p>
19
+ Sumi is a native uniform diffusion language model trained from scratch, so it runs full bidirectional attention and denoises a canvas of randomly corrupted tokens.
20
+ We provide Sumi in a custom model class, therefore you need to set `trust_remote_code=True` to use it in transformers.
21
 
22
+ We recommend `transformers==5.8.1`.
 
 
23
 
24
+ For more details, please refer to [our project page](https://www.nlp.ecei.tohoku.ac.jp/projects/sumi/) and [technical report](https://arxiv.org/abs/2606.19005).
 
 
25
 
26
  ## Quickstart
27
 
 
29
  import torch
30
  from transformers import AutoModelForMaskGeneration, AutoTokenizer
31
 
32
+ model_id = "tohoku-nlp/sumi-7b"
 
33
  tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
34
  model = AutoModelForMaskGeneration.from_pretrained(
35
  model_id, trust_remote_code=True, dtype=torch.bfloat16
36
  ).to("cuda").eval()
37
 
38
+ prompt = "Our journey into exploring diffusion language model begins,"
39
  inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
 
40
  out = model.generate(
41
  **inputs,
42
+ max_new_tokens=256, # content budget; the EOS/BOS delimiter is anchored here
43
+ num_denoising_steps=64, # refinement iterations — the main quality/compute dial
44
+ sampler="ancestral", # "ancestral" (default) or "adaptive" (sharper, for code/math)
45
+ temperature=0.7,
46
  )
47
  print(tokenizer.decode(out.sequences[0], skip_special_tokens=True))
48
  ```
49
 
50
+ `generate()` returns the trimmed completion in `out.sequences` and the full untrimmed canvas in `out.canvas`.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
 
 
 
52
 
53
  ## Citation
54
 
55
  ```bibtex
56
+ @misc{ye2026sumi,
57
+ title={Sumi: Open Uniform Diffusion Language Model from Scratch},
58
+ author={Mengyu Ye and Keito Kudo and Wataru Ikeda and Ryosuke Matsuda and Keisuke Sakaguchi and Jun Suzuki},
59
  year={2026},
60
+ eprint={2606.19005},
61
  archivePrefix={arXiv},
62
+ primaryClass={cs.CL},
63
+ url={https://arxiv.org/abs/2606.19005},
64
+ }
65
  ```