Behind the Secrets of LLMslab

Session 01 · the lab kit

Behind the Secrets of LLMs

A language model is often called a black box. In this lab you open it. You log in to a supercomputer, train a tiny GPT from scratch, and take real language models apart, one small script at a time.

Course at TU Dresden (ScaDS.AI). Everything on this page is in one GitHub repository.

text in

TheElbeflowsthrough
token + position embedding
N BLOCKSself-attentionMLP
logits → softmax
?black box

next token

Dresden43%
Hamburg17%
Germany12%
the10%
Saxony7%

Text goes in, a probability for every possible next token comes out. The numbers here are only an illustration.

5clusters at ZIH, 2 of them full of GPUs
7lab exercises, from “hello” to a real LLM
3notebooks that build a language model from scratch
0.8 Mparameters in the GPT you train yourself

The running example

Meet Marie and Martin#

Two students at TU Dresden want a language model on a university GPU to answer one question: What is the capital of Saxony, and what is it famous for? They go through all seven exercises, and one of them gets it wrong first every time. Each scene shows what does not work, why, and what works.

One sentence travels with them through the whole site: The Elbe flows through …

Follow the story

sometimes too careful

Marie

Sees a job waiting in the queue, decides it is broken, and submits it three more times.

sometimes too fast

Martin

Deletes the line that asks for a GPU because it looks like a comment, and wonders where the GPU went.

Quick start

Three ways in#

Pick where you want to work. The cluster needs the university network or the VPN, and your ZIH login.

Log in to a GPU cluster and get the lab kit. Then continue with Setup.

on your computer, then on the login nodeshell
ssh <zih-login>@login1.alpha.hpc.tu-dresden.de
git clone https://github.com/himanshubeniwal/behind-llms-lab.git
cd behind-llms-lab/hpc_lab

The repository

What is in the kit#

Clone it, download it as a .zip, or read every file right here on the site.

hpc_lab/
  00_setup/        workspace, modules and a venv in one script
  01_hello/        your first batch job
  02_cancel/       squeue, scontrol, scancel, sacct
  03_gpu/          ask for a GPU and measure it
  04_tinygpt/      train a tiny GPT as a batch job
  05_sweep/        a learning-rate sweep with a job array
  06_hf_generate/  run a pretrained LLM on a GPU node
notebooks/
  4 - Tokens and Bigram LM.ipynb
  5 - Attention and TinyGPT.ipynb
  6 - Pretrained LLMs for Text Analysis.ipynb
website/           the source of this site (python website/build.py)