Andrej Karpathy

Building makemore Part 2: MLP

Andrej Karpathy

Summary

The podcast episode focuses on the implementation of a multi-layer perceptron model for character-level language prediction, building upon previous discussions of a bigram language model. The host explains the limitations of using a single character context for predictions, highlighting the exponential growth of possible contexts as more characters are considered. To address this, they introduce a neural network approach based on a well-known paper by Benji et al. from 2003, which proposes embedding words into a lower-dimensional space to improve prediction accuracy.

The episode details the process of creating a dataset from a list of names, constructing input-output pairs for the neural network, and implementing the model using PyTorch. The host emphasizes the importance of embedding layers and discusses how the network learns to generalize by clustering similar characters in the embedding space. The training process is described, including the use of mini-batches for efficiency and the evaluation of the model's performance on training and validation datasets.

As the episode progresses, the host experiments with different hyperparameters, such as the size of the hidden layer and the dimensionality of the embedding space, to optimize the model's performance. They also discuss strategies for determining an appropriate learning rate and the significance of avoiding overfitting by splitting the dataset into training, validation, and test sets. The episode concludes with a demonstration of how to sample from the trained model, showcasing improvements in generating name-like outputs.

More from Andrej Karpathy

See all episodes →