Skip to content
mentoor

How LLMs Work (deep)

For engineers47 skills in order

From tokens and attention to training your own tiny GPT and running open-weight models locally.

Skills on this path

  1. Tokens and tokenizationFor both1. How LLMs workHow text becomes tokens and why tokens decide cost, context limits, speed and odd spelling mistakes110 questions
  2. Next-token predictionFor both2. How LLMs workThe one mechanism behind every LLM, predicting the next token again and again, and the behaviours that follow from itneeds: Tokens and tokenization110 questions
  3. Embeddings and meaningFor both3. How LLMs workText turned into vectors so that similar meanings sit close together, and what that does and does not captureneeds: Tokens and tokenization110 questions
  4. Attention and transformers (intuition)For engineers4. How LLMs workHow a transformer decides which earlier tokens matter, why attention cost grows with context, and how blocks stack into a modelneeds: Next-token prediction110 questions
  5. How pre-training builds a language modelFor both5. How LLMs workHow a model learns from trillions of tokens of text and code, what the data and compute buy, and the questions the data raisesneeds: Next-token prediction110 questions
  6. Post-trainingFor both6. How LLMs workHow instruction tuning, preference tuning and reinforcement learning on checkable tasks turn a raw text predictor into an assistantneeds: How pre-training builds a language model110 questions
  7. The context windowFor both7. How LLMs workEverything the model sees at once, how big windows have become, and why quality drops as context growsneeds: Tokens and tokenization110 questions
  8. Sampling and temperatureFor both8. How LLMs workWhy the same prompt gives different answers, the temperature and top-p knobs, and how to get repeatable or varied output on purposeneeds: Next-token prediction110 questions
  9. Reasoning (thinking) modelsFor both9. How LLMs workModels that spend extra tokens thinking before they answer: when that helps, what it costs, and how to prompt and read themneeds: Post-training110 questions
  10. Multimodal modelsFor both10. How LLMs workHow models read images, PDFs, audio, video and screens, and where their perception still failsneeds: Kinds of generative AI110 questions
  11. Knowledge cutoff and toolsFor everyone11. How LLMs workWhy models miss recent facts, how search and connectors fill the gap, and how to tell memory from a real lookupneeds: How pre-training builds a language model110 questions
  12. How a chat reaches the modelFor both12. How LLMs workRoles, system prompts and chat templates turn a conversation into one token stream that a stateless model reads fresh every turnneeds: Next-token prediction110 questions
  13. How models call toolsFor both13. How LLMs workThe model writes a structured tool request, the app runs it and feeds the result back: the mechanism behind search, code execution and agentsneeds: Next-token prediction110 questions
  14. Inference: how a trained model runsFor both14. How LLMs workParameters, prefill and decode, the KV cache and mixture-of-experts explain why models differ in speed, memory needs and priceneeds: Next-token prediction110 questions
  15. Supervised learningFor engineers15. Machine learning foundationsLearning a mapping from labelled examples: framing features and labels, splitting data, spotting overfitting and fitting a first baselineneeds: Next-token prediction110 questions
  16. Neural networksFor engineers16. Machine learning foundationsHow layers of weighted sums and nonlinear activations learn features, how backpropagation trains them and how big networks are kept from memorizingneeds: Supervised learning110 questions
  17. Gradient descentFor engineers17. Machine learning foundationsHow models learn by stepping downhill on a loss: loss functions, learning rates and schedules, optimizers such as AdamW and reading training curvesneeds: Supervised learning110 questions
  18. Math intuition for AIFor engineers18. Machine learning foundationsThe vectors, matrices, probability, logarithms and derivatives behind models, read as pictures and code rather than proofsneeds: Supervised learning110 questions
  19. PyTorch basicsFor engineers19. Machine learning foundationsTensors, autograd, nn.Module and DataLoader, a complete training loop, and debugging shapes, devices and NaN losses, including in AI-written codeneeds: Neural networks110 questions
  20. Classic ML that still winsFor engineers20. Machine learning foundationsGradient-boosted trees, regularized linear models, clustering and feature engineering that beat LLMs on tabular data, cost and explainabilityneeds: Supervised learning110 questions
  21. ML metricsFor engineers21. Machine learning foundationsPrecision, recall, F1, ROC and PR curves, calibration and regression errors, chosen to match the decision and compared honestlyneeds: Supervised learning110 questions
  22. Data for MLFor engineers22. Machine learning foundationsCollecting, labelling, splitting, balancing and documenting training data, and the leakage and bias that quietly ruin modelsneeds: Supervised learning110 questions
  23. Deep learning architecturesFor engineers23. Machine learning foundationsConvolutional, recurrent, transformer and diffusion architectures, the data each one suits, and reusing pretrained models through transfer learningneeds: Neural networks110 questions
  24. ML models in productionFor engineers24. Machine learning foundationsShipping a trained model: reproducible experiments, batch and real-time serving, drift monitoring, safe retraining and model cardsneeds: ML metrics110 questions
  25. Combining LLMs with classic MLFor engineers25. Machine learning foundationsEmbeddings as features, LLM-made labels, small-model-first cascades and reviewing agent-written ML code: the hybrid toolkit engineers use todayneeds: Classic ML that still wins110 questions
  26. Build a tiny GPTFor engineers26. Transformers, training and fine-tuningWrite a small character-level GPT in PyTorch, from tokenizer and causal self-attention to a training loop and sampling, to see what every LLM does insideneeds: Attention and transformers (intuition)110 questions
  27. Tokenizers (BPE)For engineers27. Transformers, training and fine-tuningHow byte-pair encoding builds a vocabulary, how real tokenizers are trained and configured, and how tokenizer choices surface as model bugsneeds: Build a tiny GPT110 questions
  28. When to fine-tune a modelFor engineers28. Transformers, training and fine-tuningDeciding between prompting, retrieval, hosted tuning and open-weight fine-tuning with evidence, cost and long-term maintenance in viewneeds: Post-training110 questions
  29. LoRA and PEFTFor engineers29. Transformers, training and fine-tuningParameter-efficient fine-tuning with low-rank adapters and QLoRA: how it works, the open tools, a clean run and serving adaptersneeds: Build a tiny GPT110 questions
  30. Fine-tuning dataFor engineers30. Transformers, training and fine-tuningBuilding supervised fine-tuning datasets: chat formats and loss masking, curation, synthetic data, privacy and licensing, and held-out evaluationneeds: Post-training110 questions
  31. Preference and RL tuningFor engineers31. Transformers, training and fine-tuningRLHF, DPO, AI feedback and reinforcement learning with verifiable rewards, plus the reward hacking each method invites and how to choose among themneeds: When to fine-tune a model110 questions
  32. Distillation and small modelsFor engineers32. Transformers, training and fine-tuningTeaching small, cheap models from large ones with logit or output distillation and reasoning traces, measuring the result and respecting provider termsneeds: When to fine-tune a model110 questions
  33. Scaling laws and computeFor engineers33. Transformers, training and fine-tuningHow loss scales with parameters, data and compute, how to estimate a run's cost, compute-optimal choices, inference-time scaling and reading scaling claims criticallyneeds: How pre-training builds a language model110 questions
  34. Interpretability basicsFor engineers34. Transformers, training and fine-tuningFeatures, superposition, sparse autoencoders, circuits, probes and steering, and what they can and cannot tell us about model behaviour and safetyneeds: Build a tiny GPT110 questions
  35. Modern LLM architecture choicesFor engineers35. Transformers, training and fine-tuningWhat changed between GPT-2 and today's open-weight models: rotary positions, RMSNorm and SwiGLU, grouped-query attention, mixture of experts and hybrid layersneeds: Build a tiny GPT110 questions
  36. Running training jobs on GPUsFor engineers36. Transformers, training and fine-tuningMemory math, mixed precision, gradient accumulation, multi-GPU parallelism, renting compute and keeping a long run healthyneeds: Build a tiny GPT110 questions
  37. Fine-tuning risks and safeguardsFor engineers37. Transformers, training and fine-tuningForgetting, weakened safety, emergent misalignment, poisoned data and memorised secrets in tuned models, and the release checks that catch themneeds: When to fine-tune a model110 questions
  38. Open-weight modelsFor engineers38. Open-weight models and inferenceThe main open-weight families, their base, instruct and reasoning variants, size tiers, licence terms and how to test them on your own tasksneeds: The model landscape110 questions
  39. Running models locallyFor engineers39. Open-weight models and inferenceRunning open models on your own machine with Ollama, LM Studio, llama.cpp and MLX, checking the setup works, and adding vision and speech modelsneeds: Open-weight models110 questions
  40. QuantizationFor engineers40. Open-weight models and inferenceHow lower-precision weights cut memory, the GGUF, GPTQ, AWQ, MLX and native FP8/FP4 formats, choosing a quant level and measuring what it costs in qualityneeds: Open-weight models110 questions
  41. Serving open models at scaleFor engineers41. Open-weight models and inferenceServing open models to many users with vLLM or SGLang: continuous batching, KV cache memory, multi-GPU parallelism and running the endpoint safelyneeds: Open-weight models110 questions
  42. Hardware basicsFor engineers42. Open-weight models and inferenceEstimating memory for a model, why bandwidth sets speed, choosing GPUs, CPUs and Apple silicon, and when renting beats owningneeds: Open-weight models110 questions
  43. On-device and in-browser AIFor both43. Open-weight models and inferenceSmall models built into phones, laptops and browsers: what they can do, how to call them, what stays private and when a feature should go to the cloudneeds: The model landscape110 questions
  44. Using Hugging FaceFor engineers44. Open-weight models and inferenceFinding, downloading and pinning models and datasets on the Hugging Face Hub, reading their cards critically, trying Spaces, and loading files safelyneeds: Open-weight models110 questions
  45. Building apps on local modelsFor engineers45. Open-weight models and inferenceCalling local models from code through OpenAI-compatible APIs, getting valid JSON and tool calls from them, local embeddings and connecting coding toolsneeds: Running models locally110 questions
  46. Private AI on your own computerFor both46. Open-weight models and inferenceUsing a desktop app and an open model offline for sensitive work: when local fits, setting it up, asking about documents, proving nothing leaves and checking weaker answersneeds: Privacy basics for AI110 questions
  47. Measuring and tuning local inference speedFor engineers47. Open-weight models and inferenceMeasuring prompt processing and generation speed, tuning GPU offload, context and KV cache settings, speculative decoding and diagnosing slow runsneeds: Running models locally110 questions