STATS / DATA SCI 315
Transformers
slides credit: Dr. Simon J. D. Prince
https://udlbook.github.io/udlbook/
Natural language processing (NLP)
Transformers
Motivation
Design neural network to encode and process text:
Motivation
Design neural network to encode and process text:
Word embeddings convert words into fixed dimensional vectors
word2vec is a popular family of word embeddings
Motivation
Design neural network to encode and process text:
x N
Standard fully-connected layer
Standard fully-connected layer
Standard fully-connected layer
Problem:�
�
Conclusion:
Motivation
Design neural network to encode and process text:
The word their must “attend to” the word restaurant.
Motivation
The word their must “attend to” the word restaurant.
Conclusions:�
Design neural network to encode and process text:
Transformers
Dot-product self attention
Dot-product self attention
Dot-product self attention
Attention as routing
Attention as routing
Attention as routing
Attention weights
Attention weights
Dot product = measure of similarity
Motivation
Conclusions:�
Design neural network to encode and process text:
Transformers
Matrix form
Matrix form
Positional encoding
Self-attention is equivariant to permuting word order
�But word order is important in language:
The man ate the fish
vs.
The fish ate the man
Positional encoding
Positional encoding
Multi-head self-attention
Why do we learn attention weights?
Transformers
Transformers
The transformer
Transformers
Tokenizer
Goal: Tokenizer chooses input “units”
Solution: Sub-word tokenization�One particular algorithm: Byte pair encoding
Learning vocabulary
”One hot encoding”
Transformers
Three types of transformer layer
Decoder model
Decoder model: GPT3
Decoder model: GPT3
Predicting all next words simultaneously
Masked self-attention
Transformers
GPT3 (Brown et al. 2020)
try some out at
https://umgpt.umich.edu/
What does it learn?
“Tomorrow, let’s <VERB>...”
“The train pulled into the …”
Text completion
Understanding Deep Learning is a new textbook from MIT Press by Simon Prince that's designed to offer an accessible, broad introduction to the field. Deep learning is a branch of machine learning that is concerned with algorithms that learn from data that is unstructured or unlabeled. The book is divided into four sections:
The first section offers an introduction to deep learning, including its history and origins. The second section covers deep learning architecture, discussing various types of neural networks and their applications. The third section dives into deep learning algorithms, including supervised and unsupervised learning, reinforcement learning, and more. The fourth section applies deep learning to various domains, such as computer vision, natural language processing, and robotics.
Few shot learning:
ChatGPT
ChatGPT