Block 108: Hugging Face Transformers: Intro
Load and use pre-trained transformer models for NLP tasks.
Concepts
- pip install transformers
- pipeline() API for common tasks
- Sentiment analysis, text classification, NER with transformers
- Tokenizers: how BERT tokenizes text
Code Examples
See exercise below.
Exercise
Use pipeline('sentiment-analysis') to classify 5 sentences. Examine confidence scores. Use pipeline('ner') to extract entities from a news headline.
Homework
What is the difference between BERT and GPT in terms of pre-training objective? Explain in simple terms. Friday