-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathslides.html
More file actions
2016 lines (1767 loc) · 77 KB
/
slides.html
File metadata and controls
2016 lines (1767 loc) · 77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Generator Matching without Generators</title>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
<script>
window.MathJax = {
tex: {
inlineMath: [['$', '$'], ['\\(', '\\)']],
macros: {
R: "\\mathbb{R}",
E: "\\mathbb{E}",
Var: "\\mathrm{Var}",
Prob: "\\mathbb{P}"
}
}
};
</script>
<style>
:root {
/* Light theme tuned for white background */
--text-color: #222222;
--bg-color: #f5f6fa;
--slide-bg: #ffffff;
--primary-color: #0056b3;
--accent-color: #d63384;
--secondary-accent: #2e7d32;
--code-bg: #f1f3f5;
--border-color: #e0e0e0;
--nav-bg: rgba(255, 255, 255, 0.95);
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
html, body {
height: 100%;
overflow: hidden;
}
body {
font-family: "Crimson Pro", "Georgia", serif;
background: var(--bg-color);
color: var(--text-color);
}
/* Slideshow Container */
.slideshow-container {
position: relative;
width: 100%;
height: 100vh;
overflow: hidden;
}
.slide {
display: none;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
padding: 60px 80px 100px;
overflow-y: auto;
animation: fadeIn 0.4s ease-out;
}
.slide.active {
display: flex;
flex-direction: column;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateX(20px); }
to { opacity: 1; transform: translateX(0); }
}
/* Slide Content */
.slide-content {
max-width: 1100px;
margin: 0 auto;
width: 100%;
flex: 1;
}
h1 {
font-family: "Space Grotesk", -apple-system, BlinkMacSystemFont, sans-serif;
font-size: 3rem;
font-weight: 700;
background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
margin-bottom: 0.5rem;
text-align: center;
}
h2 {
font-family: "Space Grotesk", -apple-system, BlinkMacSystemFont, sans-serif;
font-size: 2.2rem;
font-weight: 600;
color: var(--primary-color);
margin-bottom: 1.5rem;
padding-bottom: 0.5rem;
border-bottom: 2px solid var(--border-color);
}
h3 {
font-family: "Space Grotesk", -apple-system, BlinkMacSystemFont, sans-serif;
font-size: 1.5rem;
font-weight: 500;
color: var(--secondary-accent);
margin: 1.5rem 0 1rem;
}
h4 {
font-family: "Space Grotesk", -apple-system, BlinkMacSystemFont, sans-serif;
font-size: 1.2rem;
color: var(--accent-color);
margin: 0 0 1rem;
}
.subtitle {
text-align: center;
color: #aaa;
font-size: 1.3rem;
font-style: italic;
margin-bottom: 1rem;
}
.author {
text-align: center;
color: var(--accent-color);
font-size: 1.2rem;
margin-bottom: 2rem;
}
/* Abstract/Callout Box */
.callout {
background: linear-gradient(135deg, rgba(0, 86, 179, 0.06) 0%, rgba(214, 51, 132, 0.06) 100%);
padding: 1.5rem 2rem;
border-radius: 12px;
border-left: 4px solid var(--primary-color);
margin: 1.5rem 0;
font-size: 1.1rem;
line-height: 1.7;
}
.callout strong {
color: var(--primary-color);
}
/* Lists */
ul, ol {
margin: 1rem 0 1rem 1.5rem;
font-size: 1.25rem;
line-height: 1.8;
}
li {
margin-bottom: 0.8rem;
}
li::marker {
color: var(--accent-color);
}
/* Key points */
.key-point {
background: rgba(129, 199, 132, 0.15);
border-left: 4px solid var(--secondary-accent);
padding: 1rem 1.5rem;
margin: 1.5rem 0;
border-radius: 0 8px 8px 0;
font-size: 1.15rem;
}
.key-point strong {
color: var(--secondary-accent);
}
/* Equations */
.equation {
text-align: center;
margin: 1.5rem 0;
font-size: 1.3rem;
padding: 1rem;
background: rgba(0, 0, 0, 0.03);
border-radius: 8px;
}
/* Blockquote for process steps */
blockquote {
background: rgba(79, 195, 247, 0.08);
border-left: 4px solid var(--accent-color);
padding: 1rem 1.5rem;
margin: 1.5rem 0;
border-radius: 0 8px 8px 0;
}
blockquote ol {
margin: 0.5rem 0 0.5rem 1.5rem;
}
/* Links */
a {
color: var(--primary-color);
text-decoration: none;
border-bottom: 1px dotted var(--primary-color);
transition: all 0.2s;
}
a:hover {
color: var(--accent-color);
border-bottom-color: var(--accent-color);
}
/* Interactive Figure Container */
.interactive-figure {
background: var(--slide-bg);
border: 1px solid var(--border-color);
border-radius: 12px;
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
padding: 1.5rem;
text-align: center;
margin: 1rem auto;
max-width: 850px;
}
canvas {
display: block;
margin: 10px auto;
background: #0a0a1a;
border: 1px solid var(--border-color);
border-radius: 8px;
cursor: crosshair;
max-width: 100%;
}
.controls {
margin-top: 15px;
font-family: "Space Grotesk", -apple-system, sans-serif;
font-size: 0.9rem;
display: flex;
justify-content: center;
align-items: center;
gap: 15px;
flex-wrap: wrap;
padding: 12px;
background: #f8f9fa;
border-radius: 8px;
}
button {
padding: 8px 16px;
background: linear-gradient(135deg, var(--primary-color) 0%, #29b6f6 100%);
color: #1a1a2e;
font-weight: 600;
border: none;
border-radius: 6px;
cursor: pointer;
transition: all 0.2s;
font-size: 0.9rem;
font-family: "Space Grotesk", -apple-system, sans-serif;
}
button:hover {
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(79, 195, 247, 0.4);
}
button.secondary {
background: linear-gradient(135deg, #546e7a 0%, #455a64 100%);
color: white;
}
button.active {
background: linear-gradient(135deg, var(--accent-color) 0%, #ec407a 100%);
}
input[type=range] {
vertical-align: middle;
accent-color: var(--primary-color);
}
input[type=number] {
width: 55px;
padding: 6px;
background: var(--code-bg);
border: 1px solid var(--border-color);
border-radius: 4px;
color: var(--text-color);
font-family: inherit;
}
label {
color: #bbb;
}
.caption {
font-size: 0.9rem;
color: #999;
margin-top: 1rem;
font-family: "Space Grotesk", -apple-system, sans-serif;
line-height: 1.5;
}
/* Navigation */
.nav-bar {
position: fixed;
bottom: 0;
left: 0;
right: 0;
background: var(--nav-bg);
backdrop-filter: blur(10px);
padding: 15px 30px;
display: flex;
justify-content: space-between;
align-items: center;
border-top: 1px solid var(--border-color);
z-index: 1000;
}
.nav-btn {
padding: 10px 24px;
font-size: 1rem;
min-width: 120px;
}
.nav-btn:disabled {
opacity: 0.4;
cursor: not-allowed;
transform: none !important;
box-shadow: none !important;
}
.slide-counter {
font-family: "Space Grotesk", monospace;
font-size: 1rem;
color: #888;
}
.slide-counter .current {
color: var(--primary-color);
font-weight: 600;
}
/* Progress bar */
.progress-bar {
position: fixed;
top: 0;
left: 0;
height: 3px;
background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
transition: width 0.3s ease;
z-index: 1001;
}
/* Image styling */
.slide img {
max-width: 100%;
border-radius: 8px;
margin: 1rem auto;
display: block;
}
/* Two column layout */
.two-col {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 2rem;
margin: 1rem 0;
}
/* SVG figures */
.svg-figure {
background: var(--slide-bg);
border: 1px solid var(--border-color);
border-radius: 12px;
padding: 1.5rem;
margin: 1rem 0;
}
.svg-figure img {
max-width: 100%;
margin: 0 auto;
}
.svg-figure .caption {
text-align: center;
margin-top: 1rem;
}
/* Title slide special - only style when active */
.slide.title-slide.active {
justify-content: center;
align-items: center;
text-align: center;
}
.title-slide h1 {
font-size: 4rem;
margin-bottom: 1rem;
}
/* Compact list for slides */
.compact-list {
font-size: 1.15rem;
}
.compact-list li {
margin-bottom: 0.5rem;
}
/* Keyboard hint */
.keyboard-hint {
position: fixed;
bottom: 80px;
right: 30px;
font-size: 0.8rem;
color: #666;
font-family: "Space Grotesk", monospace;
}
kbd {
background: var(--code-bg);
border: 1px solid var(--border-color);
border-radius: 4px;
padding: 2px 6px;
font-family: inherit;
}
</style>
<link href="https://fonts.googleapis.com/css2?family=Crimson+Pro:ital,wght@0,400;0,600;1,400&family=Space+Grotesk:wght@400;500;600;700&display=swap" rel="stylesheet">
</head>
<body>
<div class="progress-bar" id="progressBar"></div>
<div class="slideshow-container">
<!-- SLIDE 1: Title -->
<div class="slide title-slide active" data-slide="1">
<div class="slide-content">
<h1>Generator Matching<br>without Generators</h1>
<div class="subtitle">or "Generator Matching for Computer Scientists"</div>
<div class="author">Ben Murrell</div>
<div class="callout" style="max-width: 700px; margin: 2rem auto; text-align: left;">
<strong>Goal:</strong> Explain Generator Matching using only basic probability—no measure theory or advanced stochastic processes required.
</div>
</div>
</div>
<!-- SLIDE 2: What is GM? -->
<div class="slide" data-slide="2">
<div class="slide-content">
<h2>What is Generator Matching?</h2>
<ul>
<li><strong>Generator Matching (GM)</strong> is a framework that subsumes nearly all flow matching and diffusion models</li>
<li>Understanding GM lets you:
<ul>
<li>Construct <a href="https://arxiv.org/pdf/2511.09465">entirely novel methods</a></li>
<li>Understand existing approaches with greater clarity</li>
</ul>
</li>
<li>Traditional presentations use the formalism of <a href="https://en.wikipedia.org/wiki/Infinitesimal_generator_(stochastic_processes)">generators</a>—which can be unapproachable</li>
</ul>
<div class="key-point">
<strong>This presentation:</strong> A simple reframing using only concepts from basic probability. You'll understand why GM works and be able to construct your own methods.
</div>
</div>
</div>
<!-- SLIDE 3: The Setup -->
<div class="slide" data-slide="3">
<div class="slide-content">
<h2>1. The Setup</h2>
<ul>
<li><strong>Goal:</strong> Train a model to generate samples from a target distribution (images, text, proteins, etc.)</li>
<li><strong>Approach:</strong> Transform an easy-to-sample "prior" into the target through many small steps</li>
</ul>
<div style="text-align: center; margin: 1.5rem 0;">
<img width="750" alt="Flow from prior to target" src="https://github.com/user-attachments/assets/1d156b8b-68aa-47dd-a39d-5f0e4e2b4675" />
</div>
<ul>
<li><strong>Time $t$:</strong> Goes from $t=0$ (prior) to $t=1$ (target)</li>
<li><strong>State $x_t$:</strong> The model state at time $t$
<ul>
<li>$x_0$ = sample from prior (e.g., random noise)</li>
<li>$x_1$ = sample from target (e.g., real image)</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- SLIDE 4: Conditional Process -->
<div class="slide" data-slide="4">
<div class="slide-content">
<h2>The Conditional Process</h2>
<p style="font-size: 1.2rem; margin-bottom: 1.5rem;">GM requires that you can:</p>
<ol>
<li>Sample a latent $z$ from some distribution $p(z)$, which controls where the process ends at $t=1$</li>
<li>Conditioned on $z$, sample $x_{t+\Delta t}$ from $p(x_{t+\Delta t} \mid x_t, z, t)$ for small $\Delta t$</li>
</ol>
<h3>What is $z$?</h3>
<ul>
<li>Often just holds a single training sample $x_1^z$</li>
<li>But $z$ is flexible—can include other information controlling the path</li>
</ul>
<div class="key-point">
<strong>Key constraint:</strong> When stepping through time repeatedly, at $t=1$ the state reaches $x_1^z$—the training sample associated with $z$.
</div>
</div>
</div>
<!-- SLIDE 5: Marginals and Posterior -->
<div class="slide" data-slide="5">
<div class="slide-content">
<h2>2. Marginals and Posterior</h2>
<h3>The Marginal Distribution $p(x_t \mid t)$</h3>
<ul>
<li>Sample by: picking $z$, sampling $x_0$ from prior, stepping to time $t$</li>
<li>With $n$ training samples of equal probability:</li>
</ul>
<div class="equation">
$$p(x_t \mid t) = \frac{1}{n} \sum_{i=1}^n p(x_t \mid z_i, t)$$
</div>
<ul>
<li><strong>At $t=1$:</strong> This marginal equals the training data distribution</li>
</ul>
<h3>The Posterior $p(z \mid x_t, t)$</h3>
<ul>
<li>By Bayes: $p(z \mid x_t, t) \propto p(x_t \mid z, t)$</li>
<li>We won't compute it explicitly, but need to understand what it means</li>
</ul>
</div>
</div>
<!-- SLIDE 6: Concrete Example -->
<div class="slide" data-slide="6">
<div class="slide-content">
<h2>3. Concrete Example: Flow Matching</h2>
<ul>
<li><strong>State space:</strong> Continuous</li>
<li><strong>Prior $p(x_0)$:</strong> Gaussian distribution</li>
<li><strong>Conditional path:</strong> Straight line toward $x_1^z$</li>
</ul>
<div class="equation">
$$p(x_{t+\Delta t} \mid x_t, z, t) = \delta\left(x_t + \frac{(x_1^z - x_t)\Delta t}{1-t}\right)$$
</div>
<h3>Computing $p(z \mid x_t, t)$</h3>
<ul>
<li>No noise in process → uncertainty only from prior</li>
<li>Extrapolate backwards from $x_1^z$ through $x_t$ to find $x_0$:</li>
</ul>
<div class="equation">
$$ x_0 = x_t - t \cdot \frac{x_1^z - x_t}{1-t} $$
</div>
<ul>
<li>Weight by Gaussian prior probability of that $x_0$</li>
</ul>
</div>
</div>
<!-- SLIDE 7: Interactive Posterior Visualization -->
<div class="slide" data-slide="7">
<div class="slide-content">
<h2>Interactive: The Posterior $p(z \mid x_t, t)$</h2>
<div class="interactive-figure">
<h4>Move your cursor to control $t$ (horizontal) and $x_t$ (vertical)</h4>
<canvas id="posteriorCanvas" width="600" height="450"></canvas>
<div class="controls">
<div style="border-left:1px solid var(--border-color); padding-left:10px; margin-left:10px;">
<label>N: <input type="number" id="inputN" value="40" min="1" max="100"></label>
<button id="btnResampleData" class="secondary">Resample Points</button>
</div>
</div>
<div class="caption">
<span style="color:#81c784; font-weight:bold;">Green Dot</span> = current $(t, x_t)$ |
<span style="color:#4fc3f7; font-weight:bold;">Blue Lines</span> opacity = posterior $p(z|x_t,t)$
</div>
</div>
</div>
</div>
<!-- SLIDE 8: Resample-z Process Intro -->
<div class="slide" data-slide="8">
<div class="slide-content">
<h2>4. The Resample-$z$ Process</h2>
<p style="font-size: 1.2rem; margin-bottom: 1rem;">Consider a modified process that at each step:</p>
<blockquote>
<ol>
<li>Sample fresh $z_{\text{new}}$ from the posterior $p(z \mid x_t, t)$</li>
<li>Sample $x_{t+\Delta t}$ from $p(x_{t+\Delta t} \mid x_t, z_{\text{new}}, t)$</li>
</ol>
</blockquote>
<p style="font-size: 1.2rem; margin: 1.5rem 0;">At every step: forget old $z$, redraw from posterior, take step.</p>
<div class="key-point">
<strong>Critical insight:</strong> The marginal distribution $p(x_t \mid t)$ is the same for both the original conditional process and the resample-$z$ process!
</div>
<ul>
<li>Resampling rate doesn't matter—never, every step, or sporadically</li>
<li>All give the same marginals $p(x_t \mid t)$</li>
</ul>
</div>
</div>
<!-- SLIDE 9: Why Marginals Match -->
<div class="slide" data-slide="9">
<div class="slide-content">
<h2>Why Do Marginals Match?</h2>
<p style="font-size: 1.15rem; margin-bottom: 1rem;">Proof by induction: if marginals match at $t$, they match at $t+\Delta t$.</p>
<div class="two-col">
<div>
<h3>Procedure A (Conditional)</h3>
<ul class="compact-list">
<li>Draw $z$ from $p(z)$</li>
<li>Draw $x_t$ from $p(x_t \mid z, t)$</li>
<li>Joint: $p(x_t \mid z, t)p(z)$</li>
</ul>
</div>
<div>
<h3>Procedure B (Resample-$z$)</h3>
<ul class="compact-list">
<li>Draw $x_t$ from $p(x_t \mid t)$</li>
<li>Draw $z$ from $p(z \mid x_t, t)$</li>
<li>Joint: $p(z \mid x_t, t)p(x_t \mid t)$</li>
</ul>
</div>
</div>
<div class="equation">
$$p(z \mid x_t, t)p(x_t \mid t) = p(x_t \mid z, t)p(z) = p(x_t, z \mid t)$$
</div>
<ul>
<li>Same joint → same conditional step → same next marginal</li>
<li>Base case: both start from $p(x_0)$ ✓</li>
</ul>
</div>
</div>
<!-- SLIDE 10: Interactive Resampling -->
<div class="slide" data-slide="10">
<div class="slide-content">
<h2>Interactive: Resampling in Action</h2>
<div class="interactive-figure">
<h4>Watch paths change as resampling interval decreases</h4>
<canvas id="simCanvas" width="800" height="400"></canvas>
<div class="controls">
<button id="btnAutoPlay" class="secondary">▶</button>
<button id="btnToggleMode" class="active">Mode: Conditional Process</button>
</div>
<div class="controls" id="resampleControls" style="background: rgba(79, 195, 247, 0.1);">
<label>Resample Interval:
<input type="range" id="stepSizeSlider" min="1" max="100" value="20">
</label>
<span id="stepDisplay">0.020</span>
</div>
<div class="caption" id="simCaption">
<span style="color:var(--accent-color); font-weight:bold;">Red Path</span> → <span style="color:var(--primary-color); font-weight:bold">Blue Target</span> |
Click to set starting point
</div>
</div>
</div>
</div>
<!-- SLIDE 11: Infinite Switching Limit -->
<div class="slide" data-slide="11">
<div class="slide-content">
<h2>5. The Infinite Switching Limit</h2>
<ul>
<li><strong>Without resampling:</strong> Straight lines from $x_0$ to $x_1$</li>
<li><strong>With slow resampling:</strong> Jagged, zig-zagging paths</li>
<li><strong>With fast resampling:</strong> Law of large numbers kicks in!</li>
</ul>
<div class="key-point">
<strong>Key realization:</strong> As switching rate → ∞, the path converges to a <em>smooth posterior-weighted average</em> over all $z$ values.
</div>
<h3>The Posterior-Averaged Velocity</h3>
<div class="equation">
$$ \bar{u}_t(x) = \sum_{k=1}^N p(z_k\mid x,t)\,\frac{x_1^{z_k} - x}{1-t} $$
</div>
<ul>
<li>Instead of learning $p(z \mid x_t, t)$...</li>
<li><strong>Train a model to directly learn this average step!</strong></li>
</ul>
</div>
</div>
<!-- SLIDE 12: Interactive Averaged Velocity -->
<div class="slide" data-slide="12">
<div class="slide-content">
<h2>Interactive: Posterior-Averaged Velocity</h2>
<div class="interactive-figure">
<h4>The red arrow shows $\bar{u}_t(x)$ pointing to the weighted average $x_1$</h4>
<canvas id="posteriorCanvas3" width="600" height="450"></canvas>
<div class="controls">
<div style="border-left:1px solid var(--border-color); padding-left:10px; margin-left:10px;">
<label>N: <input type="number" id="inputN3" value="40" min="1" max="100"></label>
<button id="btnResampleData3" class="secondary">Resample Points</button>
</div>
</div>
<div class="caption">
<span style="color:#81c784; font-weight:bold;">Green Dot</span> = $(t, x_t)$ |
<span style="color:#4fc3f7; font-weight:bold;">Blue Lines</span> = posterior weights |
<span style="color:var(--accent-color); font-weight:bold;">Red Arrow</span> = averaged velocity to $t=1$
</div>
</div>
</div>
</div>
<!-- SLIDE 13: Training
<div class="slide" data-slide="13">
<div class="slide-content">
<h2>6. Training</h2>
<p style="font-size: 1.2rem; margin-bottom: 1rem;">We need a model $f_\theta(t, x)$ that outputs $\bar{u}_t(x_t)$. This is just <strong>regression!</strong></p>
<h3>Generating Training Data</h3>
<ol>
<li>Sample $z$ from $p(z)$ (pick a random training example)</li>
<li>Sample $x_0$ from prior $p(x_0)$</li>
<li>Run conditional process forward to get $x_t$</li>
<li>Compute conditional step $u_t(x_t \mid z)$.</li>
</ol>
<h3>Why MSE Gives the Posterior Average</h3>
<ul>
<li>Minimizing MSE gives the <em>conditional expectation</em></li>
<li>Optimal model: $f^*(t, x_t) = \E[u_t(x_t \mid z) \mid x_t, t] = \bar{u}_t(x_t)$</li>
</ul>
<div class="key-point">
<strong>We never compute $p(z \mid x_t, t)$ explicitly!</strong> The averaging happens automatically through regression.
</div>
</div>
</div>
-->
<!-- SLIDE 14: Training Algorithm -->
<div class="slide" data-slide="14">
<div class="slide-content">
<h2>6. Training</h2>
<p style="font-size: 1.2rem; margin-bottom: 1rem;">We need a model $f_\theta(t, x)$ that outputs $\bar{u}_t(x_t)$. This is just <strong>regression!</strong></p>
<h2>The Training Algorithm</h2>
<ol>
<li>Sample a batch of training examples $\{z_i\}$</li>
<li>For each $z_i$: sample $t_i \sim \text{Uniform}(0,1)$, generate $x_{t_i}$ from conditional process</li>
<li>Compute conditional step $u_{t_i}(x_{t_i} \mid z_i)$</li>
<li>Update $\theta$ to minimize $\sum_i D(u_{t_i}(x_{t_i} \mid z_i), f_\theta(t_i, x_{t_i}))$</li>
</ol>
<h3>Loss Functions</h3>
<ul>
<li><strong>MSE:</strong> Standard choice for continuous states</li>
<li><strong>Bregman divergences:</strong> Any Bregman divergence learns the right thing!</li>
</ul>
<div class="key-point">
<strong>We never compute $p(z \mid x_t, t)$ explicitly!</strong> The averaging happens automatically through regression.
</div>
<div class="callout">
<strong>Try it yourself:</strong> <a href="https://murrellgroup.github.io/GeneratorMatchingWithoutGenerators/spiral_flow.html">Train a flow matching model in the browser</a>
</div>
</div>
</div>
<!-- SLIDE 15: Different State Spaces -->
<div class="slide" data-slide="15">
<div class="slide-content">
<h2>7. Different State Spaces</h2>
<p style="font-size: 1.15rem; margin-bottom: 1rem;">The "smooth average" works for any stochastic process. What gets averaged depends on the step type:</p>
<div class="two-col">
<div>
<h3>Case I: Pure Drift (Flow)</h3>
<ul class="compact-list">
<li>$x_{t+\Delta t} = x_t + u_t(x_t\mid z)\Delta t$</li>
<li>Average the velocities directly</li>
</ul>
</div>
<div>
<h3>Case II: Drift + Diffusion</h3>
<ul class="compact-list">
<li>Add Gaussian noise term</li>
<li>Average drift and <em>variances</em></li>
<li>(Not standard deviations!)</li>
</ul>
</div>
</div>
<div class="two-col" style="margin-top: 1rem;">
<div>
<h3>Case III: Discrete States</h3>
<ul class="compact-list">
<li>Transition rates $q_t(j \mid i, z)$</li>
<li>Average the rates</li>
</ul>
</div>
<div>
<h3>Case IV: Jump Processes</h3>
<ul class="compact-list">
<li>Jump intensity + destination</li>
<li>Average gives <em>mixture</em> of destinations</li>
<li>Harder to parameterize!</li>
</ul>
</div>
</div>
</div>
</div>
<!-- SLIDE 16: Case I - Drift Only -->
<div class="slide" data-slide="16">
<div class="slide-content">
<h2>Case I: Deterministic Flow (Pure Drift)</h2>
<div class="svg-figure">
<img src="assets/ex1_flow.svg" alt="Drift-only flow matching case"/>
<div class="caption">
<strong>Top (blue):</strong> Four steps with $z$-resampling |
<strong>Bottom (red):</strong> Cumulative effect = sum of vectors
</div>
</div>
<div class="equation">
$$x_{t+\Delta t} = x_t + u_t(x_t\mid z)\,\Delta t$$
</div>
<div class="equation">
$$\bar{u}_t(x) = \sum_k p(z_k\mid x,t)\,u_t(x\mid z_k)$$
</div>
</div>
</div>
<!-- SLIDE 17: Case II - Drift + Diffusion -->
<div class="slide" data-slide="17">
<div class="slide-content">
<h2>Case II: Diffusion (Drift + Gaussian Noise)</h2>
<div class="svg-figure">
<img src="assets/ex2_driftdiffusion.svg" alt="Drift+Diffusion case"/>
<div class="caption">
<strong>Top:</strong> Each step has drift + Gaussian sample |
<strong>Bottom:</strong> Sum of drifts + Gaussian with summed variances
</div>
</div>
<div class="equation">
$$x_{t+\Delta t} = x_t + \mu_t(x_t\mid z)\Delta t + \sigma_t(x_t\mid z)\sqrt{\Delta t}\,\xi$$
</div>
<div class="equation">
$$\bar{\mu}_t(x) = \sum_k p(z_k\mid x,t)\,\mu_t(x\mid z_k), \quad \bar{\Sigma}_t(x) = \sum_k p(z_k\mid x,t)\,\Sigma_t(x\mid z_k)$$
</div>
</div>
</div>
<!-- SLIDE 18: Case III - Discrete -->
<div class="slide" data-slide="18">
<div class="slide-content">
<h2>Case III: Discrete States (CTMC)</h2>
<div class="svg-figure">
<img src="assets/ex3_CTMC.svg" alt="Discrete state case"/>
<div class="caption">
Displacements = switching probabilities |
Cumulative = sum of switching probabilities
</div>
</div>
<ul>
<li>For discrete states (text tokens), use transition <em>rates</em> $q_t(j\mid i, z)$</li>
</ul>
<div class="equation">
$$\Prob(x_{t+\Delta t} = j \mid x_t = i) \approx q_t(j\mid i, z)\,\Delta t \quad (j \neq i)$$
</div>
<div class="equation">
$$\bar{q}_t(j\mid i) = \sum_k p(z_k\mid x_t=i,t)\,q_t(j\mid i, z_k)$$
</div>
</div>
</div>
<!-- SLIDE 19: Case IV - Jumps -->
<div class="slide" data-slide="19">
<div class="slide-content">
<h2>Case IV: Jump Processes in Continuous Space</h2>
<div class="svg-figure">
<img src="assets/ex4_jumps.svg" alt="Jump process case"/>
<div class="caption">
Each step: jump to Gaussian destination |
Cumulative: <em>mixture</em> of Gaussians
</div>
</div>
<ul>
<li>Jump intensity $\lambda_t(x\mid z)$ + destination distribution $r_t(y\mid x,z)$</li>
</ul>
<div class="equation">
$$\bar{\lambda}_t(x) = \sum_k p(z_k\mid x,t)\,\lambda_t(x\mid z_k)$$
</div>
<div class="equation">
$$\bar{r}_t(y\mid x) = \frac{\sum_k p(z_k\mid x,t)\,\lambda_t(x\mid z_k)\, r_t(y\mid x, z_k)}{\bar{\lambda}_t(x)}$$
</div>
</div>
</div>
<!-- SLIDE 20: Closure -->
<div class="slide" data-slide="20">
<div class="slide-content">
<h2>Closure Property</h2>
<ul>
<li><strong>Cases I-III:</strong> Cumulative effect is same type as component steps ✓</li>
<li><strong>Case IV (Jumps):</strong> Cumulative is a <em>mixture</em>—harder to parameterize</li>
</ul>
<div class="key-point">
<strong>Practical solution:</strong> Choose jump distributions with trivial mixtures (e.g., uniform within grid cells → discrete distribution over cells).
</div>
<h3>What's Actually Used in Practice</h3>
<ul>
<li>Continuous + drift-only (deterministic flow matching)</li>
<li>Continuous + drift + <em>fixed</em> diffusion schedule (diffusion models)</li>
<li>Discrete state & process (discrete flow matching)</li>
<li>Multimodal combinations</li>
</ul>
</div>
</div>
<!-- SLIDE 21: Sampling -->
<div class="slide" data-slide="21">
<div class="slide-content">
<h2>8. Sampling from a Trained Model</h2>
<p style="font-size: 1.2rem; margin-bottom: 1.5rem;">Once trained, generating samples is straightforward:</p>
<ol>
<li>Sample $x_0$ from the prior $p(x_0)$</li>
<li>From $t=0$, repeatedly apply: $x_{t+\Delta t} = x_t + f_\theta(t, x_t)\,\Delta t$</li>
<li>Continue until $t=1$ → result $x_1$ is your sample</li>
</ol>
<div class="key-point">
<strong>No need to sample or track $z$!</strong> The posterior averaging is "baked into" the learned model.
</div>
<h3>Practical Notes</h3>
<ul>
<li>Core idea: follow learned averaged step from prior to target</li>
<li>Step size affects both quality and speed</li>
</ul>
</div>
</div>
<!-- SLIDE 22: Complete Recipe -->
<div class="slide" data-slide="22">
<div class="slide-content">
<h2>9. The Complete GM Recipe</h2>
<div class="two-col">
<div>
<h3>Design Phase</h3>
<ol class="compact-list">
<li><strong>Choose prior:</strong> Easy to sample (e.g., Gaussian, uniform tokens)</li>
<li><strong>Design conditional process:</strong> Steps that reach data at $t=1$</li>
</ol>
<h3>Training Phase</h3>
<ol class="compact-list">
<li>Sample training examples $z$</li>