Docsity

Unit V notes in short, Summaries of Natural Language Processing (NLP)

Toggle sidebar
bg1
1. Neural NLP
Meaning
Neural NLP uses neural networks to understand, process, and generate human language.
Traditional NLP often depends on manually designed features and statistical methods. Neural
NLP learns useful patterns automatically from data.
Example
Sentence:
โ€œThe movie was very good.โ€
A neural NLP model can learn that words such as good, excellent, amazing are often
associated with positive sentiment.
2. Motivation for Neural NLP
Traditional NLP methods have some limitations:
โ— They require manual feature engineering.
โ— They have difficulty understanding context.
โ— They may struggle with complex language.
โ— They do not represent word meaning very effectively.
โ— They have difficulty handling long-distance relationships between words.
Neural networks help by learning representations and patterns automatically.
3. Limitations of Statistical NLP Models
Statistical NLP models such as traditional N-gram models have limitations.
1. Limited context
An N-gram model considers only a fixed number of previous words.
2. Data sparsity
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14

Partial preview of the text

Download Unit V notes in short and more Summaries Natural Language Processing (NLP) in PDF only on Docsity!

1. Neural NLP

Meaning

Neural NLP uses neural networks to understand, process, and generate human language.

Traditional NLP often depends on manually designed features and statistical methods. Neural NLP learns useful patterns automatically from data.

Example

Sentence:

โ€œThe movie was very good.โ€

A neural NLP model can learn that words such as good, excellent, amazing are often associated with positive sentiment.

2. Motivation for Neural NLP

Traditional NLP methods have some limitations:

โ— They require manual feature engineering. โ— They have difficulty understanding context. โ— They may struggle with complex language. โ— They do not represent word meaning very effectively. โ— They have difficulty handling long-distance relationships between words.

Neural networks help by learning representations and patterns automatically.

3. Limitations of Statistical NLP Models

Statistical NLP models such as traditional N-gram models have limitations.

1. Limited context

An N-gram model considers only a fixed number of previous words.

2. Data sparsity

Many possible word combinations may never appear in the training data.

3. Poor handling of long sentences

Relationships between words that are far apart are difficult to capture.

4. Large vocabulary problem

Handling a very large vocabulary requires considerable storage and computation.

5. Limited semantic understanding

Traditional models mainly depend on word occurrence probabilities rather than deeper contextual representations.

4. Dense Vector Representations

Definition

A dense vector representation represents a word as a vector of numerical values.

Example:

"king" โ†’ [0.25, -0.14, 0.72, 0.31, ...]

Words with related meanings tend to have similar vector representations.

Example

King โ†’ vector Queen โ†’ vector Man โ†’ vector Woman โ†’ vector

These representations allow neural networks to work with the meaning and relationships between words mathematically.

Advantages

โ— Captures semantic relationships. โ— Represents words numerically. โ— Useful for machine learning. โ— Helps neural networks process language.

Every word interacts with other words to create a better contextual representation.

7. Scaled Dot-Product Attention

This is the basic attention mechanism used in Transformers.

It uses three components:

โ— Query (Q) โ— Key (K) โ— Value (V)

The formula is:

Attention(Q,K,V)=softmax\left(\frac{QK^T}{\sqrt{d_k}}\right)V

Simple meaning

  1. Compare the Query with Keys.
  2. Calculate attention scores.
  3. Scale the scores.
  4. Apply Softmax.
  5. Use the scores to combine the Values.

Why scaling?

The division by \sqrt{d_k} prevents very large values from making the Softmax function unstable.

8. Advantages of Attention over

Traditional Models

Attention provides several benefits:

โ— Captures relationships between distant words. โ— Focuses on important words. โ— Handles context better. โ— Allows parallel processing in Transformers. โ— Reduces dependence on sequential processing.

9. Encoderโ€“Decoder Models

Definition

An Encoderโ€“Decoder model contains two main parts:

Encoder

Converts the input sequence into a representation.

Decoder

Uses that representation to generate the output sequence.

Input Sentence โ†“ Encoder โ†“ Representation โ†“ Decoder โ†“ Output Sentence

Example: Translation

English "I love India." โ†“ Encoder โ†“ Decoder โ†“ Hindi "เคฎเฅเคเฅ‡ เคญเคพเคฐเคค เคชเคธเค‚เคฆ เคนเฅˆเฅค"

Applications

โ— Machine translation โ— Text summarization โ— Question answering โ— Chatbots

English sentence โ†” Hindi sentence

and uses these examples to predict translations.

Limitation

It may produce unnatural translations and has difficulty with complex context.

C. Neural Machine Translation (NMT)

NMT uses neural networks to translate text.

Modern NMT systems commonly use Transformer-based architectures.

Advantages

โ— Better contextual understanding. โ— More fluent translations. โ— Handles long-range relationships better than older approaches. โ— Learns representations automatically.

11. Text Summarization

Definition

Text summarization automatically creates a shorter version of a longer document while retaining important information.

Example

A 10-page news article can be converted into a short paragraph containing the main points.

Types

Extractive summarization

Selects important sentences from the original document.

Abstractive summarization

Generates new sentences that express the important information.

Applications

โ— News summarization โ— Research-paper summaries โ— Legal document summarization โ— Meeting summaries โ— Email summarization

12. Transformer Architecture

A Transformer is a neural network architecture based mainly on attention mechanisms rather than recurrent processing.

Main components include:

  1. Multi-head attention
  2. Positional embeddings/encodings
  3. Feedforward layers

Basic structure

Input Tokens โ†“ Token Embeddings โ†“ Positional Information โ†“ Multi-Head Attention โ†“ Feedforward Network โ†“ Output Representation

13. Multi-Head Attention

Definition

Multi-head attention uses multiple attention mechanisms, called heads , at the same time.

Each head can learn to focus on different relationships in the sentence.

15. Feedforward Layers

A feedforward neural network is applied to the representations produced by the attention mechanism.

Its role is to further transform and learn useful patterns from the representations.

Simplified:

Attention Output โ†“ Feedforward Network โ†“ Improved Representation

16. Advantages of Transformer over RNN

Transformer RNN

Processes tokens in parallel Processes sequentially

Uses self-attention Uses recurrent connections

Handles long-range relationships effectively Can struggle with long dependencies

Faster training can be achieved through parallelization

Training is more sequential

Highly scalable Sequential nature limits parallelization

17. Contextual Embeddings

Definition

A contextual embedding represents a word according to the context in which it appears.

Example

โ€œI deposited money at the bank.โ€

and

โ€œWe sat near the river bank.โ€

The word bank has different meanings in the two sentences.

Contextual embeddings can produce different representations based on the surrounding words.

18. BERT

Full form

BERT = Bidirectional Encoder Representations from Transformers

BERT is a Transformer-based language model designed to understand language using context from both directions.

Meaning of Bidirectional

BERT considers information from both:

โ— Left side of a word โ— Right side of a word

This helps it understand the context more effectively.

19. BERT Architecture

Simplified:

22. Downstream Tasks

A pre-trained model such as BERT can be adapted for specific tasks.

A. Question Answering

Input:

Question: Where is the college?

Passage: The college is located in Pune.

Output:

Pune

B. Text Classification

Input:

โ€œThe service was excellent.โ€

Output:

Positive

Other applications include:

โ— Sentiment analysis โ— Named Entity Recognition โ— Document classification โ— Question answering

23. Modern NLP Applications

A. Chatbots

A chatbot communicates with users using natural language.

Example

Student:

โ€œWhen is my exam?โ€

Chatbot:

โ€œYour NLP exam is scheduled according to the college timetable.โ€

Applications:

โ— Customer support โ— Education โ— Banking โ— Healthcare information systems

B. Sentiment Analysis

Modern neural models can identify the sentiment of text.

"I loved the movie." โ†“ Neural NLP Model โ†“ Positive

C. Document Classification

Documents are automatically assigned to categories.

Example:

Customer document โ†“ NLP Model โ†“ Billing / Technical / Account / Other

Applications:

โ— Email classification โ— News classification โ— Legal document classification โ— Customer-support routing

25. Case Study 1 โ€“ AI-Powered Academic

Chatbot

Problem

Students have many questions about:

โ— Syllabus โ— Timetable โ— Exams โ— Assignments โ— Attendance โ— College rules

Solution

Develop an AI-powered academic chatbot.

Architecture

Student โ†“ Chatbot Interface โ†“ Question Processing โ†“ Knowledge Base / RAG โ†“ Language Model โ†“ Answer โ†“ Student

Example

Student:

โ€œWhat are the topics in Unit V of NLP?โ€

The chatbot retrieves the relevant syllabus information and provides the answer.

Benefits

โ— Available anytime. โ— Quick responses. โ— Reduces repetitive questions. โ— Helps students access academic information.

26. Case Study 2 โ€“ Retrieval-Augmented

Question Answering System

Problem

A normal language model may not have access to an organizationโ€™s private documents.

Solution

Use RAG.

Working

Question โ†“ Document Search โ†“ Relevant Documents โ†“ Context โ†“ Language Model โ†“ Answer

Example

A university uploads:

โ— Student handbook โ— Examination rules โ— Academic calendar โ— Department regulations

A student asks:

โ€œWhat is the procedure for applying for an exam?โ€

Important: A generated legal summary should be treated as an aid to reading, not as a substitute for professional legal review.

28. Case Study 4 โ€“ Voice-Enabled

Regional Language Assistant

Problem

Many users are more comfortable communicating in their regional language.

Solution

Create a voice assistant that supports regional languages.

Working

User Speaks โ†“ Speech Recognition / ASR โ†“ Regional Language Text โ†“ NLP Model โ†“ Answer Generation โ†“ Text-to-Speech โ†“ Spoken Answer

Example

A user asks a question in Marathi.

Marathi Speech โ†“ ASR โ†“ Marathi Text โ†“ NLP Model

Answer โ†“ Marathi Speech

Applications

โ— Education โ— Government information services โ— Agriculture information โ— Customer support โ— Voice-based learning systems