-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbrief_slides.html
More file actions
1631 lines (1432 loc) · 61.3 KB
/
Copy pathbrief_slides.html
File metadata and controls
1631 lines (1432 loc) · 61.3 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: 1rem;
margin: 0rem 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 3: The Setup -->
<div class="slide" data-slide="3">
<div class="slide-content">
<h2>Generator Matching: 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>
<p style="font-size: 1.2rem;">This means we can sample from $p(x_t \mid z, t)$ by first sampling $x_0$ from the prior, and then stepping through $p(x_{t+\Delta t} \mid x_t, z, t)$ for each step until $t$ is reached.</p>
<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>Marginals and Posterior</h2>
<h3>The Marginal Distribution $p(x_t \mid t)$</h3>
<ul>
<li>Sample $z$ from $p(z)$, then sample $p(x_t \mid z, t)$</li>
<li>With $n$ training samples of equal probability, one per $z$:</li>
</ul>
<p style="font-size: 1.2rem; margin: 1.5rem 0;">$$p(x_t \mid t) = \frac{1}{n} \sum_{i=1}^n p(x_t \mid z_i, t)$$</p>
<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) p(z)$</li>
<li>We won't compute it explicitly, but need to understand what it means</li>
</ul>
</div>
</div>
<!-- SLIDE 7: Interactive Posterior Visualization -->
<div class="slide" data-slide="7">
<div class="slide-content">
<h2>The Posterior $p(z \mid x_t, t)$</h2>
<div class="interactive-figure">
<h4>$t$ (horizontal); $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:#53df5a; font-weight:bold;">Green Dot</span> = current $(t, x_t)$ |
<span style="color:#a5a5a5; font-weight:bold;">White 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>The Resample-$z$ Process</h2>
<p style="font-size: 1.2rem; margin-bottom: 1rem;">The conditional process samples $x_t$ by first sampling $z$ from $p(z)$, then sampling $x_t$ from $p(x_t \mid z, t)$ by stepping from $x_0$.
Consider a modified process that every now and again:</p>
<blockquote>
<ol>
<li>Samples fresh $z_{\text{new}}$ from the posterior $p(z \mid x_t, t)$</li>
<li>Takes steps with $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 points along the sample trajectory you forget old $z$, redraw from posterior, and continue stepping.</p>
<div class="key-point">
<strong>Critically:</strong> The marginal distribution $p(x_t \mid t)$ is the same for both the original conditional process and the resample-$z$ process.
</div>
<p style="font-size: 1.2rem; margin: 1.5rem 0;">Why?
Under the conditional process, sampling $z$ then $x_t$ has the joint distribution:
$$p(x_t \mid z, t) p(z) = p(x_t, z \mid t)$$
If you discard $z$ you're in the marginal distribution $p(x_t \mid t)$, and if you resample $z$ from the posterior you get:
$$p(z \mid x_t, t) p(x_t \mid t) = p(x_t, z \mid t)$$
After resampling $z$ the joint distribution is unchanged, and the step is the same, so the distribution at $p(x_{t+\Delta t}, z \mid t+\Delta t)$ will agree as well.
So since they both start from $p(x_0)$ at $t=0$, the marginals $p(x_t \mid t)$ will match for all time steps.
</p>
</div>
</div>
<!-- SLIDE 10: Interactive Resampling -->
<div class="slide" data-slide="10">
<div class="slide-content">
<h2>The Resample-$z$ Process</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="100">
</label>
<span id="stepDisplay">1.0</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>The limit of the Resample-$z$ Process</h2>
<p style="font-size: 1.2rem; margin: 1.5rem 0;">With our pure-drift flow matching example:</p>
<ul>
<li><strong>Without resampling:</strong> Straight lines from $x_0$ to $x_1$ (i.e. the conditional process)</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>
<p style="font-size: 1.2rem; margin: 1.5rem 0;">As switching rate → ∞, the path converges to a <em>smooth posterior-weighted average</em> over all $z$ values.
$$ \bar{u}_t(x) = \sum_{k=1}^N p(z_k\mid x,t)\,u_t(x \mid z_k) $$
<strong>We can train a model to directly learn this average.</strong></p>
</div>
</div>
<!-- SLIDE 12: Interactive Averaged Velocity -->
<div class="slide" data-slide="12">
<div class="slide-content">
<h2>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:#e5eef2; font-weight:bold;">White 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 11: Infinite Switching Limit -->
<div class="slide" data-slide="11">
<div class="slide-content">
<h2>Generator Matching:</h2>
<ul>
<li>The marginal matching and switching-rate-limit arguments hold for other kinds of conditional process.</li>
<li>Use the conditional process to generate training samples.</li>
<li>Use a Bregman divergence to train a model $f_\theta(t, x)$ that directly learns the average step.</li>
<li>Generate new samples by stepping from $x_0$ using the learned model.</li>
</ul>
</div>
</div>
<!-- SLIDE 15: Different State Spaces -->
<div class="slide" data-slide="15">
<div class="slide-content">
<h2>Different State Spaces</h2>
<div class="two-col">
<div>
<h3>Case I: Pure Drift (Flow)</h3>
<img width="400" src="assets/ex1_flow.svg" alt="Drift-only flow matching case"/>
<ul class="compact-list">
<li>Average the velocities</li>
</ul>
</div>
<div>
<h3>Case II: Drift + Diffusion</h3>
<img width="400" src="assets/ex2_driftdiffusion.svg" alt="Drift+Diffusion case"/>
<ul class="compact-list">
<li>Average the drift and the variance</li>
</ul>
</div>
</div>
<div class="two-col" style="margin-top: 0rem;">
<div>
<h3>Case III: Discrete States</h3>
<img width="400" src="assets/ex3_CTMC.svg" alt="Discrete state case"/>
<ul class="compact-list">
<li>Average the rates</li>
</ul>
</div>
<div>
<h3>Case IV: Jump Processes</h3>
<img width="400" src="assets/ex4_jumps.svg" alt="Jump process case"/>
<ul class="compact-list">
<li>Average event intensities but <em>mixture</em> of destinations.</li>
<li>i.e. a Gaussian jump in the conditional process is a mixture of Gaussians (one per $z$) in the posterior averaged step.</li>
</ul>
</div>
</div>
</div>
</div>
<div class="slide" data-slide="8">
<div class="slide-content">
<h2>Auxiliary Generator Matching with a time-dependent latent process</h2>
<ul>
<li>Consider a conditional process over $x_t,g_t$ with steps $p(x_{t+\Delta t}, g_{t+\Delta t} \mid x_t, g_t, z, t)$</li>
<li>Conditional process as before, still terminating at $x_1^z$ when $t=1$ (with no required constraint on $g_1$). Note: this process is not necessarily Markov in $x$ alone.</li>
<li>Induces a marginal $p(x_t \mid t)$, and a posterior $p(g_t, z \mid x_t, t)$.</li>
</ul>
<ul>
<li>Consider a posterior resampling process but now where $z$ and $g_t$ are both sometimes resampled from $p(g_t, z \mid x_t, t)$ as the process steps forward. As before, and by the same argument, the marginal $p(x_t \mid t)$ is unchanged by the resampling.</li>
</ul>
<div class="key-point">
Taking the limit as the resampling rate goes to infinity yields a process that has the same marginal $p(x_t \mid t)$ as the original conditional process. But now, since $g_t$ and $z$ have been marginalized out, the process is Markov in $x$ alone, and a model can be trained to take $x_t, t$ and predict the posterior-averaged step on $x$.
</div>
<ul>
<li>The details of step averaging depends on how $x_t$ and $g_t$ are related.</li>
<li>For example, in Edit Flows, $x_t = \phi(g_t)$ and $g_t$ is a sequence containing some "null" tokens, and $\phi$ removes the null tokens. This means a substitution-to-null in $g_t$ is a deletion in $x_t$, and a substitution from null to a non-null token in $g_t$ is an insertion in $x_t$. So the model takes in a sequence without null tokens, but predicts rates that include insertion and deletion operations. <!--The rates learned are the posterior-averaged rates over all $g_t$ such that $\phi(g_t) = x_t$.-->
</li>
</ul>
</div>
</div>
</div>
<!-- Navigation Bar -->
<nav class="nav-bar">
<button class="nav-btn secondary" id="prevBtn" onclick="changeSlide(-1)">← Previous</button>
<div class="slide-counter">
<span class="current" id="currentSlide">1</span> / <span id="totalSlides">25</span>
</div>
<button class="nav-btn" id="nextBtn" onclick="changeSlide(1)">Next →</button>
</nav>
<div class="keyboard-hint">
<kbd>←</kbd> <kbd>→</kbd> or <kbd>Space</kbd> to navigate
</div>
<!-- LOGIC -->
<script>
// =========================================
// SLIDESHOW NAVIGATION
// =========================================
let currentSlideIndex = 0;
const slides = document.querySelectorAll('.slide');
const totalSlides = slides.length;
const progressBar = document.getElementById('progressBar');
const currentSlideEl = document.getElementById('currentSlide');
const totalSlidesEl = document.getElementById('totalSlides');
const prevBtn = document.getElementById('prevBtn');
const nextBtn = document.getElementById('nextBtn');
totalSlidesEl.textContent = totalSlides;
function showSlide(n) {
slides.forEach(s => s.classList.remove('active'));
currentSlideIndex = ((n % totalSlides) + totalSlides) % totalSlides;
slides[currentSlideIndex].classList.add('active');
// Update UI
currentSlideEl.textContent = currentSlideIndex + 1;
progressBar.style.width = ((currentSlideIndex + 1) / totalSlides * 100) + '%';
// Update button states
prevBtn.disabled = currentSlideIndex === 0;
nextBtn.disabled = currentSlideIndex === totalSlides - 1;
// Re-render MathJax for the current slide
if (window.MathJax && window.MathJax.typeset) {
MathJax.typeset();
}
}
function changeSlide(dir) {
showSlide(currentSlideIndex + dir);
}
// Keyboard navigation
document.addEventListener('keydown', (e) => {
if (e.key === 'ArrowRight' || e.key === ' ') {
e.preventDefault();
changeSlide(1);
} else if (e.key === 'ArrowLeft') {
e.preventDefault();
changeSlide(-1);
} else if (e.key === 'Home') {
e.preventDefault();
showSlide(0);
} else if (e.key === 'End') {
e.preventDefault();
showSlide(totalSlides - 1);
}
});
// Initialize
showSlide(0);
</script>
<script>
// =========================================
// UTILS & MATH
// =========================================
// Prior Distribution Parameters (Centered on Canvas)
const PRIOR_CENTER_1 = { x: 300, y: 225 }; // Center of canvas approx
const PRIOR_SIGMA_1 = 80;
const PRIOR_CENTER_2 = { x: 120, y: 200 }; // Center of canvas approx
const PRIOR_SIGMA_2 = 40;
function distSq(p1, p2) {
return (p1.x - p2.x)**2 + (p1.y - p2.y)**2;
}
// Gaussian PDF unnormalized
function gaussianPdf(x, y, center, sigma) {
const d2 = (x - center.x)**2 + (y - center.y)**2;
return Math.exp(-d2 / (2 * sigma * sigma));
}
// We ignore the constant factor -log(sqrt(2pi)*sigma) because it cancels out
function gaussianLogPdf(x, y, center, sigma) {
const dx = x - center.x;
const dy = y - center.y;
// log(exp(-d^2 / 2s^2)) = -d^2 / 2s^2
return -(dx*dx + dy*dy) / (2 * sigma * sigma);
}
// Replacement 2: Robust Posterior Weights using Log-Sum-Exp
function getPosteriorWeights(x, targets, t, center, sigma) {
// We can get extremely close to 1.0 now without NaN
const t_safe = Math.min(t, 0.9999);
const one_minus_t = 1 - t_safe;
let logWeights = [];
let maxLogW = -Infinity;
// 1. Compute Log Weights (Project back to t=0)
for (let z of targets) {
const x0_x = (x.x - t_safe * z.x) / one_minus_t;
const x0_y = (x.y - t_safe * z.y) / one_minus_t;
const lw = gaussianLogPdf(x0_x, x0_y, center, sigma);
logWeights.push(lw);
// Track max for stability
if (lw > maxLogW) maxLogW = lw;
}
// 2. Log-Sum-Exp Trick
// We subtract maxLogW from exponents to prevent underflow to 0
// at least one term will be exp(0) = 1
let sumExp = 0;
let expWeights = [];
for (let lw of logWeights) {
const w = Math.exp(lw - maxLogW);
expWeights.push(w);
sumExp += w;
}
// 3. Normalize
return expWeights.map(w => w / sumExp);
}
// =========================================
// New 1D posterior helpers (for Viz 1 & Viz 3 only)
// Keep Viz 2's 2D helpers unchanged
// =========================================
function gaussianLogPdf1D(y, mean, sigma) {
const dy = y - mean;
return -(dy * dy) / (2 * sigma * sigma);
}
// y: current state (pixel y), targetsY: array of data states (pixel y)
// t in [0,1), prior specified by (meanY, sigmaY)
function getPosteriorWeights1D(y, targetsY, t, meanY, sigmaY) {
const t_safe = Math.min(Math.max(t, 0), 0.9999);
const one_minus_t = 1 - t_safe;
let logWeights = [];
let maxLogW = -Infinity;
for (let zy of targetsY) {
const y0 = (y - t_safe * zy) / one_minus_t;
const lw = gaussianLogPdf1D(y0, meanY, sigmaY);
logWeights.push(lw);
if (lw > maxLogW) maxLogW = lw;
}
let sumExp = 0;
const expW = [];
for (let lw of logWeights) {
const w = Math.exp(lw - maxLogW);
expW.push(w);
sumExp += w;
}
return expW.map(w => w / sumExp);
}
// Draw a vertical Gaussian "hump" along the left edge (x from 0 toward right),
// hinting that mass "comes from the left" of the y-axis.
function drawVerticalGaussianHump(ctx, height, meanY, sigmaY, maxWidth, color) {
ctx.save();
ctx.fillStyle = color;
ctx.globalAlpha = 0.15;
ctx.beginPath();
ctx.moveTo(0, 0);
for (let y = 0; y <= height; y += 2) {
const pdf = Math.exp(-((y - meanY) * (y - meanY)) / (2 * sigmaY * sigmaY));
const x = Math.min(maxWidth, maxWidth * pdf);
ctx.lineTo(x, y);
}
ctx.lineTo(0, height);
ctx.closePath();
ctx.fill();
ctx.restore();
}
function drawArrow(ctx, fromX, fromY, toX, toY, color) {
const headlen = 10;
const dx = toX - fromX;
const dy = toY - fromY;
const angle = Math.atan2(dy, dx);
ctx.strokeStyle = color;
ctx.fillStyle = color;
ctx.lineWidth = 3;
ctx.beginPath();
ctx.moveTo(fromX, fromY);
ctx.lineTo(toX, toY);
ctx.stroke();
ctx.beginPath();
ctx.moveTo(toX, toY);
ctx.lineTo(toX - headlen * Math.cos(angle - Math.PI / 6), toY - headlen * Math.sin(angle - Math.PI / 6));
ctx.lineTo(toX - headlen * Math.cos(angle + Math.PI / 6), toY - headlen * Math.sin(angle + Math.PI / 6));
ctx.fill();
}
// Styled thin arrow (for faint hero arrow in Viz 2)
function drawArrowStyled(ctx, fromX, fromY, toX, toY, color, lineWidth, alpha) {
const headlen = 8;
const dx = toX - fromX;
const dy = toY - fromY;
const angle = Math.atan2(dy, dx);
ctx.save();
ctx.globalAlpha = alpha;
ctx.strokeStyle = color;
ctx.fillStyle = color;
ctx.lineWidth = lineWidth;
ctx.beginPath();
ctx.moveTo(fromX, fromY);
ctx.lineTo(toX, toY);
ctx.stroke();
ctx.beginPath();
ctx.moveTo(toX, toY);
ctx.lineTo(toX - headlen * Math.cos(angle - Math.PI / 6), toY - headlen * Math.sin(angle - Math.PI / 6));
ctx.lineTo(toX - headlen * Math.cos(angle + Math.PI / 6), toY - headlen * Math.sin(angle + Math.PI / 6));
ctx.fill();
ctx.restore();
}
// =========================================
// AUDIO: Soft click on direction switch (Viz 2)
// =========================================
let audioCtx = null;
function playClick() {
try {
if (!audioCtx) {
audioCtx = new (window.AudioContext || window.webkitAudioContext)();
}
if (audioCtx.state === 'suspended') {
audioCtx.resume();
}
} catch (e) {
return;
}
const t0 = audioCtx.currentTime;
// Short, soft sine "tick"
const osc = audioCtx.createOscillator();
const gain = audioCtx.createGain();
const filter = audioCtx.createBiquadFilter();
filter.type = 'lowpass';
filter.frequency.setValueAtTime(2000, t0);
osc.type = 'sine';
osc.frequency.setValueAtTime(1000, t0);
// gentle envelope
gain.gain.setValueAtTime(0.0001, t0);
gain.gain.exponentialRampToValueAtTime(0.04, t0 + 0.01);
gain.gain.exponentialRampToValueAtTime(0.0001, t0 + 0.08);
osc.connect(filter).connect(gain).connect(audioCtx.destination);
osc.start(t0);
osc.stop(t0 + 0.09);
}
// =========================================
// VIZ 1: POSTERIOR FIELD
// =========================================
const cvs1 = document.getElementById('posteriorCanvas');
const ctx1 = cvs1.getContext('2d');
const inputN = document.getElementById('inputN');
const btnResampleData = document.getElementById('btnResampleData');