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

Machine Learning Foundations for LLM Work

Free · sign in to start and track progress

1 · Learning from data

  • 1Problems, data and baselines
  • 2Train, validation, test and leakage
  • 3Loss functions and gradient descent

2 · Classifiers and generalisation

  • 4Logistic regression, step by step
  • 5Metrics, thresholds and calibration
  • 6Overfitting, regularisation and cross-validation

3 · The maths the later courses assume

  • 7Probability for evaluation
  • 8Standard errors, intervals and paired tests
  • 9Vectors, dot products and embeddings

    Exercise answers

    • Answer: Build a nearest-neighbour duplicate finder
    • Answer: A single attention head on four tokens
  • 10A small neural network from scratch
CapstoneTicket triage you can defendReference implementation

Module 3 · The maths the later courses assume · Lesson 9

Vectors, dot products and embeddings

The linear algebra the LLM courses assume, done by hand on ticket vectors, then with TF-IDF and a small CPU embedding model to find a ticket's nearest neighbours.

80 min 2 videos 3 exercises 7-question quiz Answers
Setup for the exercises:Install Claude CodePython with uvThe Hollowbrook ticket dataRun Hugging Face models on CPU

By the end of this lesson you can

  • Compute a dot product, a vector norm and a cosine similarity by hand for 3-dimensional vectors and say what each measures
  • Multiply a 2×3 by a 3×2 matrix by hand, then explain the shapes and the meaning of every entry in X @ W for a batch of inputs and a weight matrix
  • Build TF-IDF vectors and small CPU sentence embeddings for tickets, find the k nearest neighbours by cosine, and measure how often they share the category
  • Explain what a sentence-embedding model is trained to do and why nearest-neighbour search at scale needs approximate methods
  • Relate a query–key dot product in attention to the similarity scores computed here

On this page

  • A ticket as a vector
  • Dot product, length and cosine
  • Matrix multiplication is many dot products at once
  • From counts to TF-IDF to embeddings
  • Nearest neighbours
  • The bridge to attention
  • Connections
  • Summary
  • Sources & further reading
  • Quiz

In this lesson

  1. 01A ticket as a vector
  2. 02Dot product, length and cosine
  3. 03Matrix multiplication is many dot products at once
  4. 04From counts to TF-IDF to embeddings
  5. 05Nearest neighbours
  6. 06The bridge to attention
  7. 07Connections
  8. 08Summary

Sources & further reading

  • Efficient Estimation of Word Representations in Vector SpacePaper · Mikolov, Chen, Corrado, Dean · 2013The word2vec paper that made dense embeddings standard. Section 1 for the motivation, and the analogy results for what directions in the space can mean.
  • Sentence-BERT: Sentence Embeddings using Siamese BERT-NetworksPaper · Reimers, Gurevych · 2019How a sentence-embedding model is trained so that cosine similarity between its outputs means something; section 3 is the training objective. The MiniLM model in the exercise is a descendant.
  • MTEB: Massive Text Embedding BenchmarkPaper · Muennighoff, Tazi, Magne, Reimers · 2022How embedding models are compared across retrieval, clustering and similarity tasks; the leaderboard it defines is where you pick a model.
  • Interpretable Text Embeddings and Text Similarity Explanation: A SurveyPaper · Opitz, Möller, Michail, Padó, Clematide · 2025A recent survey of what a high cosine between two texts does and does not tell you, for when a neighbour looks wrong.
  • Speech and Language Processing, chapter 5: EmbeddingsBook · Jurafsky, Martin · 2026TF-IDF, cosine similarity and word2vec in one chapter, with the same worked-by-hand style as this lesson. Read 5.1 to 5.5 before the exercises.
  • Deep Learning, chapter 2: Linear AlgebraBook · Goodfellow, Bengio, Courville · 2016Sections 2.1 to 2.5, vectors, matrices, matrix products and norms, in the notation the LLM courses use.
  • NumPy: the absolute basics for beginnersDocs · NumPyArrays, `@`, broadcasting and `np.linalg.norm`, which is all the numpy this lesson's code uses.
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.

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