Lecture 9: Transformers, Pretrained language models, Finetuning, Python tools
Practical Natural Language Processing
Rasika Bhalerao
r.bhalerao@northeastern.edu
Reminders
Common missed point in hw 5: lexicalized probabilities
Sentence: “We eat bread with butter.”
Question: Would it help to condition the expansion of vp on the head of the vp? In other words, if we use lexicalized probabilities just for expansion of vp? Why or why not? You do not need to calculate the probabilities for this question, just provide a sentence or two of reasoning for why it would (not) help.
Answer: Yes, because “eat” appears more often in the correct sentence structure: we eat 2 things together more often than we eat in a specific way (like “with gusto”).�VP -> V NP is more common than VP -> V NP PP for the verb “eat”, and this is not the case for most other verbs.
Resources for today’s material
BTW this is one of their slides (2018)
Pretraining motivation from the textbook
Review: Encoder-Decoder Models
Review: Attention in Encoder-Decoder Models
Self-attention
Self-attention = for each word, how important is each other word (in the context)?
Multiple attention heads = learn self-attention multiple times
Review: transformer = self-attention + feedforward
Positional embeddings
It’s another learned embedding
This one is to encode the relative location (encodes “position 3” instead of the word)
Refresher on BERT
BERT’s other objective function: next sentence prediction
To help it learn relationships between sentences (not just subwords)
Transfer learning
Finetune it to do any task you want!
Bias in Language Models
Bias in Language Models
More language model harms are in the textbook ch. 10
Common Python Toolkits
Pytorch
Assignment 7