NLP Applications — Sentiment Analysis, Machine Translation & Question Answering
This lesson and the next survey how the concepts across all four units combine into the real-world NLP applications you will encounter and build.
Sentiment Analysis — Recap and Modern Deployment
Covered in depth in Unit 3 (lexicon-based with VADER, ML-based with Naïve Bayes + TF-IDF). In production today, most large-scale sentiment systems use fine-tuned Transformer models (Unit 4) for higher accuracy on nuanced/sarcastic text, while lightweight lexicon methods remain popular for real-time, low-latency applications (e.g. live chat monitoring).
| Deployment context | Typical technique used |
|---|---|
| Real-time social media stream monitoring | Lexicon-based (VADER) — fast, no GPU needed |
| Product review analytics dashboard | Fine-tuned Transformer (higher accuracy, batch processing) |
| Customer support ticket triage | ML-based (Naïve Bayes/SVM) — fast, interpretable, good baseline |
Machine Translation (MT)
Machine Translation automatically converts text from one language to another. It has evolved through the same historical arc as language modeling itself:
- Statistical MT used n-gram language models (Unit 2) combined with phrase-translation probability tables learned from parallel bilingual corpora.
- Neural MT uses an encoder-decoder architecture: an encoder (originally LSTM, now Transformer) reads the source sentence into a representation, and a decoder generates the target-language sentence token by token — the same encoder-decoder pattern used for abstractive summarization (Unit 3).
# Using a pre-trained Transformer-based translation model (Hugging Face)
from transformers import pipeline
translator = pipeline("translation_en_to_fr", model="Helsinki-NLP/opus-mt-en-fr")
result = translator("Natural Language Processing is fascinating.")
print(result[0]['translation_text'])
# "Le traitement du langage naturel est fascinant."
Question Answering (QA)
Question Answering systems return a precise answer to a natural-language question, rather than a list of documents (as a search engine does).
| QA Type | Description | Example |
|---|---|---|
| Extractive QA | Answer is a text span copied directly from a given passage | Question: "Who created Python?" Passage mentions "Guido van Rossum created Python" → answer extracted verbatim |
| Open-domain QA | No passage given; system must first retrieve relevant documents, then extract/generate the answer | "What is the capital of France?" answered from general knowledge |
| Generative/Abstractive QA | Answer is generated in the model's own words, possibly synthesizing multiple sources | LLM-based chat assistants |
from transformers import pipeline
qa = pipeline("question-answering", model="distilbert-base-cased-distilled-squad")
context = "Python was created by Guido van Rossum and released in 1991."
result = qa(question="Who created Python?", context=context)
print(result['answer']) # "Guido van Rossum"
Notice extractive QA is architecturally similar to Named Entity Recognition (Unit 2) — both are span-identification tasks over a passage, just with a different objective (find entities vs find the answer span).
How These Applications Reuse the Full Course
| Application | Units it draws on |
|---|---|
| Sentiment analysis | Unit 1 (preprocessing) + Unit 3 (TF-IDF, Naïve Bayes) + Unit 4 (Transformers) |
| Machine translation | Unit 2 (n-gram LMs, historically) + Unit 4 (encoder-decoder, Transformers) |
| Question answering | Unit 2 (NER-style span detection) + Unit 4 (contextual embeddings) |
The final lesson covers the remaining applications named in the syllabus: text summarization (deepened from Unit 3), chatbots, speech assistants, and generative AI.