Week 8

Learning objectives

Upon finishing this learning module, you should be able to:

  • Describe how embeddings are used to represent data for machine learning
  • Identify the major components of a transformer-based language model like GPT2
  • Write code that uses lists store data, loops through lists, and manipulates them

Class Schedule

First Class Meeting

  • Algorithmic Of the Week - Language Models
  • Programming - Ch 26

Independent:

  • Algorithm of the Week Reading
  • Work on programming

Second Class Meeting

  • Midterm
  • Programming - Ch 27

Independent:

  • Work on programming
  • Work on the Impacts of Computing assignment

Midterm

Take the midterm at the location you identified in the survey last week. The exam is expected to take an hour. No resources are allowed.

Make sure to do mixed review quizzes 3 and 4 before the midterm!

Note that there are no readings from the Computation section of Welcome to CS this week.

Programming

Do Chapter 26 and 27 from the Programming chapters in Welcome To CS.

Make sure you are logged into the book so your work is saved and you get credit. The surest way to make sure you are logged in is to start the programming assignment by clicking on the button in the corresponding assignment in Elearn.

Algorithmic Of the Week: Language Models

This week we are exploring how modern generative language models like ChatGPT or Claude work. This reading is NOT in the Nine Algorithms book. Instead, first read the short chapter on Embeddings and then the longer one on Transformer based Language Models.

Exploring Embeddings

Check out this interactive word2vec exploration. There are three parts you might want to experiment with:

  • Raw Data - Shows you 300 dimension embeddings for words
  • Word Similarity - Enter a word and see what words are most similar to it as measured by the cosine similarity of their embeddings
  • Word Arithmetic - Allows you to try out operations like "king - man + woman = queen" and see what the model produces

Exploring GPT2

The transformer explainer has an interactive demonstration of GPT2. You can use it to explore how the model does calculations to generate the next word in a sequence. It has a built in walk through that explains the parts.

Try entering your own prompt in the Examples text box at the top and see what the model generates. Play with the temperature and top-k settings to see how they affect the output.

Videos

This optional video has a high level overview of the concepts in the embedding chapter:


And this one has a high level overview of transformer based language models:


Impacts of Computing

This week's assignment will ask you to continue the work you started in week 7 on the topic of Automatic Vehicle Recognition. See the Canvas assignment in this week's module for specific instructions.


Optional Extras

If you are interested in learning more about deep learning you can check out the 3blue1brown series on neural networks.