In the latest lecture of the Generative AI course, Agha Ali Raza introduces a neural network architecture for next-word prediction using three context words, then transitions into a discussion of Recurrent Neural Networks (RNNs).
The lecture begins by defining a feedforward neural network (FFNN) that takes a fixed window of three previous words as input to predict the next word. This model learns word embeddings and combines them through hidden layers with non-linear activations. Key differences from word2vec are highlighted: whereas word2vec learns embeddings for similarity, this model is optimized for prediction accuracy.
The architecture is detailed step by step, including the input layer, embedding lookup, concatenation, hidden layer with non-linear activation (e.g., tanh or ReLU), and a softmax output layer over the vocabulary. The instructor discusses practical considerations such as freezing vs. fine-tuning pre-trained embeddings, noting that fine-tuning can adapt embeddings to the specific corpus but may overfit with small data.
However, the fixed-context FFNN has limitations: it cannot capture long-range dependencies or variable-length history. This motivates the introduction of RNNs, which maintain a hidden state that carries information across time steps. The lecture conceptually explains how RNNs process sequences one element at a time, feeding the output of each step back into the network, enabling them to theoretically model arbitrary-length contexts.
The session concludes with a preview of training RNNs via backpropagation through time and their application to language modeling.