-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathindex.html
More file actions
563 lines (546 loc) · 26.6 KB
/
index.html
File metadata and controls
563 lines (546 loc) · 26.6 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>LLM Training Lifecycle</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="header-section" class="container" style="margin-top:2.5rem;"></div>
<div id="summary-section" class="container" style="margin-top:2.5rem;"></div>
<div id="timeline-section" class="container" style="margin-top:2.5rem;"></div>
<div id="phases-section" class="container" style="margin-top:2.5rem;"></div>
<div id="book-promo-section" class="container" style="margin-top:2.5rem;"></div>
<script src="app_1.js"></script>
<script>
// Global variable to hold configuration data
let LLM_LIFECYCLE_CONFIG = {};
// Function to load configuration from external JSON file (works on GitHub Pages/Jekyll)
async function loadConfiguration() {
try {
// Use relative path for GitHub Pages compatibility
const response = await fetch('llm-lifecycle.json');
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
LLM_LIFECYCLE_CONFIG = await response.json();
console.log('Configuration loaded from llm-lifecycle.json');
} catch (error) {
console.error('Error loading configuration:', error);
// Fallback configuration in case external file fails to load
LLM_LIFECYCLE_CONFIG = {
header: {
title: "Large Language Model Training Lifecycle",
subtitle: "Complete overview of modern LLM training methods and approaches (2025)",
themeToggle: {
text: "🌓 Toggle Theme",
id: "themeToggle"
}
},
summary: {
title: "📊 Training Pipeline Overview",
stages: []
},
phases: {
title: "<br/>🔍 Detailed Training Phases",
phases: []
},
timeline: {
title: "📅 Evolution Timeline",
items: []
}
};
console.log('Using fallback configuration');
}
}
// Render Functions
function renderHeader() {
const headerSection = document.getElementById('header-section');
const config = LLM_LIFECYCLE_CONFIG.header;
headerSection.innerHTML = `
<div class="header-flex-row">
<div class="header-title-group">
<h1 class="gradient-title">${config.title}</h1>
<p class="subtitle">${config.subtitle}</p>
</div>
<div class="header-actions" style="display:flex;align-items:center;gap:1.2rem;">
<a href="https://raghavbali.github.io" class="website-link" target="_blank" rel="noopener" title="raghavbali.github.io" style="font-weight:500;display:inline-flex;align-items:center;justify-content:center;background:var(--color-surface);border-radius:8px;padding:0.5em 0.8em;"><span style="font-size:1.3em;">🌐</span></a>
<a href="https://github.com/raghavbali/mastering_llms_workshop" class="github-link" target="_blank" rel="noopener" title="GitHub" style="display:inline-flex;align-items:center;justify-content:center;background:var(--color-surface);border-radius:8px;padding:0.5em 0.8em;"><img src="https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png" alt="GitHub" style="width:24px;height:24px;vertical-align:middle;"/></a>
<label class="theme-switch" style="margin-left:0.5em;">
<input type="checkbox" id="${config.themeToggle.id}" />
<span class="slider"></span>
</label>
</div>
</div>
`;
}
function renderSummary() {
const summarySection = document.getElementById('summary-section');
const config = LLM_LIFECYCLE_CONFIG.summary;
// Use a common Amazon URL from config or fallback
const amazonUrl = "https://www.amazon.com/Generative-Python-PyTorch-Hands-cutting-edge/dp/B0D9QBYYBQ";
let stagesHTML = '';
config.stages.forEach((stage, index) => {
if (stage.type === 'branch-group') {
stagesHTML += `
<div class="summary-branches">
<div class="branch-group">
${stage.stages.map(s => {
// For Phase 2 branches, force data-stage to phase2-path-a, phase2-path-b, phase2-alignment
let branchDataStage = s.id;
if (s.id) {
const idLower = s.id.toLowerCase();
if (idLower === 'path-a') branchDataStage = 'phase2-path-a';
else if (idLower === 'path-b') branchDataStage = 'phase2-path-b';
else if (idLower.includes('alignment')) branchDataStage = 'phase2-alignment';
}
return `
<div class="summary-stage" data-stage="${branchDataStage}">
<div class="summary-box">
<span class="summary-icon">${s.icon}</span>
<span class="summary-text">${s.text}</span>
</div>
</div>
`;
}).join('')}
</div>
</div>
`;
} else {
// For main phase sections, keep as is
stagesHTML += `
<div class="summary-stage" data-stage="${stage.id}">
<div class="summary-box ${stage.special || ''}">
<span class="summary-icon">${stage.icon}</span>
<span class="summary-text">${stage.text}</span>
</div>
</div>
`;
}
if (index < config.stages.length - 1) {
stagesHTML += '<div class="summary-arrow">→</div>';
}
});
summarySection.innerHTML = `
<h2 class="section-title">${config.title}</h2>
<div class="summary-diagram">
${stagesHTML}
</div>
`;
// Add the promo row just below the overview box, not inside it
const promoRow = document.createElement('div');
promoRow.className = 'overview-promo-row';
promoRow.innerHTML = `
<div class="overview-promo-inner">
<span class="overview-promo-text">
<span style="font-size:1.3em;">❤️</span>
<span>For more deeper insights, check out my very approachable new book on Generative AI</span>
</span>
<span class="overview-promo-actions">
<a href="${amazonUrl}" target="_blank" rel="noopener" class="overview-promo-btn overview-promo-btn--amazon">Buy on Amazon</a>
<a href="#book-promo-section" class="overview-promo-btn overview-promo-btn--outline">More Details</a>
</span>
</div>
`;
summarySection.parentNode.insertBefore(promoRow, summarySection.nextSibling);
}
function renderInfoRows(info) {
// Add target and rel to all anchor tags in the value, and add nbsanity/nbviewer badges for notebook links
function patchLinks(html) {
// Add target and rel
let patched = html.replace(/<a\s/gi, '<a target="_blank" rel="noopener" ');
// Prefix notebook links with 'docs/' if not already present
patched = patched.replace(/<a ([^>]*?)href=["'](?!https?:|\/|docs\/)([^"'>]+\.ipynb)["']/gi, '<a $1href="docs/$2"');
// Add nbsanity and nbviewer badges after notebook links
patched = patched.replace(/<a ([^>]*?)href=["']([^"'>]+\.ipynb)["'][^>]*>(.*?)<\/a>/gi, function(match, attrs, href, text) {
// Remove leading './' or 'docs/' for GitHub path
let githubPath = href.replace(/^\.\/?|^docs\//, '');
// Compose GitHub repo path (assume main branch)
const githubBase = 'raghavbali/mastering_llms_workshop/blob/main/docs/';
// GitHub badge
const github = `<a target="_blank" rel="noopener" href="https://github.com/${githubBase}${githubPath}"><img src='https://img.shields.io/badge/View%20on-GitHub-black?logo=github' alt='View on GitHub' style='height:1em;vertical-align:middle;'/></a>`;
// nbviewer
const nbviewer = `<a target="_blank" rel="noopener" href="https://nbviewer.org/github/${githubBase}${githubPath}"><img src='https://img.shields.io/badge/Open%20in-nbviewer-orange?logo=jupyter' alt='Open in nbviewer' style='height:1em;vertical-align:middle;'/></a>`;
// Original link + badges
return `${match} ${github} ${nbviewer}`;
});
return patched;
}
return info.map(item => `
<div class="info-row">
<span class="info-label">${item.label}</span>
<span class="info-value">${patchLinks(item.value)}</span>
</div>
`).join('');
}
function renderAlignmentMethods(methods) {
const tabsHTML = methods.map(method => `
<button class="method-tab ${method.active ? 'active' : ''}" data-method="${method.id}">${method.name}</button>
`).join('');
const panelsHTML = methods.map(method => `
<div class="method-panel ${method.active ? 'active' : ''}" id="${method.id}">
<div class="method-header">
<h6 class="method-name">${method.fullName}</h6>
<div class="method-badges">
<span class="year-badge ${method.yearClass || ''}">${method.year}</span>
<span class="complexity-badge ${method.complexity}">${method.complexityText}</span>
</div>
</div>
<div class="branch-card ${method.class}">
<div class="phase-info">
${renderInfoRows(method.info)}
</div>
</div>
</div>
`).join('');
return `
<div class="alignment-methods">
<div class="method-tabs">
${tabsHTML}
</div>
<div class="method-content">
${panelsHTML}
</div>
</div>
`;
}
function renderPhases() {
const phasesSection = document.getElementById('phases-section');
const config = LLM_LIFECYCLE_CONFIG.phases;
let phasesHTML = `<h2 class="section-title">${config.title}</h2>`;
config.phases.forEach(phase => {
const isCollapsed = phase.collapsed !== undefined ? phase.collapsed : false;
const collapseId = `collapse-${phase.id}`;
// For Phase 2, add unique IDs to each branch for linking
let branchIdPrefix = '';
if (phase.id === 'phase2') branchIdPrefix = 'phase2-';
phasesHTML += `
<div id="${phase.id}" class="phase-container">
<div class="phase-header collapsible-header" onclick="toggleCollapse('${collapseId}')">
<div class="phase-header-content">
<h3 class="phase-title">${phase.title}</h3>
<span class="phase-badge ${phase.badge.class}">${phase.badge.text}</span>
</div>
<span class="collapse-toggle" id="toggle-${collapseId}">${isCollapsed ? '▶' : '▼'}</span>
</div>
<div class="phase-content collapsible-content ${isCollapsed ? 'collapsed' : ''}" id="${collapseId}">
`;
if (phase.description) {
phasesHTML += `
<div class="branching-description">
<p>${phase.description}</p>
</div>
`;
}
if (phase.branches) {
// --- MODIFIED: Make branches stack vertically and full width ---
phasesHTML += '<div class="branches-container vertical">';
phase.branches.forEach(branch => {
// Add unique id for each branch in phase2 for linking
let branchId = '';
if (branchIdPrefix) {
// Force branchId to phase2-path-a, phase2-path-b, phase2-alignment for correct linking
const idLower = (branch.id || branch.title || '').toLowerCase();
if (idLower === 'path-a') branchId = 'phase2-path-a';
else if (idLower === 'path-b') branchId = 'phase2-path-b';
else if (idLower.includes('alignment')) branchId = 'phase2-alignment';
else branchId = `${branchIdPrefix}${idLower.replace(/[^a-z0-9]+/g, '-')}`;
}
phasesHTML += `<div class="branch-path"${branchId ? ` id="${branchId}"` : ''}>`;
phasesHTML += `<h4 class="branch-title">${branch.title}</h4>`;
if (branch.info) {
phasesHTML += `
<div class="branch-card ${branch.class}">
<div class="phase-info">
${renderInfoRows(branch.info)}
</div>
</div>
`;
}
if (branch.steps) {
branch.steps.forEach(step => {
phasesHTML += `
<div class="instruction-step">
<h5 class="step-title">${step.title}</h5>
`;
if (step.info) {
phasesHTML += `
<div class="branch-card ${step.class}">
<div class="phase-info">
${renderInfoRows(step.info)}
</div>
</div>
`;
}
if (step.hasMethodTabs && step.methods) {
phasesHTML += renderAlignmentMethods(step.methods);
}
phasesHTML += '</div>';
});
}
phasesHTML += '</div>';
});
phasesHTML += '</div>';
} else if (phase.info) {
phasesHTML += `
<div class="phase-card">
<div class="phase-info">
${renderInfoRows(phase.info)}
</div>
</div>
`;
}
phasesHTML += `
</div>
</div>
`;
});
phasesSection.innerHTML = phasesHTML;
}
function renderTimeline() {
const timelineSection = document.getElementById('timeline-section');
const config = LLM_LIFECYCLE_CONFIG.timeline;
const timelineHTML = config.items.map(item => `
<div class="timeline-item">
<div class="timeline-year">${item.year}</div>
<div class="timeline-content">${item.content}</div>
</div>
`).join('');
timelineSection.innerHTML = `
<h2 class="section-title">${config.title}</h2>
<div class="timeline">
${timelineHTML}
</div>
`;
}
function renderBookPromo() {
const promoSection = document.getElementById('book-promo-section');
const amazonUrl = "https://www.amazon.com/Generative-Python-PyTorch-Hands-cutting-edge/dp/B0D9QBYYBQ";
promoSection.innerHTML = `
<div id="book-promo" class="book-promo" style="margin-top:2.5rem;display:flex;align-items:center;gap:2rem;justify-content:center;flex-wrap:wrap;background:var(--color-surface);border-radius:12px;box-shadow:var(--shadow-md);padding:2rem 1.5rem;">
<img src="assets/packt_gai_2.png" alt="Book Cover" style="width:120px;height:auto;border-radius:8px;box-shadow:0 2px 8px rgba(0,0,0,0.08);background:#f5f5f5;object-fit:contain;"/>
<div style="flex:1;min-width:220px;">
<h2 style="margin:0 0 0.5rem 0;font-size:1.5em;">Generative AI with Python and PyTorch, 2nd ed. Edition</h2>
<p style="margin:0 0 1rem 0;font-size:1.1em;">Master GenAI techniques to create images and text using variational autoencoders (VAEs), generative adversarial networks (GANs), LSTMs, and large language models (LLMs). <span style='color:var(--color-primary);font-weight:600;'><br/>Inspire your LLM journey!</span></p>
<div style="display:flex;gap:1rem;align-items:center;flex-wrap:wrap;">
<a href="${amazonUrl}" target="_blank" rel="noopener" style="background:#ff9900;color:#fff;padding:8px 18px;border-radius:6px;font-weight:600;text-decoration:none;box-shadow:0 2px 8px rgba(255,153,0,0.08);">Buy on Amazon</a>
<a href="https://github.com/PacktPublishing/Generative-AI-with-Python-and-PyTorch-Second-Edition" target="_blank" rel="noopener" style="background:#24292f;color:#fff;padding:8px 18px;border-radius:6px;font-weight:600;text-decoration:none;box-shadow:0 2px 8px rgba(36,41,47,0.08);">View on GitHub</a>
</div>
</div>
</div>
`;
}
// Collapse/Expand functionality
function toggleCollapse(elementId) {
const content = document.getElementById(elementId);
const toggle = document.getElementById(`toggle-${elementId}`);
if (content.classList.contains('collapsed')) {
content.classList.remove('collapsed');
toggle.textContent = '▼';
} else {
content.classList.add('collapsed');
toggle.textContent = '▶';
}
}
// Event handlers for interactive elements
function setupEventHandlers() {
// Method tab switching
document.addEventListener('click', function(e) {
if (e.target.classList.contains('method-tab')) {
const methodId = e.target.getAttribute('data-method');
const parentContainer = e.target.closest('.alignment-methods');
parentContainer.querySelectorAll('.method-tab').forEach(tab => tab.classList.remove('active'));
parentContainer.querySelectorAll('.method-panel').forEach(panel => panel.classList.remove('active'));
e.target.classList.add('active');
parentContainer.querySelector(`#${methodId}`).classList.add('active');
}
// Summary stage click: scroll to relevant phase or branch section
const stage = e.target.closest('.summary-stage');
if (stage && stage.dataset.stage) {
let targetId = stage.dataset.stage;
// If it's a phase2 branch, scroll to the branch id
if (targetId.startsWith('phase2-')) {
const branchSection = document.getElementById(targetId);
if (branchSection) {
branchSection.scrollIntoView({ behavior: 'smooth', block: 'start' });
return;
}
}
// Otherwise scroll to phase section
const phaseSection = document.getElementById(targetId);
if (phaseSection) {
phaseSection.scrollIntoView({ behavior: 'smooth', block: 'start' });
}
}
});
}
// Initialize the page
async function init() {
// Load configuration first
await loadConfiguration();
// Then render all sections
renderHeader();
renderSummary();
renderTimeline();
renderPhases(); // Move phases before timeline
renderBookPromo();
setupEventHandlers();
// Initialize theme manager after header is rendered
if (window.ThemeManager) {
window.themeManager = new window.ThemeManager();
}
}
// Load the page when DOM is ready
document.addEventListener('DOMContentLoaded', init);
</script>
<style>
/* Additional CSS for collapsible functionality */
.collapsible-header {
cursor: pointer;
display: flex;
justify-content: space-between;
align-items: center;
padding: 1rem;
background: rgba(255, 255, 255, 0.05);
border-radius: 8px;
margin-bottom: 1rem;
transition: background-color 0.2s ease;
}
.collapsible-header:hover {
background: rgba(255, 255, 255, 0.1);
}
.phase-header-content {
display: flex;
align-items: center;
gap: 1rem;
}
.collapse-toggle {
font-size: 1.2rem;
font-weight: bold;
color: #64748b;
transition: transform 0.2s ease;
}
.collapsible-content {
max-height: 5000px;
overflow: hidden;
transition: max-height 0.3s ease, opacity 0.3s ease;
opacity: 1;
}
.collapsible-content.collapsed {
max-height: 0;
opacity: 0;
margin-bottom: 0;
}
.phase-header {
margin-bottom: 0;
}
.phase-title {
margin: 0;
}
/* --- Custom header flex for theme toggle --- */
.header-flex-row {
display: flex;
justify-content: space-between;
align-items: flex-start;
gap: 2rem;
flex-wrap: wrap;
}
.header-title-group {
flex: 1 1 auto;
min-width: 250px;
}
.theme-toggle-btn {
align-self: flex-start;
margin-top: 0.5rem;
margin-left: auto;
/* visually separate from title */
}
/* --- Add gap between summary and timeline --- */
.summary-section {
margin-bottom: 3.5rem !important;
}
.timeline-section {
margin-top: 3.5rem !important;
}
/* --- Theme switch toggle styles --- */
.theme-switch {
margin-left: auto;
margin-top: 0.5rem;
}
.overview-promo-row {
width: 100%;
display: flex;
justify-content: center;
margin: 1.5rem 0 0 0;
}
.overview-promo-inner {
max-width: 1100px;
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
gap: 1.5rem;
flex-wrap: wrap;
padding: 0 2.5rem;
}
.overview-promo-text {
font-size: 1.1em;
display: flex;
align-items: center;
gap: 0.5em;
}
.overview-promo-actions {
display: flex;
gap: 1rem;
flex-wrap: wrap;
}
.overview-promo-btn {
font-weight: 600;
text-decoration: none;
border-radius: 6px;
padding: 8px 18px;
font-size: 1em;
box-shadow: 0 2px 8px rgba(255,153,0,0.08);
border: none;
transition: background 0.15s, color 0.15s, border 0.15s;
display: inline-block;
}
.overview-promo-btn--amazon {
background: #ff9900;
color: #fff;
}
.overview-promo-btn--outline {
background: transparent;
color: var(--color-primary);
border: 2px solid var(--color-primary);
box-shadow: none;
}
/* --- CSS: Make .branches-container vertical and .branch-path full width --- */
.branches-container.vertical {
display: flex;
flex-direction: column;
gap: 2rem;
}
.branch-path {
width: 100%;
margin-bottom: 0;
}
@media (max-width: 700px) {
.overview-promo-inner {
padding: 0 0.5rem;
flex-direction: column;
align-items: flex-start;
gap: 1rem;
}
.overview-promo-actions {
width: 100%;
justify-content: flex-start;
}
.branches-container.vertical {
gap: 1.2rem;
}
}
</style>
</body>
</html>