5ba22d0
de2603c
5ba22d0
de2603c
5ba22d0
de2603c
5ba22d0
de2603c
5ba22d0
de2603c
5ba22d0
de2603c
eb25815
de2603c
eb25815
de2603c
5ba22d0
de2603c
eb25815
5ba22d0
de2603c
5ba22d0
de2603c
5ba22d0
eb25815
de2603c
eb25815
de2603c
eb25815
5ba22d0
eb25815
de2603c
eb25815
de2603c
eb25815
de2603c
eb25815
de2603c
eb25815
de2603c
eb25815
de2603c
eb25815
de2603c
eb25815
de2603c
eb25815
de2603c
eb25815
de2603c
eb25815
de2603c
eb25815
de2603c
eb25815
de2603c
eb25815
de2603c
eb25815
de2603c
eb25815
de2603c
eb25815
de2603c
eb25815
de2603c
eb25815
de2603c
eb25815
de2603c
eb25815
de2603c
eb25815
de2603c
eb25815
de2603c
eb25815
de2603c
eb25815
de2603c
eb25815
de2603c
eb25815
de2603c
eb25815
de2603c
eb25815
de2603c
eb25815
de2603c
eb25815
de2603c
eb25815
de2603c
eb25815
de2603c
eb25815
de2603c
5ba22d0
de2603c
5ba22d0
de2603c
5ba22d0
de2603c
5ba22d0
de2603c
5ba22d0
de2603c
5ba22d0
de2603c
5ba22d0
| 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 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Transformer Deep-Dive: Architectures & Foundations</title>
<script>
MathJax = { tex: { inlineMath: [['$', '$'], ['\\(', '\\)']] } };
</script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
:root {
--bg: #0f1419;
--surface: #1a1f2e;
--text: #e4e6eb;
--text-dim: #b0b7c3;
--cyan: #a371f7;
--orange: #00d4ff;
--green: #2ecc71;
--yellow: #ffaa00;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: var(--bg);
color: var(--text);
line-height: 1.6;
overflow-x: hidden;
}
.container {
max-width: 1400px;
margin: 0 auto;
padding: 20px;
}
header {
text-align: center;
margin-bottom: 40px;
padding: 30px 0;
border-bottom: 2px solid var(--cyan);
}
h1 {
font-size: 2.5em;
background: linear-gradient(135deg, var(--cyan), var(--orange));
background-clip: text;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
margin-bottom: 10px;
}
.subtitle {
color: var(--text-dim);
font-size: 1.1em;
}
.disclaimer {
margin-top: 50px;
padding: 20px;
border-top: 1px solid var(--surface);
color: var(--text-dim);
font-size: 0.85em;
text-align: center;
max-width: 800px;
margin-left: auto;
margin-right: auto;
}
.dashboard {
display: none;
}
.dashboard.active {
display: block;
}
.deep-dive-note {
background: rgba(163, 113, 247, 0.15);
border-left: 4px solid var(--cyan);
padding: 20px;
border-radius: 8px;
margin: 25px 0;
position: relative;
}
.deep-dive-note::before {
content: 'π TECHNICAL DEEP-DIVE';
font-size: 0.75em;
font-weight: 800;
color: var(--cyan);
display: block;
margin-bottom: 10px;
letter-spacing: 1px;
}
.grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
gap: 25px;
margin: 40px 0;
}
.card {
background: linear-gradient(135deg, rgba(163, 113, 247, 0.1), rgba(0, 212, 255, 0.1));
border: 2px solid var(--cyan);
border-radius: 12px;
padding: 30px;
cursor: pointer;
transition: all 0.3s ease;
text-align: center;
position: relative;
}
.card:hover {
transform: translateY(-5px);
box-shadow: 0 10px 30px rgba(163, 113, 247, 0.2);
border-color: var(--orange);
}
.card-icon {
font-size: 3em;
margin-bottom: 15px;
}
.card h3 {
color: var(--cyan);
font-size: 1.5em;
margin-bottom: 10px;
}
.card p {
color: var(--text-dim);
font-size: 0.95em;
}
.category-label {
display: inline-block;
margin-top: 10px;
padding: 5px 12px;
background: rgba(163, 113, 247, 0.2);
border-radius: 20px;
font-size: 0.85em;
color: #d1b3ff;
}
.module {
display: none;
}
.module.active {
display: block;
animation: fadeIn 0.3s ease;
}
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
.btn-back {
display: inline-block;
text-decoration: none;
padding: 10px 20px;
background: var(--cyan);
color: var(--bg);
border: none;
border-radius: 6px;
cursor: pointer;
font-weight: 600;
margin-bottom: 25px;
transition: all 0.3s ease;
}
.btn-back:hover {
background: var(--orange);
}
.tabs {
display: flex;
gap: 10px;
margin-bottom: 30px;
flex-wrap: wrap;
justify-content: center;
border-bottom: 1px solid rgba(163, 113, 247, 0.2);
padding-bottom: 15px;
overflow-x: auto;
}
.tab-btn {
padding: 10px 20px;
background: var(--surface);
color: var(--text);
border: 2px solid transparent;
border-radius: 6px;
cursor: pointer;
font-size: 0.95em;
transition: all 0.3s ease;
font-weight: 500;
white-space: nowrap;
}
.tab-btn:hover {
background: rgba(163, 113, 247, 0.1);
border-color: var(--cyan);
}
.tab-btn.active {
background: var(--cyan);
color: var(--bg);
border-color: var(--cyan);
}
.tab {
display: none;
}
.tab.active {
display: block;
animation: fadeIn 0.3s ease;
}
.section {
background: var(--surface);
border: 1px solid rgba(163, 113, 247, 0.2);
border-radius: 10px;
padding: 30px;
margin-bottom: 25px;
transition: all 0.3s ease;
}
.section:hover {
border-color: var(--cyan);
box-shadow: 0 0 20px rgba(163, 113, 247, 0.1);
}
h2 {
color: var(--cyan);
font-size: 1.8em;
margin-bottom: 15px;
}
h3 {
color: var(--orange);
font-size: 1.3em;
margin-top: 20px;
margin-bottom: 12px;
}
h4 {
color: var(--green);
font-size: 1.1em;
margin-top: 15px;
margin-bottom: 10px;
}
p {
margin-bottom: 15px;
line-height: 1.8;
}
ul {
margin-left: 20px;
margin-bottom: 15px;
}
ul li {
margin-bottom: 8px;
}
.info-box {
background: linear-gradient(135deg, rgba(163, 113, 247, 0.1), rgba(0, 212, 255, 0.1));
border: 1px solid var(--cyan);
border-radius: 8px;
padding: 20px;
margin: 20px 0;
}
.box-title {
color: var(--orange);
font-weight: 700;
margin-bottom: 10px;
font-size: 1.1em;
}
.box-content {
color: var(--text-dim);
line-height: 1.7;
}
.formula {
background: rgba(163, 113, 247, 0.1);
border: 1px solid var(--cyan);
border-radius: 8px;
padding: 20px;
margin: 20px 0;
overflow-x: auto;
line-height: 1.8;
color: #d1b3ff;
text-align: center;
}
.code-block {
background: #0d1117;
border: 1px solid #30363d;
border-radius: 8px;
padding: 20px;
margin: 20px 0;
overflow-x: auto;
font-family: 'Fira Code', 'Consolas', monospace;
font-size: 0.88em;
line-height: 1.7;
white-space: pre-wrap;
color: #e6edf3;
}
.code-title {
display: block;
background: #161b22;
color: #8b949e;
padding: 8px 16px;
border-radius: 8px 8px 0 0;
border: 1px solid #30363d;
border-bottom: none;
font-size: 0.85em;
font-family: 'Fira Code', monospace;
margin-top: 20px;
}
.code-title+.code-block {
margin-top: 0;
border-radius: 0 0 8px 8px;
}
.code-block .keyword { color: #ff7b72; }
.code-block .string { color: #a5d6ff; }
.code-block .comment { color: #8b949e; }
.code-block .function { color: #d2a8ff; }
.code-block .builtin { color: #79c0ff; }
.code-block .number { color: #79c0ff; }
.callout {
border-left: 4px solid;
padding: 15px;
margin: 20px 0;
border-radius: 6px;
}
.callout.tip {
border-left-color: var(--green);
background: rgba(46, 204, 113, 0.05);
}
.callout.warning {
border-left-color: var(--yellow);
background: rgba(255, 170, 0, 0.05);
}
.callout.insight {
border-left-color: var(--cyan);
background: rgba(163, 113, 247, 0.05);
}
.callout-title {
font-weight: 700;
margin-bottom: 8px;
}
.list-item {
display: flex;
gap: 12px;
margin: 12px 0;
padding: 12px;
background: rgba(163, 113, 247, 0.05);
border-left: 3px solid var(--cyan);
border-radius: 4px;
}
.list-num {
color: var(--orange);
font-weight: 700;
min-width: 30px;
}
table {
width: 100%;
border-collapse: collapse;
margin: 20px 0;
}
th, td {
padding: 12px;
text-align: left;
border: 1px solid rgba(163, 113, 247, 0.2);
}
th {
background: rgba(163, 113, 247, 0.1);
color: var(--cyan);
font-weight: 700;
}
@media (max-width: 768px) {
h1 { font-size: 1.8em; }
.tabs { flex-direction: column; }
.tab-btn { width: 100%; }
.grid { grid-template-columns: 1fr; }
}
</style>
</head>
<body>
<div class="container">
<div id="dashboard" class="dashboard active">
<header>
<h1>π§ Transformer Deep-Dive</h1>
<p class="subtitle">From Attention to Reasoning: A Masterclass in Modern Architectures (2025 Edition)</p>
<div style="margin-top: 25px;">
<a href="../index.html" class="btn-back">β Back to Masterclass</a>
</div>
</header>
<div style="text-align: center; margin-bottom: 40px;">
<p style="color: var(--text-dim); font-size: 1.1em; max-width: 800px; margin: 0 auto;">
Master the architecture that powers modern AI. This comprehensive 9-module curriculum deeply covers NLP fundamentals,
Transformer internals, advanced LLM tuning, reasoning architectures, and agentic workflows.
</p>
</div>
<div class="grid" id="modulesGrid"></div>
</div>
<div id="modulesContainer"></div>
</div>
<script>
const modules = [
{
id: "lecture-1",
title: "The Foundation: NLP & Transformers",
icon: "π",
category: "NLP Basics",
color: "#a371f7",
description: "Tokenization, Word2Vec, RNNs, and the Self-Attention Mechanism that started it all."
},
{
id: "lecture-2",
title: "Transformer Architectures",
icon: "π€",
category: "Architecture",
color: "#00d4ff",
description: "Deep dive into MHA, GQA, RoPE, BERT, and GPT architectures."
},
{
id: "lecture-3",
title: "Inside Large Language Models",
icon: "π§ ",
category: "LLM Internals",
color: "#ffaa00",
description: "Mixture of Experts, Decoding Strategies, Context Windows, and Prompting."
},
{
id: "lecture-4",
title: "Training & Tuning LLMs",
icon: "βοΈ",
category: "Training",
color: "#2ecc71",
description: "From Pretraining on massive sets to SFT, LoRA, and memory-saving Quantization."
},
{
id: "lecture-5",
title: "Aligning LLMs (RLHF/DPO)",
icon: "βοΈ",
category: "Alignment",
color: "#f771b6",
description: "Shaping AI behavior using RLHF, Reward Models, PPO, and DPO."
},
{
id: "lecture-6",
title: "Reasoning Models",
icon: "π€",
category: "Advanced",
color: "#ff6b35",
description: "Test-time compute, System 2 Thinking (o1-style), and GRPO RL formulation."
},
{
id: "lecture-7",
title: "Agentic LLMs & RAG",
icon: "π΅οΈ",
category: "Agents",
color: "#00c9a7",
description: "Augmenting models via Vector databases, Function Calling, and the ReAct loop."
},
{
id: "lecture-8",
title: "Evaluation & Benchmarks",
icon: "π",
category: "Evaluation",
color: "#a371f7",
description: "How to objectively measure LLMs using exact benchmarks or LLM-as-a-Judge."
},
{
id: "lecture-9",
title: "Multimodality & Trends",
icon: "ποΈ",
category: "Frontier",
color: "#00d4ff",
description: "Vision Transformers (ViT), Diffusion models, and the expanding modalities."
}
];
const MODULE_CONTENT = {
"lecture-1": {
overview: `
<p>Before Large Language Models, computers needed a way to process human language reliably. This module covers the historic journey from basic NLP processing to the revolutionary architecture that powers modern AI.</p>
<div class="deep-dive-note">
Historically, RNNs were the deep learning standard for text, but they processed data sequentially, leading to information loss over long sentences (vanishing gradients). The Transformer paper ("Attention Is All You Need", 2017) completely eliminated recurrent layers in favor of the <strong>Self-Attention Mechanism</strong>, allowing the model to look at the entire context simultaneously.
</div>
`,
concepts: `
<div class="list-item">
<div class="list-num">01</div>
<div>
<strong>Tokenization & BPE:</strong> Transition from word-level to sub-word level. Byte Pair Encoding (BPE) uses a frequency-based merge strategy to build a vocabulary.
<div class="visual-demo" style="margin-top: 15px; background: rgba(0,0,0,0.2); padding: 15px; border-radius: 8px; border: 1px solid var(--green);">
<h4 style="color: var(--green); margin-bottom: 10px; font-size: 0.85em;">BPE Merging Strategy</h4>
<svg viewBox="0 0 400 120" style="width: 100%; height: auto;">
<rect x="20" y="20" width="40" height="30" rx="4" fill="var(--surface)" stroke="var(--text-dim)" />
<text x="32" y="40" fill="var(--text)" font-size="12">l o</text>
<rect x="70" y="20" width="40" height="30" rx="4" fill="var(--surface)" stroke="var(--text-dim)" />
<text x="82" y="40" fill="var(--text)" font-size="12">w</text>
<rect x="120" y="20" width="40" height="30" rx="4" fill="var(--surface)" stroke="var(--text-dim)" />
<text x="132" y="40" fill="var(--text)" font-size="12">e r</text>
<path d="M 40 55 L 75 80" stroke="var(--green)" stroke-width="1" marker-end="url(#arrow-green)" />
<path d="M 90 55 L 85 80" stroke="var(--green)" stroke-width="1" marker-end="url(#arrow-green)" />
<rect x="60" y="85" width="60" height="30" rx="4" fill="rgba(46, 204, 113, 0.2)" stroke="var(--green)" />
<text x="75" y="105" fill="var(--text)" font-size="12">"low"</text>
<text x="130" y="105" fill="var(--text-dim)" font-size="10">+ "er" ...</text>
</svg>
<p style="font-size: 0.75em; color: var(--text-dim);">Frequent sequences (l+o+w) are merged into a single token, reducing sequence length while handling rare words.</p>
</div>
</div>
</div>
<div class="list-item">
<div class="list-num">02</div>
<div>
<strong>Word2Vec & Vector Spaces:</strong> Word embeddings map tokens into a high-dimensional continuous space (e.g., 512 dimensions). These vectors capture semantic relationships via dot products; tokens with similar meanings are geometrically close.
<div class="visual-demo" style="margin-top: 20px; background: rgba(0,0,0,0.2); padding: 20px; border-radius: 8px; border: 1px solid var(--cyan);">
<h4 style="color: var(--cyan); margin-bottom: 15px; font-size: 0.9em;">Visualizing Semantic Vector Math: King - Man + Woman β Queen</h4>
<svg viewBox="0 0 400 200" style="width: 100%; height: auto;">
<line x1="20" y1="180" x2="380" y2="180" stroke="var(--text-dim)" stroke-width="1" />
<line x1="20" y1="20" x2="20" y2="180" stroke="var(--text-dim)" stroke-width="1" />
<circle cx="60" cy="140" r="4" fill="var(--orange)" />
<text x="70" y="145" fill="var(--text)" font-size="12">Man</text>
<line x1="60" y1="140" x2="160" y2="60" stroke="var(--orange)" stroke-width="2" stroke-dasharray="4" />
<circle cx="160" cy="60" r="4" fill="var(--orange)" />
<text x="170" y="65" fill="var(--text)" font-size="12">King</text>
<circle cx="150" cy="160" r="4" fill="var(--cyan)" />
<text x="160" y="165" fill="var(--text)" font-size="12">Woman</text>
<line x1="150" y1="160" x2="250" y2="80" stroke="var(--cyan)" stroke-width="2" stroke-dasharray="4" />
<circle cx="250" cy="80" r="4" fill="var(--cyan)" />
<text x="260" y="85" fill="var(--text)" font-size="12">Queen</text>
<path d="M 60 140 L 150 160" stroke="var(--green)" stroke-width="1" marker-end="url(#arrow)" />
<path d="M 160 60 L 250 80" stroke="var(--green)" stroke-width="1" marker-end="url(#arrow)" />
<defs>
<marker id="arrow" markerWidth="10" markerHeight="10" refX="0" refY="3" orient="auto" markerUnits="strokeWidth">
<path d="M0,0 L0,6 L9,3 z" fill="var(--green)" />
</marker>
</defs>
</svg>
<p style="font-size: 0.8em; color: var(--text-dim); margin-top: 10px;">The relationship vector (Gender) is consistently mapped across different nouns.</p>
</div>
<div class="visual-demo" style="margin-top: 20px; background: rgba(0,0,0,0.2); padding: 20px; border-radius: 8px; border: 1px solid var(--orange);">
<h4 style="color: var(--orange); margin-bottom: 15px; font-size: 0.9em;">Latent Space Clustering</h4>
<svg viewBox="0 0 400 150" style="width: 100%; height: auto;">
<g>
<circle cx="80" cy="70" r="30" fill="var(--cyan)" opacity="0.1" />
<circle cx="70" cy="60" r="3" fill="var(--cyan)" /> <text x="75" y="62" fill="var(--text-dim)" font-size="10">Apple</text>
<circle cx="90" cy="80" r="3" fill="var(--cyan)" /> <text x="95" y="82" fill="var(--text-dim)" font-size="10">Banana</text>
<circle cx="65" cy="85" r="3" fill="var(--cyan)" /> <text x="50" y="95" fill="var(--text-dim)" font-size="10">Orange</text>
</g>
<g>
<circle cx="280" cy="80" r="35" fill="var(--orange)" opacity="0.1" />
<circle cx="270" cy="70" r="3" fill="var(--orange)" /> <text x="275" y="72" fill="var(--text-dim)" font-size="10">Car</text>
<circle cx="300" cy="90" r="3" fill="var(--orange)" /> <text x="305" y="92" fill="var(--text-dim)" font-size="10">Truck</text>
<circle cx="260" cy="100" r="3" fill="var(--orange)" /> <text x="240" y="115" fill="var(--text-dim)" font-size="10">Airplane</text>
</g>
</svg>
<p style="font-size: 0.8em; color: var(--text-dim); margin-top: 10px;">Embeddings naturally group semantically similar concepts together in vector clusters.</p>
</div>
</div>
</div>
<div class="list-item">
<div class="list-num">03</div>
<div>
<strong>The RNN Vanishing Gradient:</strong> Recurrent architectures process tokens sequentially, leading to information loss. Transformers solve this by processing all tokens simultaneously.
<div class="visual-demo" style="margin-top: 15px; background: rgba(0,0,0,0.2); padding: 15px; border-radius: 8px; border: 1px solid #e74c3c;">
<h4 style="color: #e74c3c; margin-bottom: 10px; font-size: 0.85em;">Sequential (RNN) vs. Parallel (Transformer)</h4>
<svg viewBox="0 0 400 150" style="width: 100%; height: auto;">
<text x="20" y="25" fill="#e74c3c" font-size="10" font-weight="bold">RNN (Bottleneck)</text>
<rect x="20" y="40" width="30" height="20" rx="2" fill="var(--surface)" stroke="var(--text-dim)" />
<path d="M 50 50 L 70 50" stroke="var(--text-dim)" marker-end="url(#arrow-red)" />
<rect x="70" y="40" width="30" height="20" rx="2" fill="var(--surface)" stroke="var(--text-dim)" />
<path d="M 100 50 L 120 50" stroke="#e74c3c" stroke-width="2" marker-end="url(#arrow-red)" />
<text x="125" y="55" fill="#e74c3c" font-size="20">...</text>
<text x="220" y="25" fill="var(--cyan)" font-size="10" font-weight="bold">Transformer (All-at-once)</text>
<rect x="220" y="40" width="20" height="15" rx="1" fill="var(--cyan)" opacity="0.3" />
<rect x="250" y="40" width="20" height="15" rx="1" fill="var(--cyan)" opacity="0.3" />
<rect x="280" y="40" width="20" height="15" rx="1" fill="var(--cyan)" opacity="0.3" />
<path d="M 230 55 L 290 85" stroke="var(--cyan)" opacity="0.4" />
<path d="M 260 55 L 290 85" stroke="var(--cyan)" opacity="0.4" />
<path d="M 290 55 L 290 85" stroke="var(--cyan)" opacity="0.8" />
<rect x="220" y="85" width="100" height="40" rx="4" fill="var(--surface)" stroke="var(--cyan)" />
<text x="235" y="110" fill="var(--cyan)" font-size="12">Attention Layer</text>
</svg>
<p style="font-size: 0.75em; color: var(--text-dim);">Transformers eliminate the time-step dependency, removing the "forgetting" bottleneck of RNNs.</p>
</div>
</div>
</div>
<div class="list-item">
<div class="list-num">04</div>
<div>
<strong>Self-Attention Mechanism:</strong> The dynamic computation of weights via Query (Q), Key (K), and Value (V) projections.
<div class="visual-demo" style="margin-top: 15px; background: rgba(0,0,0,0.2); padding: 15px; border-radius: 8px; border: 1px solid var(--yellow);">
<h4 style="color: var(--yellow); margin-bottom: 10px; font-size: 0.85em;">Query, Key, and Value Interaction</h4>
<svg viewBox="0 0 400 150" style="width: 100%; height: auto;">
<circle cx="50" cy="40" r="15" fill="var(--cyan)" /> <text x="45" y="45" fill="var(--bg)" font-weight="bold">Q</text>
<circle cx="150" cy="40" r="15" fill="var(--orange)" /> <text x="145" y="45" fill="var(--bg)" font-weight="bold">K</text>
<circle cx="250" cy="40" r="15" fill="var(--green)" /> <text x="145" y="45" fill="var(--bg)" font-weight="bold" /> <text x="245" y="45" fill="var(--bg)" font-weight="bold">V</text>
<path d="M 65 40 L 135 40" stroke="var(--yellow)" stroke-width="2" marker-end="url(#arrow-yellow)" />
<text x="75" y="30" fill="var(--yellow)" font-size="10">Internal product (Score)</text>
<path d="M 165 40 L 235 40" stroke="var(--text-dim)" opacity="0.5" />
<path d="M 150 55 L 200 100" stroke="var(--yellow)" marker-end="url(#arrow-yellow)" />
<path d="M 250 55 L 210 100" stroke="var(--green)" marker-end="url(#arrow-green)" />
<rect x="170" y="105" width="60" height="30" rx="4" fill="var(--surface)" stroke="var(--yellow)" />
<text x="182" y="125" fill="var(--text)" font-size="10">Context Z</text>
</svg>
<p style="font-size: 0.75em; color: var(--text-dim);">The Query looks for specific information in the Keys. The score determines how much of the Value is retrieved.</p>
</div>
</div>
</div>
`,
math: `
<h3>The Self-Attention Equation</h3>
<p>The core mathematical breakthrough that allows parallel processing of context is the Scaled Dot-Product Attention equation.</p>
<div class="formula">
$$ \\text{Attention}(Q, K, V) = \\text{softmax}\\left( \\frac{QK^T}{\\sqrt{d_k}} \\right) V $$
</div>
<div style="text-align: left; max-width: 600px; margin: 0 auto; color: var(--text-dim);">
<p><strong>Query (Q):</strong> What the current token is looking for.</p>
<p><strong>Key (K):</strong> What other tokens offer.</p>
<p><strong>Value (V):</strong> The actual information represented by the token.</p>
<p><strong>$\\sqrt{d_k}$:</strong> A scaling factor to prevent gradients from disappearing during softmax.</p>
</div>
`,
code: `
<span class="code-title">π attention.py</span>
<div class="code-block"><span class="keyword">import</span> torch
<span class="keyword">import</span> torch.nn.functional <span class="keyword">as</span> F
<span class="keyword">import</span> math
<span class="keyword">def</span> <span class="function">scaled_dot_product_attention</span>(Q, K, V, mask=<span class="keyword">None</span>):
<span class="string">"""
Compute 'Scaled Dot Product Attention'
"""</span>
d_k = Q.size(-<span class="number">1</span>)
<span class="comment"># 1. Compute dot product (scores)</span>
scores = torch.matmul(Q, K.transpose(-<span class="number">2</span>, -<span class="number">1</span>)) / math.sqrt(d_k)
<span class="comment"># 2. Apply masking (essential for autoregressive generation)</span>
<span class="keyword">if</span> mask <span class="keyword">is</span> <span class="keyword">not</span> <span class="keyword">None</span>:
scores = scores.masked_fill(mask == <span class="number">0</span>, -<span class="number">1e9</span>)
<span class="comment"># 3. Softmax to get probabilities/attention weights</span>
attention_weights = F.softmax(scores, dim=-<span class="number">1</span>)
<span class="comment"># 4. Multiply by values</span>
output = torch.matmul(attention_weights, V)
<span class="keyword">return</span> output, attention_weights</div>
`
},
"lecture-2": {
overview: `
<p>The original Transformer architecture has been significantly optimized. This module explores how researchers modified Attention constraints to build faster, larger foundation models.</p>
<div class="info-box">
<div class="box-title">Evolution of the Transformer</div>
<div class="box-content">
While the original 2017 architecture contained both an <strong>Encoder</strong> and a <strong>Decoder</strong>, modern models generally specialize: BERT uses only the Encoder for classification/understanding, while GPT uses only the Decoder for generative text.
</div>
</div>
`,
concepts: `
<h3>Architectural Optimizations</h3>
<div class="list-item">
<div class="list-num">01</div>
<div><strong>Multi-Head Attention (MHA):</strong> By projecting Q, K, and V into multiple lower-dimensional "heads," the model can attend to information from different representation subspaces simultaneously. One head might focus on syntax, while another focuses on sentiment.</div>
</div>
<div><strong>Multi-Head Attention (MHA):</strong> By projecting Q, K, and V into multiple lower-dimensional "heads," the model can attend to information from different representation subspaces simultaneously. One head might focus on syntax, while another focuses on sentiment.</div>
</div>
<div class="list-item">
<div class="list-num">03</div>
<div>
<strong>KV Cache & GQA:</strong> Autoregressive generation requires re-calculating attention. Grouped-Query Attention (GQA) reduces memory bandwidth.
<div class="visual-demo" style="margin-top: 15px; background: rgba(0,0,0,0.2); padding: 15px; border-radius: 8px; border: 1px solid var(--cyan);">
<h4 style="color: var(--cyan); margin-bottom: 10px; font-size: 0.85em;">Head Grouping: MHA vs GQA</h4>
<svg viewBox="0 0 400 120" style="width: 100%; height: auto;">
<text x="20" y="20" fill="var(--text-dim)" font-size="10">MHA (1:1)</text>
<rect x="25" y="30" width="10" height="10" fill="var(--cyan)" /> <line x1="35" y1="35" x2="55" y2="35" stroke="var(--orange)" /> <rect x="55" y="30" width="10" height="10" fill="var(--orange)" />
<rect x="25" y="45" width="10" height="10" fill="var(--cyan)" /> <line x1="35" y1="50" x2="55" y2="50" stroke="var(--orange)" /> <rect x="55" y="45" width="10" height="10" fill="var(--orange)" />
<text x="220" y="20" fill="var(--cyan)" font-size="10">GQA (Many-to-One)</text>
<rect x="225" y="30" width="10" height="10" fill="var(--cyan)" />
<rect x="225" y="45" width="10" height="10" fill="var(--cyan)" />
<rect x="225" y="60" width="10" height="10" fill="var(--cyan)" />
<path d="M 235 35 L 265 50" stroke="var(--orange)" />
<path d="M 235 50 L 265 50" stroke="var(--orange)" />
<path d="M 235 65 L 265 50" stroke="var(--orange)" />
<rect x="265" y="45" width="10" height="10" fill="var(--orange)" />
</svg>
<p style="font-size: 0.75em; color: var(--text-dim);">GQA shares Key/Value heads across multiple Query heads, drastically reducing the KV Cache memory footprint.</p>
</div>
</div>
</div>
<div class="list-item">
<div class="list-num">03</div>
<div>
<strong>RoPE (Rotary Position Embeddings):</strong> Relative distance encoded as rotations in the complex plane.
<div class="visual-demo" style="margin-top: 15px; background: rgba(0,0,0,0.2); padding: 15px; border-radius: 8px; border: 1px solid var(--orange);">
<h4 style="color: var(--orange); margin-bottom: 10px; font-size: 0.85em;">RoPE: Rotation in Latent Space</h4>
<svg viewBox="0 0 400 120" style="width: 100%; height: auto;">
<circle cx="200" cy="60" r="40" fill="none" stroke="var(--text-dim)" opacity="0.3" stroke-dasharray="2" />
<line x1="160" y1="60" x2="240" y2="60" stroke="var(--text-dim)" opacity="0.5" />
<line x1="200" y1="20" x2="200" y2="100" stroke="var(--text-dim)" opacity="0.5" />
<line x1="200" y1="60" x2="235" y2="40" stroke="var(--cyan)" stroke-width="2" marker-end="url(#arrow-cyan)" />
<text x="240" y="45" fill="var(--cyan)" font-size="10">Pos 1 (ΞΈ)</text>
<line x1="200" y1="60" x2="180" y2="25" stroke="var(--orange)" stroke-width="2" marker-end="url(#arrow-orange)" />
<text x="160" y="25" fill="var(--orange)" font-size="10">Pos 2 (2ΞΈ)</text>
</svg>
<p style="font-size: 0.75em; color: var(--text-dim);">Position is encoded as a rotation angle. The dot product between rotated vectors naturally captures relative distance.</p>
</div>
</div>
</div>
<div class="list-item">
<div class="list-num">04</div>
<div>
<strong>Normalization (RMSNorm):</strong> Faster weight stabilization.
<div class="visual-demo" style="margin-top: 15px; background: rgba(0,0,0,0.2); padding: 15px; border-radius: 8px; border: 1px solid var(--cyan);">
<h4 style="color: var(--cyan); margin-bottom: 10px; font-size: 0.85em;">RMSNorm vs LayerNorm</h4>
<svg viewBox="0 0 400 100" style="width: 100%; height: auto;">
<rect x="50" y="30" width="100" height="40" fill="var(--surface)" stroke="var(--text-dim)" />
<text x="60" y="55" fill="var(--text-dim)" font-size="10">Mean + Var</text>
<path d="M 160 50 L 200 50" stroke="var(--text-dim)" marker-end="url(#arrow-dim)" />
<rect x="210" y="30" width="100" height="40" fill="rgba(0, 212, 255, 0.1)" stroke="var(--cyan)" />
<text x="220" y="55" fill="var(--cyan)" font-size="10">RMS Scaling Only</text>
</svg>
<p style="font-size: 0.75em; color: var(--text-dim);">RMSNorm removes the mean-centering step, making it computationally faster for high-throughput models.</p>
</div>
</div>
</div>
`
},
"lecture-3": {
overview: `
<p>What makes an LLM "Large" and how do we extract the best performance out of it? This module rips open the generative engine inside models like GPT-4, Llama 3, and Claude.</p>
`,
concepts: `
<h3>LLM Internals & Inference</h3>
<div class="list-item">
<div class="list-num">01</div>
<div>
<strong>Mixture of Experts (MoE):</strong> Scaling model capacity without scaling compute. For each token, a "Router" selects a subset of "Experts."
<div class="visual-demo" style="margin-top: 15px; background: rgba(0,0,0,0.2); padding: 15px; border-radius: 8px; border: 1px solid var(--green);">
<h4 style="color: var(--green); margin-bottom: 10px; font-size: 0.85em;">Sparse Expert Routing (MoE)</h4>
<svg viewBox="0 0 400 120" style="width: 100%; height: auto;">
<rect x="60" y="45" width="60" height="40" rx="4" fill="var(--surface)" stroke="var(--cyan)" />
<text x="70" y="70" fill="var(--cyan)" font-size="12">Router</text>
<line x1="120" y1="65" x2="200" y2="35" stroke="var(--green)" stroke-width="2" marker-end="url(#arrow-green)" />
<line x1="120" y1="65" x2="200" y2="95" stroke="var(--green)" stroke-width="2" marker-end="url(#arrow-green)" />
<rect x="200" y="20" width="80" height="30" rx="2" fill="rgba(46, 204, 113, 0.2)" stroke="var(--green)" />
<text x="215" y="40" fill="var(--text)" font-size="10">Expert 1</text>
<rect x="200" y="80" width="80" height="30" rx="2" fill="rgba(46, 204, 113, 0.2)" stroke="var(--green)" />
<text x="215" y="100" fill="var(--text)" font-size="10">Expert N</text>
</svg>
<p style="font-size: 0.75em; color: var(--text-dim);">The Router only activates the most relevant Feed-Forward networks for each specific token.</p>
</div>
</div>
</div>
<div class="list-item">
<div class="list-num">02</div>
<div>
<strong>KV Cache Management (vLLM):</strong> Efficient memory allocation.
<div class="visual-demo" style="margin-top: 15px; background: rgba(0,0,0,0.2); padding: 15px; border-radius: 8px; border: 1px solid var(--orange);">
<h4 style="color: var(--orange); margin-bottom: 10px; font-size: 0.85em;">PagedAttention: Virtual Memory for LLMs</h4>
<svg viewBox="0 0 400 100" style="width: 100%; height: auto;">
<rect x="20" y="30" width="30" height="30" fill="var(--orange)" opacity="0.8" />
<rect x="55" y="30" width="30" height="30" fill="var(--orange)" opacity="0.4" />
<path d="M 35 65 L 150 80" stroke="var(--orange)" stroke-dasharray="2" />
<path d="M 70 65 L 220 50" stroke="var(--orange)" stroke-dasharray="2" />
<rect x="150" y="65" width="25" height="25" fill="var(--orange)" opacity="0.8" />
<rect x="180" y="35" width="25" height="25" fill="var(--surface)" stroke="var(--text-dim)" />
<rect x="210" y="35" width="25" height="25" fill="var(--orange)" opacity="0.4" />
</svg>
<p style="font-size: 0.75em; color: var(--text-dim);">Non-contiguous memory slots are mapped to the sequence, eliminating waste and internal fragmentation.</p>
</div>
</div>
</div>
<div class="list-item">
<div class="list-num">03</div>
<div>
<strong>Continuous Batching:</strong> Dynamic request handling in production.
<div class="visual-demo" style="margin-top: 15px; background: rgba(0,0,0,0.2); padding: 15px; border-radius: 8px; border: 1px solid var(--green);">
<h4 style="color: var(--green); margin-bottom: 10px; font-size: 0.85em;">Static vs. Continuous Batching</h4>
<svg viewBox="0 0 400 120" style="width: 100%; height: auto;">
<text x="20" y="20" fill="var(--text-dim)" font-size="10">Static (Wait for all)</text>
<rect x="25" y="30" width="100" height="20" fill="rgba(231, 76, 60, 0.3)" stroke="#e74c3c" />
<text x="35" y="44" fill="var(--text)" font-size="9">Req A, B, C...</text>
<text x="220" y="20" fill="var(--green)" font-size="10">Continuous (Fill voids)</text>
<rect x="225" y="30" width="60" height="20" fill="var(--green)" opacity="0.3" stroke="var(--green)" />
<text x="230" y="44" fill="var(--text)" font-size="9">Req A (End)</text>
<rect x="290" y="30" width="60" height="20" fill="var(--cyan)" opacity="0.3" stroke="var(--cyan)" />
<text x="295" y="44" fill="var(--text)" font-size="9">Req D (New)</text>
<path d="M 285 55 L 290 30" stroke="var(--green)" stroke-dasharray="2" marker-end="url(#arrow-green)" />
</svg>
<p style="font-size: 0.75em; color: var(--text-dim);">Continuous batching injects new requests into the batch as soon as others finish, maximizing GPU utilization.</p>
</div>
</div>
</div>
<div class="list-item">
<div class="list-num">04</div>
<div>
<strong>Temperature & Sampling:</strong> Probability sharpening.
<div class="visual-demo" style="margin-top: 15px; background: rgba(0,0,0,0.2); padding: 15px; border-radius: 8px; border: 1px solid var(--orange);">
<h4 style="color: var(--orange); margin-bottom: 10px; font-size: 0.85em;">Effect of Temperature (T)</h4>
<svg viewBox="0 0 400 100" style="width: 100%; height: auto;">
<text x="20" y="20" fill="var(--text-dim)" font-size="10">T=0.1 (Factual)</text>
<path d="M 25 80 L 40 20 L 55 80" stroke="var(--orange)" stroke-width="2" fill="none" />
<text x="35" y="95" fill="var(--orange)" font-size="9">Sharp Peak</text>
<text x="160" y="20" fill="var(--text-dim)" font-size="10">T=1.0 (Balanced)</text>
<path d="M 165 80 Q 200 40 235 80" stroke="var(--cyan)" stroke-width="2" fill="none" />
<text x="300" y="20" fill="var(--text-dim)" font-size="10">T=2.0 (Creative)</text>
<path d="M 305 75 Q 350 70 395 75" stroke="#e74c3c" stroke-width="2" fill="none" />
<text x="315" y="95" fill="#e74c3c" font-size="9">Uniform/Flat</text>
</svg>
<p style="font-size: 0.75em; color: var(--text-dim);">Low temperature concentrates probability on the top token; high temperature distributes it across many options.</p>
</div>
</div>
</div>
<div class="list-item">
<div class="list-num">05</div>
<div>
<strong>Few-Shot Prompting:</strong> In-context learning via demonstration.
<div class="visual-demo" style="margin-top: 15px; background: rgba(0,0,0,0.3); padding: 15px; border-radius: 8px; border: 1px solid var(--cyan);">
<h4 style="color: var(--cyan); margin-bottom: 10px; font-size: 0.85em;">Few-Shot Prompt Structure</h4>
<svg viewBox="0 0 400 100" style="width: 100%; height: auto;">
<rect x="20" y="10" width="360" height="80" rx="4" fill="var(--surface)" stroke="var(--cyan)" />
<text x="30" y="30" fill="var(--text)" font-size="10">Input: Dog -> Output: Animal</text>
<text x="30" y="50" fill="var(--text)" font-size="10">Input: Car -> Output: Transport</text>
<line x1="30" y1="60" x2="370" y2="60" stroke="var(--cyan)" opacity="0.3" />
<text x="30" y="80" fill="var(--orange)" font-size="10" font-weight="bold">Input: Apple -> Output: [Model Predicts...]</text>
</svg>
</div>
</div>
</div>
<div class="list-item">
<div class="list-num">06</div>
<div>
<strong>Chain of Thought (CoT):</strong> Step-by-step logic exploration.
<div class="visual-demo" style="margin-top: 15px; background: rgba(0,0,0,0.2); padding: 15px; border-radius: 8px; border: 1px solid var(--yellow);">
<h4 style="color: var(--yellow); margin-bottom: 10px; font-size: 0.85em;">Reasoning Search Tree</h4>
<svg viewBox="0 0 400 120" style="width: 100%; height: auto;">
<circle cx="200" cy="20" r="10" fill="var(--cyan)" />
<path d="M 195 30 L 150 60" stroke="var(--yellow)" />
<path d="M 205 30 L 250 60" stroke="var(--yellow)" />
<circle cx="150" cy="70" r="10" fill="var(--surface)" stroke="var(--yellow)" />
<circle cx="250" cy="70" r="10" fill="var(--green)" />
<path d="M 250 80 L 250 100" stroke="var(--green)" marker-end="url(#arrow-green)" />
<text x="210" y="115" fill="var(--green)" font-size="10">Optimal Logic Path Found</text>
</svg>
<p style="font-size: 0.75em; color: var(--text-dim);">The model explores paths (thoughts), rejects bad ones, and follows the correct logical chain.</p>
</div>
</div>
</div>
`,
math:`
<h3>Sampling using Temperature</h3>
<div class="formula">
$$ p_i = \\frac{e^{z_i / T}}{\\sum_j e^{z_j / T}} $$
</div>
<p style="text-align: center; color: var(--text-dim);">
Where $T$ is the temperature parameter. As $T \\to 0$, it becomes a deterministic $\\max$ operation.<br>
As $T \\to \\infty$, the distribution becomes uniform across all possible tokens.
</p>
`
},
"lecture-4": {
overview: `
<p>How are these giant models built? The lifecycle of training a Foundation Model spans months and costs millions.</p>
`,
concepts: `
<h3>Pretraining & Scaling Deep Dive</h3>
<div class="list-item">
<div class="list-num">01</div>
<div>
<strong>Scaling Laws (Chinchilla):</strong> The relationship between Parameters (N) and Data (D).
<div class="visual-demo" style="margin-top: 15px; background: rgba(0,0,0,0.2); padding: 15px; border-radius: 8px; border: 1px solid var(--cyan);">
<h4 style="color: var(--cyan); margin-bottom: 10px; font-size: 0.85em;">Chinchilla Compute-Optimal Frontier</h4>
<svg viewBox="0 0 400 150" style="width: 100%; height: auto;">
<line x1="40" y1="120" x2="360" y2="120" stroke="var(--text-dim)" />
<line x1="40" y1="20" x2="40" y2="120" stroke="var(--text-dim)" />
<text x="300" y="140" fill="var(--text-dim)" font-size="9">Tokens (D)</text>
<text x="10" y="20" fill="var(--text-dim)" font-size="9" transform="rotate(-90 40 20)">Loss</text>
<path d="M 50 110 Q 150 40 350 30" fill="none" stroke="var(--cyan)" stroke-width="2" />
<circle cx="200" cy="50" r="4" fill="var(--orange)" />
<text x="210" y="55" fill="var(--orange)" font-size="10">Optimal Balance</text>
</svg>
<p style="font-size: 0.75em; color: var(--text-dim);">Tokens and Parameters should be scaled equally for a given compute budget.</p>
</div>
</div>
</div>
<div class="list-item">
<div class="list-num">02</div>
<div>
<strong>Data Mixing & Quality:</strong> The "garbage in, garbage out" rule.
<div class="visual-demo" style="margin-top: 15px; background: rgba(0,0,0,0.2); padding: 15px; border-radius: 8px; border: 1px solid var(--green);">
<h4 style="color: var(--green); margin-bottom: 10px; font-size: 0.85em;">Data Hygiene Pipeline</h4>
<svg viewBox="0 0 400 120" style="width: 100%; height: auto;">
<text x="20" y="20" fill="var(--text-dim)" font-size="10">Raw Web (Petabytes)</text>
<rect x="20" y="30" width="60" height="40" fill="var(--surface)" stroke="var(--text-dim)" />
<path d="M 80 50 L 120 50" stroke="var(--text-dim)" marker-end="url(#arrow-dim)" />
<rect x="120" y="30" width="100" height="40" rx="4" fill="var(--surface)" stroke="var(--cyan)" />
<text x="125" y="55" fill="var(--cyan)" font-size="10">Dedupe (MinHash)</text>
<path d="M 220 50 L 260 50" stroke="var(--text-dim)" marker-end="url(#arrow-dim)" />
<rect x="260" y="30" width="100" height="40" rx="4" fill="rgba(46, 204, 113, 0.2)" stroke="var(--green)" />
<text x="268" y="55" fill="var(--text)" font-size="10">Quality Classifier</text>
<path d="M 360 50 L 380 50" stroke="var(--green)" marker-end="url(#arrow-green)" />
</svg>
<p style="font-size: 0.75em; color: var(--text-dim);">Filtering removes 90% of raw data to ensure only high-quality information reaches the model.</p>
</div>
</div>
</div>
<div class="list-item">
<div class="list-num">03</div>
<div>
<strong>Learning Rate Schedules:</strong> Maintaining training stability.
<div class="visual-demo" style="margin-top: 15px; background: rgba(0,0,0,0.2); padding: 15px; border-radius: 8px; border: 1px solid var(--orange);">
<h4 style="color: var(--orange); margin-bottom: 10px; font-size: 0.85em;">Cosine Decay with Warmup</h4>
<svg viewBox="0 0 400 120" style="width: 100%; height: auto;">
<line x1="40" y1="100" x2="360" y2="100" stroke="var(--text-dim)" />
<line x1="40" y1="20" x2="40" y2="100" stroke="var(--text-dim)" />
<path d="M 40 100 L 80 30 Q 200 30 360 100" fill="none" stroke="var(--orange)" stroke-width="2" />
<text x="45" y="45" fill="var(--orange)" font-size="8">Warmup</text>
<text x="180" y="45" fill="var(--orange)" font-size="8">Cosine Decay</text>
<text x="300" y="115" fill="var(--text-dim)" font-size="9">Training Steps</text>
</svg>
</div>
</div>
</div>
<div class="list-item">
<div class="list-num">04</div>
<div>
<strong>3D Parallelism:</strong> Splitting the model across huge H100 clusters.
<div class="visual-demo" style="margin-top: 15px; background: rgba(0,0,0,0.2); padding: 15px; border-radius: 8px; border: 1px solid var(--cyan);">
<h4 style="color: var(--cyan); margin-bottom: 10px; font-size: 0.85em;">Tensor vs. Pipeline vs. Data Parallelism</h4>
<svg viewBox="0 0 400 120" style="width: 100%; height: auto;">
<rect x="20" y="20" width="30" height="30" fill="var(--cyan)" opacity="0.3" stroke="var(--cyan)" />
<rect x="20" y="60" width="30" height="30" fill="var(--cyan)" opacity="0.3" stroke="var(--cyan)" />
<text x="20" y="105" fill="var(--cyan)" font-size="8">Data Par (Batch)</text>
<rect x="150" y="40" width="30" height="30" fill="var(--orange)" opacity="0.4" />
<path d="M 180 55 L 210 55" stroke="var(--orange)" marker-end="url(#arrow-orange)" />
<rect x="210" y="40" width="30" height="30" fill="var(--orange)" opacity="0.6" />
<text x="160" y="105" fill="var(--orange)" font-size="8">Pipeline Par (Layers)</text>
<rect x="300" y="40" width="60" height="15" fill="rgba(163, 113, 247, 0.5)" stroke="var(--cyan)" />
<rect x="300" y="60" width="60" height="15" fill="rgba(163, 113, 247, 0.5)" stroke="var(--cyan)" />
<text x="300" y="105" fill="var(--cyan)" font-size="8">Tensor Par (Weights)</text>
</svg>
</div>
</div>
</div>
`
},
"lecture-5": {
overview: `
<p>Even an SFT model might generate harmful, politically biased, or unsafe answers. Alignment refers to shaping the model's outputs to heavily mirror human preferences.</p>
`,
concepts: `
<h3>Fine-Tuning & Alignment</h3>
<div class="list-item">
<div class="list-num">01</div>
<div><strong>SFT (Supervised Fine-Tuning):</strong> Converting a "next-token predictor" into a "helpful assistant." The model is trained on (Prompt, Completion) pairs. This stage teaches the model the "Instruction Following" format and the appropriate tone for interaction.</div>
</div>
<div class="list-item">
<div class="list-num">02</div>
<div><strong>PEFT (Parameter-Efficient Fine-Tuning):</strong> Techniques like LoRA (Low-Rank Adaptation) freeze the base weights and only train a small subset of "delta" weights. This reduces the VRAM requirement by 100x and allows multiple specialized models to share the same base weights in memory.</div>
</div>
<div class="list-item">
<div class="list-num">03</div>
<div>
<strong>Alignment (RLHF & DPO):</strong> Shaping behavior to match human values.
<div class="visual-demo" style="margin-top: 15px; background: rgba(0,0,0,0.2); padding: 15px; border-radius: 8px; border: 1px solid var(--orange);">
<h4 style="color: var(--orange); margin-bottom: 10px; font-size: 0.85em;">The Alignment Lifecycle (RLHF)</h4>
<svg viewBox="0 0 400 120" style="width: 100%; height: auto;">
<rect x="20" y="45" width="60" height="30" rx="2" fill="var(--surface)" stroke="var(--cyan)" />
<text x="35" y="65" fill="var(--text)" font-size="10">SFT</text>
<path d="M 80 60 L 120 60" stroke="var(--text-dim)" marker-end="url(#arrow-dim)" />
<rect x="120" y="45" width="100" height="30" rx="2" fill="var(--surface)" stroke="#e74c3c" />
<text x="130" y="65" fill="var(--text)" font-size="10">Reward Model</text>
<path d="M 220 60 L 260 60" stroke="var(--text-dim)" marker-end="url(#arrow-dim)" />
<rect x="260" y="45" width="100" height="30" rx="2" fill="rgba(46, 204, 113, 0.2)" stroke="var(--green)" />
<text x="275" y="65" fill="var(--text)" font-size="10">PPO / DPO</text>
<path d="M 310 45 Q 200 0 50 45" fill="none" stroke="var(--green)" stroke-dasharray="2" marker-end="url(#arrow-green)" />
</svg>
<p style="font-size: 0.75em; color: var(--text-dim);">Alignment fine-tunes the base model to prioritize helpfulness and safety based on preference data.</p>
</div>
</div>
</div>
<div class="list-item">
<div class="list-num">04</div>
<div><strong>Catastrophic Forgetting:</strong> A major challenge in fine-tuning where a model loses its general knowledge (pretraining facts) while learning a specific task. Mitigation strategies includes lower learning rates and mixing in pretraining data during the fine-tuning phase.</div>
</div>
`
},
"lecture-6": {
overview: `
<p>Generative modeling reaches its ceiling when answers require long planning steps. "Reasoning Models" (like DeepSeek R1 and OpenAI o1) use RL to develop an inner monologue.</p>
<div class="callout tip">
<div class="callout-title">System 1 vs System 2</div>
Standard LLMs are "System 1" (instinctual, fast reflexes). Reasoning models unlock "System 2" (methodical, slow, deep thinking).
</div>
`,
concepts: `
<h3>Logic, Math & Verification</h3>
<div class="list-item">
<div class="list-num">01</div>
<div>
<strong>Reasoning Trajectories:</strong> Spending "test-time compute" to solve complex problems.
<div class="visual-demo" style="margin-top: 15px; background: rgba(0,0,0,0.2); padding: 15px; border-radius: 8px; border: 1px solid var(--cyan);">
<h4 style="color: var(--cyan); margin-bottom: 10px; font-size: 0.85em;">CoT vs. Reasoning Models (o1/R1)</h4>
<svg viewBox="0 0 400 120" style="width: 100%; height: auto;">
<rect x="10" y="10" width="60" height="20" rx="2" fill="var(--surface)" stroke="var(--cyan)" />
<text x="18" y="25" fill="var(--text)" font-size="9">Prompt</text>
<path d="M 70 20 L 150 20 L 150 60 L 250 60" fill="none" stroke="var(--orange)" stroke-width="2" stroke-dasharray="3" />
<rect x="130" y="70" width="100" height="20" rx="2" fill="rgba(255, 170, 0, 0.1)" stroke="var(--orange)" />
<text x="140" y="85" fill="var(--orange)" font-size="8">Thinking Tokens...</text>
<path d="M 230 80 L 320 80" stroke="var(--green)" marker-end="url(#arrow-green)" />
<rect x="320" y="70" width="60" height="25" rx="2" fill="rgba(46, 204, 113, 0.1)" stroke="var(--green)" />
<text x="335" y="85" fill="var(--text)" font-size="9">Answer</text>
</svg>
<p style="font-size: 0.75em; color: var(--text-dim);">Reasoning models explore multiple paths internally before committing to a final visible output.</p>
</div>
</div>
</div>
<div class="list-item">
<div class="list-num">02</div>
<div><strong>Verifiable Rewards (RL on Math/Code):</strong> Unlike subjective chat data, math and code have ground-truth answers. Reinforcement Learning can optimize a model purely on output verification (does it pass the test cases?), allowing the model to "learn to think" without human-labeled reasoning paths.</div>
</div>
<div class="list-item">
<div class="list-num">03</div>
<div><strong>AlphaCode & Strawberry Logic:</strong> Strategies for searching through potential solution spaces. The model generates many candidates, verifies them, and uses the correct ones to further tune its internal policy. This moves LLMs from "System 1" (instinctive) to "System 2" (deliberative) thinking.</div>
</div>
`
},
"lecture-7": {
overview: `
<p>An LLM is just a brain locked in a vault. Agentic frameworks give it the ability to connect to databases, browse the web, and execute actions.</p>
`,
concepts: `
<h3>Agent & Integration Paradigms</h3>
<div class="list-item">
<div class="list-num">01</div>
<div>
<strong>RAG (Retrieval-Augmented Generation):</strong> Connecting LLMs to private data via Vector DBs.
<div class="visual-demo" style="margin-top: 15px; background: rgba(0,0,0,0.2); padding: 15px; border-radius: 8px; border: 1px solid var(--cyan);">
<h4 style="color: var(--cyan); margin-bottom: 10px; font-size: 0.85em;">RAG Pipeline</h4>
<svg viewBox="0 0 400 80" style="width: 100%; height: auto;">
<rect x="20" y="25" width="60" height="30" fill="var(--surface)" stroke="var(--cyan)" />
<text x="35" y="45" fill="var(--cyan)" font-size="10">Query</text>
<path d="M 80 40 L 120 40" stroke="var(--text-dim)" marker-end="url(#arrow-dim)" />
<rect x="120" y="15" width="80" height="50" rx="2" fill="var(--surface)" stroke="var(--orange)" />
<text x="135" y="45" fill="var(--orange)" font-size="10">Vector DB</text>
<path d="M 200 40 L 250 40" stroke="var(--text-dim)" marker-end="url(#arrow-dim)" />
<rect x="250" y="15" width="100" height="50" rx="4" fill="var(--surface)" stroke="var(--green)" />
<text x="260" y="45" fill="var(--green)" font-size="10">Augmented Prompt</text>
</svg>
</div>
</div>
</div>
<div class="list-item">
<div class="list-num">02</div>
<div><strong>Function Calling (Tool Use):</strong> Models finetuned to halt generation and return a strictly formatted JSON specifying an API name and extracted parameters (e.g., <code>{"name":"get_weather", "location":"Boston"}</code>).</div>
</div>
<div class="list-item">
<div class="list-num">03</div>
<div>
<strong>The ReAct Pattern:</strong> The Thought β Action β Observation cycle.
<div class="visual-demo" style="margin-top: 15px; background: rgba(0,0,0,0.2); padding: 15px; border-radius: 8px; border: 1px solid var(--yellow);">
<h4 style="color: var(--yellow); margin-bottom: 10px; font-size: 0.85em;">Agentic ReAct Loop</h4>
<svg viewBox="0 0 400 120" style="width: 100%; height: auto;">
<circle cx="200" cy="30" r="15" fill="var(--cyan)" /> <text x="220" y="35" fill="var(--text)" font-size="10">Thought</text>
<circle cx="300" cy="80" r="15" fill="var(--orange)" /> <text x="320" y="85" fill="var(--text)" font-size="10">Action</text>
<circle cx="100" cy="80" r="15" fill="var(--green)" /> <text x="40" y="85" fill="var(--text)" font-size="10">Observation</text>
<path d="M 215 35 Q 260 45 290 65" fill="none" stroke="var(--text-dim)" marker-end="url(#arrow-dim)" />
<path d="M 285 85 Q 200 100 115 85" fill="none" stroke="var(--text-dim)" marker-end="url(#arrow-dim)" />
<path d="M 110 65 Q 140 45 185 35" fill="none" stroke="var(--text-dim)" marker-end="url(#arrow-dim)" />
</svg>
</div>
</div>
</div>
`
},
"lecture-8": {
overview: `
<p>Evaluating an LLM's intelligence is extremely complex since language is subjective. This module covers benchmarks and the transition to algorithmic judges.</p>
`,
concepts: `
<h3>Benchmarks & Human Calibration</h3>
<div class="list-item">
<div class="list-num">01</div>
<div>
<strong>Chatbot Arena & Elo System:</strong> Crowdsourced human ranking.
<div class="visual-demo" style="margin-top: 15px; background: rgba(0,0,0,0.2); padding: 15px; border-radius: 8px; border: 1px solid var(--cyan);">
<h4 style="color: var(--cyan); margin-bottom: 10px; font-size: 0.85em;">LMSYS Arena Battle</h4>
<svg viewBox="0 0 400 100" style="width: 100%; height: auto;">
<rect x="40" y="30" width="100" height="50" rx="4" fill="var(--surface)" stroke="var(--cyan)" />
<text x="60" y="60" fill="var(--text)" font-size="10">Model A</text>
<text x="180" y="60" fill="var(--orange)" font-size="12" font-weight="bold">VS</text>
<rect x="260" y="30" width="100" height="50" rx="4" fill="var(--surface)" stroke="var(--green)" />
<text x="280" y="60" fill="var(--text)" font-size="10">Model B</text>
<path d="M 200 70 L 200 90" stroke="var(--text-dim)" marker-end="url(#arrow-dim)" />
<text x="165" y="105" fill="var(--text-dim)" font-size="9">Crowd Voting</text>
</svg>
</div>
</div>
</div>
<div class="list-item">
<div class="list-num">02</div>
<div><strong>Model Contamination:</strong> A critical issue where benchmark questions are accidentally included in the model's pretraining data (the model "memorizes" the test). Modern evals use private, fresh, or dynamically generated datasets to prevent this.</div>
</div>
<div class="list-item">
<div class="list-num">03</div>
<div><strong>Eval-as-a-Service:</strong> Tools like DeepEval or RAGAS focus on specific metrics for agents, such as Hallucination Rate, Factuality, and Context Adherence, rather than just general conversational quality.</div>
</div>
`
},
"lecture-9": {
overview: `
<p>The bleeding edge. The integration of image, audio, and generation models merging into singular foundation interfaces.</p>
`,
concepts: `
<h3>The Multi-Senses Architecture</h3>
<div class="list-item">
<div class="list-num">01</div>
<div>
<strong>Vision Transformers (ViT):</strong> "An Image is worth 16x16 words."
<div class="visual-demo" style="margin-top: 15px; background: rgba(0,0,0,0.2); padding: 15px; border-radius: 8px; border: 1px solid var(--cyan);">
<h4 style="color: var(--cyan); margin-bottom: 10px; font-size: 0.85em;">Image-to-Patch Tokenization</h4>
<svg viewBox="0 0 400 120" style="width: 100%; height: auto;">
<rect x="20" y="20" width="60" height="60" fill="var(--cyan)" opacity="0.1" stroke="var(--cyan)" />
<line x1="40" y1="20" x2="40" y2="80" stroke="var(--cyan)" opacity="0.3" />
<line x1="60" y1="20" x2="60" y2="80" stroke="var(--cyan)" opacity="0.3" />
<line x1="20" y1="40" x2="80" y2="40" stroke="var(--cyan)" opacity="0.3" />
<line x1="20" y1="60" x2="80" y2="60" stroke="var(--cyan)" opacity="0.3" />
<path d="M 85 50 L 150 50" stroke="var(--text-dim)" marker-end="url(#arrow-dim)" />
<rect x="160" y="40" width="20" height="20" fill="var(--cyan)" stroke="var(--cyan)" />
<rect x="190" y="40" width="20" height="20" fill="var(--cyan)" stroke="var(--cyan)" />
<rect x="220" y="40" width="20" height="20" fill="var(--cyan)" stroke="var(--cyan)" />
<text x="250" y="55" fill="var(--text-dim)" font-size="12">...</text>
<path d="M 170 35 L 250 15" stroke="var(--orange)" stroke-dasharray="2" />
<text x="260" y="20" fill="var(--orange)" font-size="10">Attention Ready</text>
</svg>
<p style="font-size: 0.75em; color: var(--text-dim);">Images are flattened into patches, enabling the same Transformer architecture to handle visual data as tokens.</p>
</div>
</div>
</div>
<div class="list-item">
<div class="list-num">02</div>
<div>
<strong>Contrastive Learning (CLIP):</strong> Creating the bridge between eyes and mind.
<div class="visual-demo" style="margin-top: 15px; background: rgba(0,0,0,0.2); padding: 15px; border-radius: 8px; border: 1px solid var(--orange);">
<h4 style="color: var(--orange); margin-bottom: 10px; font-size: 0.85em;">Dual-Encoder Alignment</h4>
<svg viewBox="0 0 400 120" style="width: 100%; height: auto;">
<rect x="40" y="20" width="60" height="30" fill="var(--surface)" stroke="var(--cyan)" />
<text x="50" y="40" fill="var(--cyan)" font-size="10">Text Enc</text>
<rect x="40" y="70" width="60" height="30" fill="var(--surface)" stroke="var(--orange)" />
<text x="50" y="90" fill="var(--orange)" font-size="10">Img Enc</text>
<path d="M 110 35 L 200 60" stroke="var(--cyan)" />
<path d="M 110 85 L 200 60" stroke="var(--orange)" />
<circle cx="210" cy="60" r="15" fill="var(--green)" />
<text x="230" y="65" fill="var(--green)" font-size="10">Joint Space</text>
</svg>
<p style="font-size: 0.75em; color: var(--text-dim);">By training on millions of image-caption pairs, CLIP learns a unified understanding across modalities.</p>
</div>
</div>
</div>
<div class="list-item">
<div class="list-num">03</div>
<div><strong>Autoregressive Vision:</strong> Future state where models generate pixels token-by-token (just like text) or use latent diffusion bridges to generate extremely consistent high-definition visual narratives.</div>
</div>
`
}
};
// --- Core Application Logic ---
function initDashboard() {
const grid = document.getElementById("modulesGrid");
const container = document.getElementById("modulesContainer");
modules.forEach((module, index) => {
const card = document.createElement("div");
card.className = "card";
card.style.borderColor = module.color;
card.onclick = () => switchTo(module.id + "-module");
card.innerHTML = `
<div class="card-icon">${module.icon}</div>
<h3>${module.title}</h3>
<p>${module.description}</p>
<span class="category-label" style="background: ${module.color}22; color: ${module.color};">${module.category}</span>
`;
grid.appendChild(card);
const moduleHTML = createModuleHTML(module);
container.innerHTML += moduleHTML;
});
}
function createModuleHTML(module) {
const content = MODULE_CONTENT[module.id] || {};
return `
<div class="module" id="${module.id}-module">
<button class="btn-back" onclick="switchTo('dashboard')">β Back to Dashboard</button>
<header>
<h1>${module.icon} ${module.title}</h1>
<p class="subtitle">${module.description}</p>
</header>
<div class="tabs">
<button class="tab-btn active" onclick="switchTab(event, '${module.id}-overview')">Overview</button>
<button class="tab-btn" onclick="switchTab(event, '${module.id}-concepts')">Key Concepts</button>
${content.math ? `<button class="tab-btn" onclick="switchTab(event, '${module.id}-math')">Math & Theory</button>` : ''}
${content.applications ? `<button class="tab-btn" onclick="switchTab(event, '${module.id}-applications')">Applications</button>` : ''}
${content.code ? `<button class="tab-btn" onclick="switchTab(event, '${module.id}-code')">Code</button>` : ''}
</div>
<div id="${module.id}-overview" class="tab active">
<div class="section">
<h2>π Overview</h2>
${content.overview || '<p>Content in development.</p>'}
</div>
</div>
<div id="${module.id}-concepts" class="tab">
<div class="section">
<h2>π― Key Concepts</h2>
${content.concepts || '<p>Content in development.</p>'}
</div>
</div>
${content.math ? `
<div id="${module.id}-math" class="tab">
<div class="section">
<h2>π Math & Theory</h2>
${content.math}
</div>
</div>` : ''}
${content.applications ? `
<div id="${module.id}-applications" class="tab">
<div class="section">
<h2>π Applications</h2>
${content.applications}
</div>
</div>` : ''}
${content.code ? `
<div id="${module.id}-code" class="tab">
<div class="section">
<h2>π Implementation</h2>
${content.code}
</div>
</div>` : ''}
</div>
`;
}
function switchTo(target) {
document.querySelectorAll('.dashboard, .module').forEach(el => {
el.classList.remove('active');
});
const elem = document.getElementById(target);
if (elem) {
elem.classList.add('active');
window.scrollTo(0, 0);
}
}
function switchTab(e, tabId) {
const module = e.target.closest('.module');
if (!module) return;
module.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));
module.querySelectorAll('.tab-btn').forEach(b => b.classList.remove('active'));
const tab = document.getElementById(tabId);
if (tab) tab.classList.add('active');
e.target.classList.add('active');
if (window.MathJax && window.MathJax.typesetPromise) {
window.MathJax.typesetPromise([tab]).catch(function (err) { console.log('MathJax typeset:', err); });
}
}
// Initialize application
initDashboard();
</script>
<footer class="disclaimer">
<p><strong>Disclaimer:</strong> This content is an independent educational synthesis based on public research papers (e.g., "Attention Is All You Need", "Chinchilla Scaling Laws") and open-source materials. It is not affiliated with, endorsed by, or sponsored by any university or academic institution. Branding is used for informational purposes only. Β© 2025 AI Engineering Masterclass.</p>
</footer>
</body>
</html>
|