Coders In Hoods
  • Courses
  • Roles
  • Blog
  • Setup

Coders In Hoods AI Academy

Every course is free. Sign in to start, and your progress, quiz scores and bookmarks follow you.

AI Academy

  • Courses
  • Paths
  • Setup guides
  • How we teach

Role roadmaps

  • AI Engineer
  • Forward Deployed Engineer
  • Machine Learning Engineer
  • All roles

Coders In Hoods

  • The agency
  • Coaching for teams
  • Blog
  • LinkedIn
  • X (Twitter)

Contact

codersinhoods@gmail.com

© Coders In Hoods · since 2019

Course overview

LLMs for Engineers

Free · sign in to start and track progress

1 · Inside the transformer

  • 1Tokens and embeddings

    Exercise answers

    • Answer: Implement and stress-test a byte-level BPE tokenizer
    • Answer: Probe embedding geometry
  • 2Attention, step by step
  • 3The transformer block

2 · How models are trained

  • 4Pretraining and scaling laws
  • 5Post-training an assistant

3 · Running models in production

  • 6Sampling and hallucination
  • 7Context windows, KV cache and caching
  • 8Reasoning models and extended thinking
  • 9Choosing and comparing models
CapstoneChoose a model for document extractionReference implementation

Module 1 · Inside the transformer · Lesson 1

Tokens and embeddings

How raw text is chopped into tokens with byte-pair encoding, and how each token becomes a vector the network can compute with.

45 min 2 videos 3 exercises 7-question quiz Answers
Setup for the exercises:Install Claude CodePython with uv

By the end of this lesson you can

  • Run the byte-pair encoding algorithm by hand on a small corpus
  • Explain why models struggle with spelling, arithmetic and some non-English text
  • Describe the embedding matrix and what an embedding lookup actually computes
  • Use cosine similarity to reason about meaning as direction in vector space

On this page

  • Why not just use characters or words?
  • Byte-pair encoding
  • A worked example
  • Real tokenizers add a few refinements
  • Why tokenization explains weird model behaviour
  • What a title register looks like to a model
  • From token IDs to vectors: the embedding matrix
  • Meaning as direction
  • Many more features than dimensions
  • Position: the missing ingredient
  • Going back out: unembedding
  • Summary
  • Sources & further reading
  • Quiz

In this lesson

  1. 01Why not just use characters or words?
  2. 02Byte-pair encoding
  3. 03Why tokenization explains weird model behaviour
  4. 04From token IDs to vectors: the embedding matrix
  5. 05Position: the missing ingredient
  6. 06Going back out: unembedding
  7. 07Summary

Sources & further reading

  • Neural Machine Translation of Rare Words with Subword UnitsPaper · Sennrich, Haddow, Birch · 2016The paper that brought byte-pair encoding from data compression into NLP. Section 3.2 has the whole algorithm in about 20 lines of Python.
  • Efficient Estimation of Word Representations in Vector SpacePaper · Mikolov, Chen, Corrado, Dean · Google · 2013word2vec. The source of the "king − man + woman ≈ queen" result and of the idea that meaning can live in vector geometry.
  • Language Models are Unsupervised Multitask Learners (GPT-2)Lab research · Radford et al. · OpenAI · 2019Section 2.2 explains byte-level BPE, the tokenizer design most modern LLMs descend from.
  • Toy Models of SuperpositionLab research · Elhage et al. · Anthropic · 2022Why a model can store far more features than it has dimensions. Read the introduction for intuition; the rest is optional depth.
  • CS224N: Natural Language Processing with Deep LearningUniversity · StanfordLectures 1–2 cover word vectors in depth. The slides and notes are public.
  • Speech and Language Processing, ch. 6: Vector Semantics and EmbeddingsBook · Jurafsky, Martin · StanfordThe standard textbook treatment of embeddings, cosine similarity and word2vec, free online.
Free · sign in to start

Sign in to keep reading.

Free, no card. We use your account to save progress, quiz scores, bookmarks and occasionally send updates from our team.

  • 7 more sections
  • 3 hands-on exercises
  • A 7-question quiz
  • Progress, quiz scores and bookmarks