Skip to content

Commit 3b6c6d5

Browse files
committed
feat: add mdbook setup with GitHub Pages deploy
Mirrors the Agents-That-Think-and-Self-Improve mdbook layout: chapters moved into src/ (with a chapters -> src/chapters symlink so existing links keep working), SUMMARY.md, mermaid preprocessor, navy theme, and a Pages workflow that deploys on push to main.
1 parent 9df91b1 commit 3b6c6d5

31 files changed

Lines changed: 2361 additions & 0 deletions

.github/workflows/pages.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Deploy mdBook to GitHub Pages
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: pages
15+
cancel-in-progress: false
16+
17+
env:
18+
MDBOOK_VERSION: 0.4.40
19+
MDBOOK_MERMAID_VERSION: 0.14.0
20+
21+
jobs:
22+
build:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
28+
- name: Install mdBook + mdbook-mermaid
29+
run: |
30+
mkdir -p "$HOME/.local/bin"
31+
curl -sSL "https://github.com/rust-lang/mdBook/releases/download/v${MDBOOK_VERSION}/mdbook-v${MDBOOK_VERSION}-x86_64-unknown-linux-gnu.tar.gz" \
32+
| tar -xz -C "$HOME/.local/bin"
33+
curl -sSL "https://github.com/badboy/mdbook-mermaid/releases/download/v${MDBOOK_MERMAID_VERSION}/mdbook-mermaid-v${MDBOOK_MERMAID_VERSION}-x86_64-unknown-linux-gnu.tar.gz" \
34+
| tar -xz -C "$HOME/.local/bin"
35+
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
36+
37+
- name: Build book
38+
run: mdbook build
39+
40+
- name: Setup Pages
41+
uses: actions/configure-pages@v5
42+
43+
- name: Upload artifact
44+
uses: actions/upload-pages-artifact@v3
45+
with:
46+
path: ./book
47+
48+
deploy:
49+
needs: build
50+
runs-on: ubuntu-latest
51+
environment:
52+
name: github-pages
53+
url: ${{ steps.deployment.outputs.page_url }}
54+
steps:
55+
- name: Deploy to GitHub Pages
56+
id: deployment
57+
uses: actions/deploy-pages@v4

book.toml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
[book]
2+
title = "The Builder's Handbook: LLM Inference from First Principles"
3+
authors = ["TBH Books"]
4+
description = "Learn how LLM inference works at scale — by building one from scratch."
5+
language = "en"
6+
multilingual = false
7+
src = "src"
8+
9+
[output.html]
10+
default-theme = "navy"
11+
preferred-dark-theme = "navy"
12+
git-repository-url = "https://github.com/tbhbooks/LLM-Inference-from-First-Principles"
13+
edit-url-template = "https://github.com/tbhbooks/LLM-Inference-from-First-Principles/edit/main/{path}"
14+
site-url = "/LLM-Inference-from-First-Principles/"
15+
no-section-label = false
16+
smart-punctuation = true
17+
additional-js = ["mermaid.min.js", "mermaid-init.js"]
18+
19+
[output.html.fold]
20+
enable = true
21+
level = 1
22+
23+
[output.html.search]
24+
enable = true
25+
limit-results = 30
26+
use-boolean-and = true
27+
boost-title = 2
28+
boost-hierarchy = 1
29+
boost-paragraph = 1
30+
expand = true
31+
heading-split-level = 3
32+
33+
[preprocessor]
34+
35+
[preprocessor.mermaid]
36+
command = "mdbook-mermaid"

chapters

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
src/chapters

mermaid-init.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
(() => {
2+
const darkThemes = ['ayu', 'navy', 'coal'];
3+
const lightThemes = ['light', 'rust'];
4+
5+
const classList = document.getElementsByTagName('html')[0].classList;
6+
7+
let lastThemeWasLight = true;
8+
for (const cssClass of classList) {
9+
if (darkThemes.includes(cssClass)) {
10+
lastThemeWasLight = false;
11+
break;
12+
}
13+
}
14+
15+
const theme = lastThemeWasLight ? 'default' : 'dark';
16+
mermaid.initialize({ startOnLoad: true, theme });
17+
18+
// Simplest way to make mermaid re-render the diagrams in the new theme is via refreshing the page
19+
20+
for (const darkTheme of darkThemes) {
21+
document.getElementById(darkTheme).addEventListener('click', () => {
22+
if (lastThemeWasLight) {
23+
window.location.reload();
24+
}
25+
});
26+
}
27+
28+
for (const lightTheme of lightThemes) {
29+
document.getElementById(lightTheme).addEventListener('click', () => {
30+
if (!lastThemeWasLight) {
31+
window.location.reload();
32+
}
33+
});
34+
}
35+
})();

mermaid.min.js

Lines changed: 2186 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../README.md

src/SUMMARY.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Summary
2+
3+
[Introduction](README.md)
4+
[Preface](chapters/preface.md)
5+
6+
# Getting Started
7+
8+
- [Chapter 0: Setup](chapters/ch00-setup.md)
9+
10+
# Part I: Foundations
11+
12+
- [Chapter 1: The LLM Inference Problem](chapters/ch01-the-llm-inference-problem.md)
13+
- [Chapter 2: vLLM Architecture Overview](chapters/ch02-vllm-architecture-overview.md)
14+
- [Chapter 3: Setting Up the Project](chapters/ch03-setting-up-the-project.md)
15+
16+
# Part II: MVP — Single-Request Inference
17+
18+
- [Chapter 4: GPT-2 from Scratch](chapters/ch04-gpt2-from-scratch.md)
19+
- [Chapter 5: The Building Blocks](chapters/ch05-the-building-blocks.md)
20+
- [Chapter 6: Where the Model Learns to Look Back](chapters/ch06-where-the-model-learns-to-look-back.md)
21+
- [Chapter 7: The Skeleton Speaks](chapters/ch07-the-skeleton-speaks.md)
22+
- [Chapter 8: Fit and Finish](chapters/ch08-fit-and-finish.md)
23+
24+
# Part III: Core vLLM — Memory & Scheduling
25+
26+
- [Chapter 9: The Memory Problem](chapters/ch09-the-memory-problem.md)
27+
- [Chapter 10: Paged Attention](chapters/ch10-paged-attention.md)
28+
- [Chapter 11: Continuous Batching](chapters/ch11-continuous-batching.md)
29+
- [Chapter 12: The Scheduler](chapters/ch12-the-scheduler.md)
30+
- [Chapter 13: The Engine Loop](chapters/ch13-the-engine-loop.md)
31+
32+
# Part IV: Production
33+
34+
- [Chapter 14: Sampling Strategies](chapters/ch14-sampling-strategies.md)
35+
- [Chapter 15: Building the API Server](chapters/ch15-building-the-api-server.md)
36+
- [Chapter 16: Prefix Caching](chapters/ch16-prefix-caching.md)
37+
- [Chapter 17: Speculative Decoding](chapters/ch17-speculative-decoding.md)
38+
- [Chapter 18: Structured Output](chapters/ch18-structured-output.md)
39+
- [Chapter 19: Parallelism](chapters/ch19-parallelism.md)
40+
41+
# Part V: Further
42+
43+
- [Chapter 20: Where to Go from Here](chapters/ch20-where-to-go-from-here.md)
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)