AI Foundations ← pitcsolutions.com All lessons

Lesson 7 of 13 in Deep learning, about 12 minutes

Natural Language Processing

Computers only understand numbers. NLP is the bridge that lets them read, understand and write human language.

By the end of this lesson you will be able to

  • explain how a computer turns a sentence into numbers
  • name the major NLP tasks and where you meet them
  • explain why context makes language hard, and how modern models handle it

Natural Language Processing (NLP) is the branch of AI that lets computers understand, interpret, analyse and generate human languages like English, Hindi, French or Tamil.

The goal is simple: let humans and computers communicate naturally, in speech or writing.

HumanComputer
Understands wordsUnderstands numbers
Uses grammarUses mathematical models
Learns language from experienceLearns from training data
Understands emotionsPredicts patterns in text
Speaks naturallyGenerates text with AI models
Classroom question

Write “I love AI.” on the board. What language is it? Is the speaker happy or angry? Everyone answers instantly. Now ask: how does a computer know that “love” is positive? Because it has learned patterns from billions of sentences during training.

How NLP works, step by step

NLP pipeline: input sentence I love pizza, tokenisation into three tokens, conversion to vectors of numbers, a deep learning model, and the prediction positive sentiment I love pizza.1. Input I love pizza 2. Tokenisation [0.21, 0.82,−0.40, …]3. Vectors Deep learningmodel4. Model Positivesentiment 😊5. Prediction

First the text is split into smaller pieces called tokens: ["I", "love", "Machine", "Learning"]. Each token gets an ID number (I → 152, love → 849, …), and each ID becomes a vector of numbers. The AI never works with letters directly; it only works with numbers. You can try a live tokeniser in lesson 9.

Why is language so hard for computers?

Because language is ambiguous, and meaning depends on context.

“I saw a man with a telescope.”

Who has the telescope: the man, or me? Humans use context; computers must learn to.

“Apple”

🍎 a fruit, or 💻 Apple Inc.? The AI decides from the surrounding words.

“Bank”

“The bank approved my loan” (money) vs “The fisherman sat on the bank” (river side).

“Bat”

🦇 a flying mammal, 🏏 a cricket bat, or ⚾ a baseball bat.

Major NLP tasks

  1. 1. Text classification

    “This movie is amazing.” → Positive review

    Spam detection, email categories, news topics

  2. 2. Sentiment analysis

    “I love this phone” → Positive 😊. “Worst product ever” → Negative 😞

    Product reviews, social media monitoring, feedback

  3. 3. Machine translation

    English → French, Hindi → English

    Google Translate, Microsoft Translator, Amazon Translate

  4. 4. Text summarisation

    Long article → short summary

    News, research papers, meeting notes

  5. 5. Question answering

    “Who is the Prime Minister of India?” → the answer

    ChatGPT, customer support, virtual assistants

  6. 6. Text generation

    “Write a poem on nature.” → a poem

    ChatGPT, Gemini, Claude

  7. 7. Named Entity Recognition

    “Rahul works at Amazon in Bengaluru.” → Person, Organisation, Location

    Resume parsing, medical records, search engines

  8. 8. Speech recognition

    Speech → text

    Alexa, Siri, Google Assistant, voice notes

  9. 9. Text-to-speech

    Text → natural voice

    GPS navigation, audiobooks, accessibility

How NLP evolved

EraHow it workedLimitation
Rule-basedDictionaries and hand-written rules: IF text contains “good” THEN positiveHard to maintain, fails on ambiguity and context (“not good”)
Machine learningLearns from labelled examples: 10,000 reviews → classifier → spam / not spamStill needs hand-crafted features
Deep learningNeural networks: RNN, LSTM, GRU, then TransformersNeeds lots of data and compute
Large Language ModelsChatGPT, Gemini, Claude, Llama, DeepSeek, trained on trillions of tokensCan confidently make mistakes (“hallucinate”)

The three ideas behind modern NLP

Tokenisation

Models read tokens, not whole sentences. Common words are one token; rare words are split: unbelievable → un + believ + able. This lets the model handle new and rare words.

Embeddings

Each token becomes a vector, like King → [0.23, 0.51, …]. Words with similar meanings get similar vectors, so King sits close to Queen, Doctor near Nurse, Paris near France. The model learns these relationships automatically.

Attention

In “The cat chased the mouse because it was hungry”, who was hungry? The model uses attention to decide which earlier words matter most for each word. This made NLP dramatically more accurate, and it is the heart of the Transformer.

Real-world applications

ApplicationNLP task
ChatGPTText generation
Google TranslateMachine translation
GmailSpam detection
AlexaSpeech recognition
SiriQuestion answering
GrammarlyGrammar correction
Amazon reviewsSentiment analysis
Banking chatbotsCustomer support
WhatsApp voice messagesSpeech-to-text
Meeting assistantsSummarisation
A common misconception

ChatGPT does not look answers up in a giant database. It predicts the next most probable token based on your prompt and the patterns it learned in training. Lessons 9 and 10 show exactly how.

Try it: be the NLP model

For each sentence decide the sentiment, or which “Apple” / “bank” is meant: “I love this movie.” “This movie is terrible.” “Apple launched a new iPhone.” “I ate an apple after lunch.” “The bank approved my loan.” “The fisherman sat on the river bank.” Then ask: how did you figure it out? From context. NLP models learn to use context mathematically through embeddings and attention.

Key takeaways

  • AI makes machines intelligent; ML learns from data; deep learning uses neural networks; NLP applies them to human language.
  • Text → tokens → numbers (vectors) → model → prediction.
  • Language is ambiguous; embeddings and attention let models use context.
  • NLP turns human language into maths, so machines can understand, translate, summarise and generate text.

Check your understanding

1. “Rahul works at Amazon in Bengaluru” → Person, Organisation, Location. Which task is this?

NER finds and labels the important names in text.

2. Why do models split “unbelievable” into un + believ + able?

Sub-word tokens let a fixed vocabulary cover almost any word.

3. What makes “The bank approved my loan” understandable to a Transformer?

Attention lets “bank” pick up meaning from “loan” and “approved”.