Where to start
Learn tokenisation, TF-IDF features and a linear classifier first, so you can measure what a fine-tuned transformer adds. Then learn precision, recall and F1, which matter more than accuracy when classes are unbalanced.
How machine learning is used in natural language processing
Text classification
Models assign labels such as topic, sentiment or urgency to documents, emails and reviews. Fine-tuning a pretrained language model works well even with modest labelled data.
Real example: ULMFiT. ULMFiT showed that fine-tuning a pretrained language model outperformed the previous state of the art on six text classification tasks.
Extracting names, dates and facts
Named entity recognition and relation extraction pull structured facts out of text, such as drugs, genes or contract parties. Domain-specific pretraining helps in specialist text.
Real example: BioBERT. BioBERT is a language model pretrained on biomedical text that improved on BERT for biomedical named entity recognition, relation extraction and question answering.
Search and question answering
Language models help a search engine understand what a query means, not just which words it contains. The same models rank passages and extract answers.
Real example: BERT in Google Search. Google announced in 2019 that it was applying BERT models to better understand search queries.
Machine translation
Sequence-to-sequence models translate text between languages, trained on large collections of parallel sentences. Recent work extends this to languages with little training data.
Real example: No Language Left Behind (Meta AI). Meta AI's No Language Left Behind project built translation models covering 200 languages, including many low-resource languages.
Can you learn machine learning for NLP?
Yes. NLP is very accessible because pretrained models and libraries do much of the heavy lifting. Learn Python and text handling first, then classical models such as TF-IDF with logistic regression, then transformers and fine-tuning.
- Python and text handling. Clean, tokenise and count text with Python strings, pandas and regular expressions. Taught in the Python track of Foundations of AI
- Classical text models. Build TF-IDF features with logistic regression and evaluate with precision, recall and F1, which gives a fast baseline. Taught in the Machine Learning track of Foundations of AI
- Neural networks and embeddings. Learn how words and sentences become vectors and how sequence models use them. Covered by the Deep Learning course (coming next)
- Transformers and fine-tuning. Fine-tune a pretrained model such as DistilBERT with Hugging Face Transformers for classification or entity extraction. Covered by the Generative AI course (planned)
Moving into natural language processing
If you already work in the field
If you work with language professionally, as a linguist, translator, analyst or editor, you know where meaning is ambiguous and how to write labelling rules. Add Python and Hugging Face, then start with a classification project on documents you already know well.
If you come from data science or ML
If you come from tabular machine learning, learn tokenisation, embeddings and transformer fine-tuning. Pay attention to annotation guidelines and inter-annotator agreement, which limit how good any NLP model can be.
Roles that do this work: NLP engineerMachine learning engineer, NLPComputational linguistApplied scientist, language
Tools you will use
| Tool | What you use it for |
|---|---|
| Hugging Face Transformers | Load pretrained language models and fine-tune them for classification, tagging and question answering. |
| spaCy | Tokenise text, tag entities and parse sentences in fast production pipelines. |
| scikit-learn | Build TF-IDF and linear-model baselines and compute precision, recall and F1. |
| Sentence Transformers | Turn sentences into embeddings for semantic search, clustering and similarity. |
| NLTK | Teaching-friendly tokenisers, corpora and classic NLP algorithms for exploring text. |
Public data to practise on
- IMDb Large Movie Review Dataset: Movie reviews labelled positive or negative, the standard first dataset for sentiment classification.
- Universal Dependencies: Treebanks in many languages annotated with parts of speech and syntax, for tagging and parsing models.
- MultiNLI: Sentence pairs labelled entailment, neutral or contradiction across several genres, for natural language inference.
Your first project
Download the IMDb movie review dataset, predict review sentiment by fine-tuning DistilBERT, and compare it with TF-IDF and logistic regression using accuracy and F1 on the test set.
Keep the result, your code and a short note on what didn't work. That record is worth more than the score.