Skip to content

LLM Foundations

Master the core concepts that power modern Large Language Models. This module provides the technical foundation needed to understand, evaluate, and optimize LLMs in production systems.

Learning Objectives

By completing this module, you will be able to:

  • Explain the complete inference pipeline from text input to token generation, including the role of tokenization, embeddings, and sampling strategies
  • Analyze scaling laws and predict model performance based on compute budget, parameter count, and training data
  • Compare model architectures across major families (GPT, Claude, Llama, Gemini) and articulate their trade-offs
  • Optimize inference performance using techniques like KV-caching, quantization, and speculative decoding
  • Design context-aware systems that maximize information utilization within context windows

Module Overview

Modules

ModuleDescriptionKey TopicsEst. Time
How LLMs WorkThe inference pipeline from input to outputLogits, softmax, sampling strategies45 min
Tokenization Deep DiveHow text becomes numbersBPE, SentencePiece, vocabulary design40 min
Scaling LawsThe science of model sizingChinchilla, compute-optimal training35 min
Model FamiliesComparing major LLM architecturesGPT, Claude, Llama, Mistral, Gemini50 min
Context & MemoryWorking with long contextsLost-in-the-middle, needle-in-haystack40 min
Inference OptimizationMaking LLMs fast and efficientKV-cache, quantization, speculative decoding55 min

Prerequisites

Before diving into this module, ensure you understand:

  • Transformer Architecture - Self-attention, positional encodings, layer normalization
  • Neural Network Fundamentals - Backpropagation, gradient descent, loss functions
  • Linear Algebra - Matrix operations, softmax, probability distributions
  • Python - Comfortable with NumPy, PyTorch basics

Interview Focus Areas

Interview Tip

LLM foundations questions typically fall into three categories:

  1. Conceptual Understanding - "Explain how temperature affects generation"
  2. System Design - "Design an inference pipeline for 10K QPS"
  3. Trade-off Analysis - "When would you choose smaller models?"

This module covers all three with practical examples and code.

Quick Reference

Key Metrics to Know

MetricFormulaTypical Values
Perplexitye1Nlogp(xi)10-30 for good models
FLOPS/token2×N (forward)~200B for 100B model
Memory (fp16)2×N bytes~200GB for 100B model
Context lengthArchitecture dependent4K-200K tokens

Common Interview Questions Preview

  1. Why do LLMs sometimes repeat themselves? (See: Sampling Strategies)
  2. How does BPE handle unknown words? (See: Tokenization)
  3. Why is the KV-cache necessary? (See: Inference Optimization)

Visualization Resources

This module includes interactive visualizations:

  • BPE merge process animation
  • Sampling strategy comparison charts
  • Scaling law 3D surfaces
  • KV-cache memory growth plots
  • Model family evolution tree
  • Context utilization heatmaps

Summary

TopicCore InsightInterview Relevance
Inference PipelineLLMs are autoregressive - they generate one token at a timeHigh - fundamental understanding
TokenizationSubword tokenization balances vocabulary size and coverageMedium - affects multilingual performance
Scaling LawsMore compute requires balanced parameter/data scalingHigh - system design decisions
Model FamiliesDifferent architectures optimize for different trade-offsMedium - model selection rationale
Context WindowsInformation position affects retrieval qualityHigh - RAG system design
OptimizationMultiple techniques combine for production efficiencyVery High - deployed systems

Sources

  • Vaswani et al. "Attention Is All You Need" (2017)
  • Hoffmann et al. "Training Compute-Optimal Large Language Models" (Chinchilla paper, 2022)
  • Touvron et al. "LLaMA: Open and Efficient Foundation Language Models" (2023)
  • Liu et al. "Lost in the Middle" (2023)
  • Kwon et al. "Efficient Memory Management for Large Language Model Serving with PagedAttention" (2023)