AI & ML Quick Path

Part 5: Large language models

How large language models work, how to design one, how to train a small one on your laptop and scale it to big hardware, how to fine-tune and run models locally, and how to evaluate them.

8 lessonsAbout 11 hours of study (estimate)0 of 8 completed in this browser

Key terms in this part (20)

  1. UnderstandHow LLMs work, tokens, sampling
  2. DesignSize, context and vocabulary
  3. TrainA small model on your laptop
  4. ScaleThe same code on GPUs and many machines
  5. Adapt and runFine-tune, run locally, evaluate

Realistic scope. You will train small models that show every mechanism. Training a modern large model from scratch needs very large datasets, many GPUs and a specialised team; this part teaches the principles so you understand, adapt and run such models.

How LLMs work

  1. How large language models work

    Explain pretraining, next-token prediction, context windows, instruction tuning, open-weight versus hosted models, and why LLMs sometimes make things up.

    Intermediate75 minNeeds: Transformers and attention

  2. Tokens and sampling settings

    Explain how tokenisers split text, why tokens drive cost and limits, and how temperature and top-p change generated text.

    Intermediate60 minNeeds: How large language models work

Design and train

  1. Designing a language model

    Choose tokeniser, vocabulary, width, depth, heads and context length for a model, estimate its size and memory, and plan experiments.

    Advanced75 minNeeds: Tokens and sampling settings, Transformers and attention

  2. Train a small language model on your laptop

    Train a character-level language model end to end on a laptop, read training and validation loss, save and reload checkpoints, and run the same loop as a tiny transformer.

    Advanced2 hNeeds: Designing a language model, Training deep networks well

  3. From laptop to big hardware: scaling training

    Estimate memory for training and inference, and choose the right scaling tools (GPUs, mixed precision, gradient accumulation and checkpointing, data and model parallelism, FSDP) as models grow.

    Expert1.5 hNeeds: Train a small language model on your laptop

Adapt, run and evaluate

  1. Fine-tuning: SFT, LoRA, QLoRA and preference tuning

    Decide between prompting, RAG and fine-tuning, prepare instruction data, and fine-tune an open model with LoRA or QLoRA, then compare it fairly with the base model.

    Advanced1.5 hNeeds: From laptop to big hardware: scaling training, How large language models work

  2. Running language models on your own machine

    Run an open-weight model locally, understand quantization and memory needs, and call the local model from Python and .NET through the same interfaces used for hosted models.

    Intermediate75 minNeeds: How large language models work

  3. Evaluating language models

    Evaluate language models with perplexity, benchmarks and your own task tests, and avoid contamination and misleading comparisons.

    Advanced60 minNeeds: Train a small language model on your laptop