Generative AI · Intermediate level

Intermediate level · Module 3 of 10 · 10 guided hours

Tokens, Embeddings and Semantic Search

Counting tokens for cost and limits, how embedding models turn text into vectors, cosine similarity, and building semantic search over a small document set.

Learning objectives

  • Count tokens and estimate their cost
  • Generate embeddings and compare them
  • Build semantic search over documents

Topics

  • tokenisers and token counts
  • token limits and budgets
  • embedding models
  • cosine similarity
  • semantic vs keyword search
  • multilingual embeddings and limits

Lessons

  1. Lesson 1 Tokens, Limits and Budgets

    Learners count tokens with tokenisers, compare languages and estimate how prompts and documents fit into context windows and budgets.

    tokenizertoken countcontext windowlanguage differencesbudget

  2. Lesson 2 Embeddings and Cosine Similarity

    Learners create sentence embeddings with Sentence Transformers and compare meanings with cosine similarity.

    embedding vectorSentence Transformerscosine similaritynormalisationsemantic similarity

  3. Lesson 3 Semantic Search over Documents

    Learners build a search function that embeds documents and queries and returns the top matches, and compare it with keyword search.

    document embeddingsquery embeddingtop-k resultskeyword (TF-IDF) searchhybrid search

Practical activity

Produce a token budget and build semantic, keyword and hybrid search over the project collection, with a top-3 hit comparison.

Expected outcomes

  • Practical command of tokens and embeddings
  • Working semantic search

Assessment

Search notebook and comparison (70%) and token budget (30%).

Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.