Sidharthan commited on
Commit
6585902
·
verified ·
1 Parent(s): ac841dc

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +11 -253
README.md CHANGED
@@ -13,12 +13,6 @@ pipeline_tag: text-to-audio
13
 
14
  # QaDiT — text-to-audio latent Diffusion Transformer
15
 
16
- > **Research / educational artifact.** This is **not** a state-of-the-art
17
- > text-to-audio host model. It is a from-scratch DiT trained on a modest budget
18
- > so the full stack is readable, reproducible, and improvable. Quality already
19
- > shows that the pipeline works; pushing further is mostly **more data and
20
- > longer training**, not a different architecture.
21
-
22
  A ~159M-parameter latent Diffusion Transformer that turns a text caption into
23
  **10.24 s of 16 kHz mono audio**: FLAN-T5 conditioning → DiT denoising of
24
  AudioLDM KL-VAE latents → VAE decode → HiFi-GAN vocoder.
@@ -27,25 +21,6 @@ Weights are the **EMA** copy from training step **23,999**.
27
 
28
  ---
29
 
30
- ## Architecture at a glance
31
-
32
- Drop a rendered overview PNG at [`assets/architecture.png`](assets/architecture.png)
33
- if you want a Hub thumbnail; the Mermaid diagrams below are the source of truth
34
- and render on GitHub / the Hub.
35
-
36
- ![Architecture diagram](assets/architecture.png)
37
-
38
- *Optional image — place your export at `assets/architecture.png`.*
39
-
40
- ```text
41
- caption
42
- → FLAN-T5-large [B, 64, 1024] token states
43
- → DiT-B denoiser v-pred on [B, 8, 256, 16] latents
44
- → ÷ latent_scale
45
- → AudioLDM KL-VAE decode → log-mel
46
- → HiFi-GAN vocoder → 16 kHz waveform
47
- ```
48
-
49
  | Piece | Choice |
50
  | --- | --- |
51
  | Backbone | DiT-B — depth 12, width 768, 12 heads, MLP ratio 4.0 (~159M) |
@@ -67,17 +42,8 @@ caption
67
 
68
  ## 1. Big picture — three pipelines
69
 
70
- ```mermaid
71
- flowchart LR
72
- A[/"AudioCaps<br/>~46K clips + captions"/] --> B["① Offline Pre-compute<br/>(run frozen models once,<br/>cache to disk)"]
73
- B --> C["② Training Loop<br/>(only the DiT trains)"]
74
- C --> D["③ Inference / Sampling<br/>(caption → waveform)"]
75
 
76
- style A fill:#fff3c4,stroke:#b8860b,color:#000
77
- style B fill:#dbeafe,stroke:#1e40af,color:#000
78
- style C fill:#dcfce7,stroke:#15803d,color:#000
79
- style D fill:#fde2e2,stroke:#b91c1c,color:#000
80
- ```
81
 
82
  ---
83
 
@@ -86,44 +52,7 @@ flowchart LR
86
  Heavy frozen models run **once**; the training loop never loads T5, the VAE,
87
  or the REPA encoder.
88
 
89
- ```mermaid
90
- flowchart TD
91
- subgraph INPUT["Per clip"]
92
- WAV[/"waveform<br/>10.24 s · 16 kHz · mono"/]
93
- CAP[/"caption (text)"/]
94
- end
95
-
96
- subgraph FRONT["Mel front-end (locked to VAE)"]
97
- MEL["STFT → log-mel<br/>n_fft 1024 · hop 160 · 64 mels<br/>→ mel 1×1024×64"]
98
- end
99
-
100
- subgraph FROZEN["Frozen pretrained encoders 🟦"]
101
- VAE["AudioLDM mel-VAE<br/>encoder (÷4, C=8)"]
102
- T5["FLAN-T5 encoder"]
103
- AST["AST<br/>(REPA target encoder)"]
104
- end
105
-
106
- subgraph CACHE["Cached to sharded records 🟨"]
107
- Z0[/"z₀ latent · 8×256×16<br/>(scaled by latent_scale → unit std)"/]
108
- CTX[/"text states c ∈ ℝ^{64×1024}<br/>+ attention mask"/]
109
- YSTAR[/"REPA target features y*"/]
110
- end
111
-
112
- WAV --> MEL
113
- MEL --> VAE --> Z0
114
- CAP --> T5 --> CTX
115
- MEL --> AST --> YSTAR
116
-
117
- style WAV fill:#fff3c4,stroke:#b8860b,color:#000
118
- style CAP fill:#fff3c4,stroke:#b8860b,color:#000
119
- style MEL fill:#e0e7ff,stroke:#4338ca,color:#000
120
- style VAE fill:#dbeafe,stroke:#1e40af,color:#000
121
- style T5 fill:#dbeafe,stroke:#1e40af,color:#000
122
- style AST fill:#dbeafe,stroke:#1e40af,color:#000
123
- style Z0 fill:#fff3c4,stroke:#b8860b,color:#000
124
- style CTX fill:#fff3c4,stroke:#b8860b,color:#000
125
- style YSTAR fill:#fff3c4,stroke:#b8860b,color:#000
126
- ```
127
 
128
  ---
129
 
@@ -131,191 +60,27 @@ flowchart TD
131
 
132
  Only the **DiT** and its small glue layers receive gradients.
133
 
134
- ```mermaid
135
- flowchart TD
136
- subgraph BATCH["Batch from cache 🟨"]
137
- Z0[/"z₀' scaled latent"/]
138
- C[/"T5 tokens c + mask"/]
139
- YS[/"REPA target y*"/]
140
- end
141
-
142
- subgraph NOISE["Forward diffusion"]
143
- TS["sample t ~ logit-normal"]
144
- EPS["sample ε ~ N(0, I)"]
145
- ZT["z_t = √ᾱ_t · z₀' + √(1−ᾱ_t) · ε"]
146
- end
147
-
148
- CFGDROP{"CFG dropout<br/>p = 0.1?"}
149
- NULL["learned null ∅ 🟩"]
150
-
151
- subgraph DIT["DiT — the ONLY trained network 🟩"]
152
- PATCH["patchify 2×2 + 2-D pos-emb<br/>→ 1024 tokens"]
153
- BLOCKS["12 × DiT blocks<br/>(self-attn → cross-attn → MLP,<br/>adaLN-Zero from t + pooled text)"]
154
- HL["hidden state h_ℓ<br/>(block ℓ = 4)"]
155
- HEAD["unpatchify head"]
156
- end
157
-
158
- PROJ["MLP projection g(·) 🟩"]
159
- PRED[/"prediction v̂"/]
160
-
161
- LDIFF{{"L_diff = ‖v − v̂‖²"}}
162
- LREPA{{"L_REPA = −cos(g(h_ℓ), y*)"}}
163
- LTOT{{"L = L_diff + λ·L_REPA<br/>(λ = 0.5, decayed)"}}
164
-
165
- OPT["AdamW + EMA(0.9999)<br/>→ DiT weights only"]
166
-
167
- Z0 --> ZT
168
- TS --> ZT
169
- EPS --> ZT
170
- ZT --> PATCH
171
- C --> CFGDROP
172
- CFGDROP -- "90% keep" --> BLOCKS
173
- CFGDROP -- "10% drop" --> NULL --> BLOCKS
174
- TS -- "adaLN-Zero" --> BLOCKS
175
- PATCH --> BLOCKS --> HEAD --> PRED
176
- BLOCKS -.-> HL --> PROJ
177
- PROJ --> LREPA
178
- YS --> LREPA
179
- PRED --> LDIFF
180
- LDIFF --> LTOT
181
- LREPA --> LTOT
182
- LTOT --> OPT
183
-
184
- style Z0 fill:#fff3c4,stroke:#b8860b,color:#000
185
- style C fill:#fff3c4,stroke:#b8860b,color:#000
186
- style YS fill:#fff3c4,stroke:#b8860b,color:#000
187
- style TS fill:#e0e7ff,stroke:#4338ca,color:#000
188
- style EPS fill:#e0e7ff,stroke:#4338ca,color:#000
189
- style ZT fill:#e0e7ff,stroke:#4338ca,color:#000
190
- style CFGDROP fill:#fef9c3,stroke:#a16207,color:#000
191
- style NULL fill:#dcfce7,stroke:#15803d,color:#000
192
- style PATCH fill:#dcfce7,stroke:#15803d,color:#000
193
- style BLOCKS fill:#dcfce7,stroke:#15803d,color:#000
194
- style HL fill:#dcfce7,stroke:#15803d,color:#000
195
- style HEAD fill:#dcfce7,stroke:#15803d,color:#000
196
- style PROJ fill:#dcfce7,stroke:#15803d,color:#000
197
- style PRED fill:#fff3c4,stroke:#b8860b,color:#000
198
- style LDIFF fill:#fde2e2,stroke:#b91c1c,color:#000
199
- style LREPA fill:#fde2e2,stroke:#b91c1c,color:#000
200
- style LTOT fill:#fde2e2,stroke:#b91c1c,color:#000
201
- style OPT fill:#dcfce7,stroke:#15803d,color:#000
202
- ```
203
 
204
  ---
205
 
206
  ## 4. Inside one DiT block
207
 
208
- ```mermaid
209
- flowchart TD
210
- TOKENS[/"latent tokens (queries)"/] --> LN1["LayerNorm ⊕ adaLN-Zero<br/>(scale, shift, gate from t-emb)"]
211
- LN1 --> SA["Self-Attention<br/>(latent ↔ latent)"]
212
- SA --> ADD1(("+"))
213
- TOKENS --> ADD1
214
-
215
- ADD1 --> LN2["LayerNorm"]
216
- LN2 --> CA["Cross-Attention<br/>Q = latent tokens<br/>K,V = T5 text tokens c<br/>(+ padding mask)"]
217
- TXT[/"T5 tokens c 🟨"/] --> CA
218
- CA --> ADD2(("+"))
219
- ADD1 --> ADD2
220
-
221
- ADD2 --> LN3["LayerNorm ⊕ adaLN-Zero"]
222
- LN3 --> MLP["Feed-Forward MLP"]
223
- MLP --> ADD3(("+"))
224
- ADD2 --> ADD3
225
- ADD3 --> OUT[/"tokens → next block"/]
226
-
227
- TEMB[/"t-embedding<br/>(sinusoidal → MLP,<br/>+ pooled text vector)"/] -. "scale · shift · gate" .-> LN1
228
- TEMB -. "scale · shift · gate" .-> LN3
229
-
230
- style TOKENS fill:#fff3c4,stroke:#b8860b,color:#000
231
- style TXT fill:#fff3c4,stroke:#b8860b,color:#000
232
- style TEMB fill:#fff3c4,stroke:#b8860b,color:#000
233
- style OUT fill:#fff3c4,stroke:#b8860b,color:#000
234
- style LN1 fill:#dcfce7,stroke:#15803d,color:#000
235
- style SA fill:#dcfce7,stroke:#15803d,color:#000
236
- style LN2 fill:#dcfce7,stroke:#15803d,color:#000
237
- style CA fill:#dcfce7,stroke:#15803d,color:#000
238
- style LN3 fill:#dcfce7,stroke:#15803d,color:#000
239
- style MLP fill:#dcfce7,stroke:#15803d,color:#000
240
- ```
241
 
242
  ---
243
 
244
  ## 5. Inference / sampling (caption → waveform)
245
 
246
- ```mermaid
247
- flowchart TD
248
- CAP[/"caption"/] --> T5["FLAN-T5 encoder 🟦"]
249
- T5 --> C[/"text tokens c"/]
250
- NULLC[/"null embedding ∅"/]
251
-
252
- ZT[/"z_T ~ N(0, I)<br/>8×256×16"/] --> LOOP
253
-
254
- subgraph LOOP["Reverse sampler · 50 DDIM steps (default)"]
255
- DIT["EMA DiT 🟩<br/>two passes: pred(c), pred(∅)"]
256
- CFG["CFG combine:<br/>v = v(∅) + w · (v(c) − v(∅))<br/>w = 4.0"]
257
- STEP["DDIM update z_t → z_{t−1}"]
258
- DIT --> CFG --> STEP
259
- STEP -- "next t" --> DIT
260
- end
261
-
262
- C --> DIT
263
- NULLC --> DIT
264
-
265
- LOOP --> ZH[/"ẑ₀' → un-scale (÷ latent_scale)"/]
266
- ZH --> DEC["VAE decoder 🟦"]
267
- DEC --> MELO[/"mel-spectrogram"/]
268
- MELO --> VOC["HiFi-GAN vocoder 🟦"]
269
- VOC --> OUT[/"waveform 🔊<br/>10.24 s · 16 kHz"/]
270
-
271
- style CAP fill:#fff3c4,stroke:#b8860b,color:#000
272
- style C fill:#fff3c4,stroke:#b8860b,color:#000
273
- style NULLC fill:#fff3c4,stroke:#b8860b,color:#000
274
- style ZT fill:#fff3c4,stroke:#b8860b,color:#000
275
- style T5 fill:#dbeafe,stroke:#1e40af,color:#000
276
- style DIT fill:#dcfce7,stroke:#15803d,color:#000
277
- style CFG fill:#e0e7ff,stroke:#4338ca,color:#000
278
- style STEP fill:#e0e7ff,stroke:#4338ca,color:#000
279
- style ZH fill:#fff3c4,stroke:#b8860b,color:#000
280
- style DEC fill:#dbeafe,stroke:#1e40af,color:#000
281
- style MELO fill:#fff3c4,stroke:#b8860b,color:#000
282
- style VOC fill:#dbeafe,stroke:#1e40af,color:#000
283
- style OUT fill:#fff3c4,stroke:#b8860b,color:#000
284
- ```
285
 
286
  ---
287
 
288
  ## 6. Component ownership
289
 
290
- ```mermaid
291
- flowchart LR
292
- subgraph FROZEN["🟦 Frozen (reused pretrained)"]
293
- direction TB
294
- F1["AudioLDM mel-VAE<br/>(encode + decode)"]
295
- F2["FLAN-T5 text encoder"]
296
- F3["AST<br/>(REPA target)"]
297
- F4["HiFi-GAN vocoder"]
298
- end
299
-
300
- subgraph TRAINED["🟩 Trained on AudioCaps"]
301
- direction TB
302
- T1["DiT-B/2 (~159M)"]
303
- T2["T5 → d_model projection"]
304
- T3["REPA projection head g(·)<br/>(dropped at inference)"]
305
- T4["learned null embedding ∅"]
306
- end
307
-
308
- FROZEN -- "latent space, text<br/>features, alignment<br/>targets, waveform decode" --> TRAINED
309
-
310
- style F1 fill:#dbeafe,stroke:#1e40af,color:#000
311
- style F2 fill:#dbeafe,stroke:#1e40af,color:#000
312
- style F3 fill:#dbeafe,stroke:#1e40af,color:#000
313
- style F4 fill:#dbeafe,stroke:#1e40af,color:#000
314
- style T1 fill:#dcfce7,stroke:#15803d,color:#000
315
- style T2 fill:#dcfce7,stroke:#15803d,color:#000
316
- style T3 fill:#dcfce7,stroke:#15803d,color:#000
317
- style T4 fill:#dcfce7,stroke:#15803d,color:#000
318
- ```
319
 
320
  ---
321
 
@@ -377,21 +142,14 @@ that is intentional so the slots are obvious.
377
 
378
  ### Diffusion / total loss
379
 
380
- ![Training loss](assets/loss_curve.png)
381
 
382
- *Drop your curve at `assets/loss_curve.png`.*
383
 
384
- ### REPA loss
385
-
386
- ![REPA loss](assets/repa_loss_curve.png)
387
 
388
- *Drop your curve at `assets/repa_loss_curve.png`.*
389
-
390
- ### Learning rate (optional)
391
 
392
- ![LR schedule](assets/lr_schedule.png)
393
 
394
- *Optional: `assets/lr_schedule.png`.*
395
 
396
  ---
397
 
 
13
 
14
  # QaDiT — text-to-audio latent Diffusion Transformer
15
 
 
 
 
 
 
 
16
  A ~159M-parameter latent Diffusion Transformer that turns a text caption into
17
  **10.24 s of 16 kHz mono audio**: FLAN-T5 conditioning → DiT denoising of
18
  AudioLDM KL-VAE latents → VAE decode → HiFi-GAN vocoder.
 
21
 
22
  ---
23
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  | Piece | Choice |
25
  | --- | --- |
26
  | Backbone | DiT-B — depth 12, width 768, 12 heads, MLP ratio 4.0 (~159M) |
 
42
 
43
  ## 1. Big picture — three pipelines
44
 
 
 
 
 
 
45
 
46
+ ![image](https://cdn-uploads.huggingface.co/production/uploads/64054e5e0ab5e22719fc179f/W4tXcMyotNTC01hEYTz6q.png)
 
 
 
 
47
 
48
  ---
49
 
 
52
  Heavy frozen models run **once**; the training loop never loads T5, the VAE,
53
  or the REPA encoder.
54
 
55
+ ![image](https://cdn-uploads.huggingface.co/production/uploads/64054e5e0ab5e22719fc179f/ok-iYdQGBXNXgnBzKtXdS.png)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
 
57
  ---
58
 
 
60
 
61
  Only the **DiT** and its small glue layers receive gradients.
62
 
63
+
64
+ ![image](https://cdn-uploads.huggingface.co/production/uploads/64054e5e0ab5e22719fc179f/vpUCimXElF6yv-M9UBI3Z.png)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
 
66
  ---
67
 
68
  ## 4. Inside one DiT block
69
 
70
+ ![image](https://cdn-uploads.huggingface.co/production/uploads/64054e5e0ab5e22719fc179f/mmTgnW0w7BAyCKLC7gHiA.png)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
 
72
  ---
73
 
74
  ## 5. Inference / sampling (caption → waveform)
75
 
76
+
77
+ ![image](https://cdn-uploads.huggingface.co/production/uploads/64054e5e0ab5e22719fc179f/-4i-SA1wIcQ589NKJOPAe.png)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
 
79
  ---
80
 
81
  ## 6. Component ownership
82
 
83
+ ![image](https://cdn-uploads.huggingface.co/production/uploads/64054e5e0ab5e22719fc179f/d7AJNoRcB47CztYuZt-jC.png)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
 
85
  ---
86
 
 
142
 
143
  ### Diffusion / total loss
144
 
 
145
 
146
+ ![image](https://cdn-uploads.huggingface.co/production/uploads/64054e5e0ab5e22719fc179f/JXuluU4tNmP6z5tuirIkb.png)
147
 
 
 
 
148
 
149
+ ### REPA loss
 
 
150
 
 
151
 
152
+ ![image](https://cdn-uploads.huggingface.co/production/uploads/64054e5e0ab5e22719fc179f/pGbo0f5lliOenjMsGmFP6.png)
153
 
154
  ---
155