Natural Language Processing

Chapter 1
Foundations of Natural Language Processing

Post Graduate Program in AI and ML
Natural Language Processing   •   Post Graduate

Foundations of Natural Language Processing

Introduction and Context

Natural Language Processing (NLP) is the interdisciplinary field concerned with enabling computers to represent, analyse, understand, generate and interact through human language. It connects linguistics, computer science, statistics, machine learning, information retrieval, cognitive science and, more recently, generative artificial intelligence.

Language is central to modern information systems. Search engines interpret queries, virtual assistants process speech, organisations classify customer feedback, translators convert between languages, and large language models generate text. Yet language is not merely a sequence of words. It is structured, context-dependent, socially situated and often ambiguous. A successful NLP system must therefore address both formal patterns and human meaning.

For postgraduate students, NLP should be understood not simply as a collection of algorithms, but as a design discipline involving linguistic analysis, data engineering, model selection, evaluation, deployment and governance.

Learning Objectives

By the end of this chapter, learners should be able to:

  1. Define major NLP terminology and distinguish related fields.
  2. Explain the historical development of NLP.
  3. Describe linguistic levels and their computational representations.
  4. Identify major NLP tasks and common sources of ambiguity.
  5. Compare symbolic, statistical, neural and generative architectures.
  6. Describe an end-to-end NLP development lifecycle.
  7. Analyse relationships among computational linguistics, machine learning and generative AI.
  8. Recognise practical, ethical and governance challenges in NLP projects.

1. What Is Natural Language?

Natural language refers to languages that develop through human communities, such as English, Hindi, Arabic and Japanese. It contrasts with formal languages, whose syntax and semantics are explicitly designed, such as programming languages, logical calculi and database query languages.

Natural languages possess several characteristics:

  • Productivity: speakers can create and understand novel expressions.
  • Compositionality: the meaning of a larger expression is often related to the meanings and arrangement of its parts.
  • Ambiguity: one expression may support multiple interpretations.
  • Context dependence: interpretation may depend on prior discourse, situation or shared knowledge.
  • Variation: language differs across dialects, domains, communities and time.
  • Redundancy: speakers often communicate the same information through multiple forms.

NLP converts language into computational objects—tokens, trees, vectors, graphs or generated sequences—while attempting to preserve information relevant to a task.

Important Terminology

TermMeaning
CorpusA collection of language data, usually stored digitally
DocumentA unit of text such as an article, message or report
TokenA computational occurrence of a word, symbol or subword unit
TypeA distinct token form in a corpus
VocabularyThe set of types recognised by a system
AnnotationHuman- or machine-assigned linguistic labels
FeatureAn observable or derived input used by a model
RepresentationA computational encoding of language
InferenceProducing a prediction or decision from a model
PretrainingLearning general patterns from a large unlabelled or weakly labelled corpus
Fine-tuningAdapting a pretrained model to a task or domain
PromptAn instruction or input supplied to a generative model
HallucinationA fluent but unsupported or incorrect model output

2. Historical Development

Rule-Based Beginnings

Early NLP systems were largely symbolic. Linguists and engineers wrote grammars, dictionaries and transformation rules. The 1950s and 1960s saw work on machine translation, formal grammars and question answering. These systems were interpretable and effective in narrowly defined environments, but they required substantial manual knowledge engineering and struggled with exceptions and ambiguity.

The Statistical Turn

From the late 1980s, increasing computational power and digitised corpora encouraged statistical NLP. Instead of specifying every rule, researchers estimated probabilities from observed language. Statistical machine translation, speech recognition, part-of-speech tagging and information retrieval benefited from this shift. The central idea was that patterns in representative data could support robust predictions, even when explicit linguistic rules were incomplete.

A simple language-model probability can be expressed as:

P(w₁, w₂, …, wₙ) = ∏ᵢ₌₁ⁿ P(wᵢ | w₁, …, wᵢ₋₁)

Here, wᵢ is the token at position i, n is sequence length, and the conditional probability estimates the next token given its preceding context. In practice, models approximate this relationship because the full history is too large to estimate directly. The formula describes a probability distribution, not a claim that language production is psychologically identical to sequential multiplication.

Neural NLP

Neural networks replaced many manually designed features with learned representations. Word embeddings represented words as dense vectors, allowing semantically related words to occupy nearby regions. Recurrent neural networks processed sequences, while convolutional networks captured local patterns. Attention mechanisms enabled a model to assign different importance to different parts of an input.

Transformers and Generative AI

The Transformer architecture made attention-based processing central to NLP. Large pretrained models learn statistical regularities from extensive corpora and can then be adapted to classification, extraction, translation, summarisation, dialogue and generation. Generative AI systems produce new text, but generation is not equivalent to verified reasoning. Their outputs must be evaluated for factuality, safety, bias and suitability for the application.

3. Linguistic Levels and Computational Analysis

NLP systems often combine several levels of linguistic description.

Phonetics and Phonology

Phonetics concerns the physical properties of speech sounds; phonology concerns how a language organises those sounds. These levels are especially important in automatic speech recognition, speaker identification and text-to-speech systems. A speech pipeline may convert an acoustic signal into phonemes, words and finally a transcript.

Morphology

Morphology studies the internal structure of words. The word “unhappiness” can be analysed as the prefix “un-”, the root “happy” and the suffix “-ness”. Morphological processing is valuable for lemmatisation, search, translation and languages with rich inflection.

  • Inflection changes grammatical form, as in “walk” and “walked”.
  • Derivation creates a related word, as in “teach” and “teacher”.
  • Morpheme is a minimal meaning-bearing or grammatical unit.

Lexical Analysis

Lexical analysis identifies words, subwords, named entities and lexical categories. Tokenisation is not always trivial: “New York”, “don’t”, URLs, emojis and compound words require design decisions. A tokenizer appropriate for social media may be inappropriate for legal contracts.

Syntax

Syntax concerns how words combine into phrases and sentences. Part-of-speech tagging assigns categories such as noun, verb or adjective. Parsing produces a structural representation, including constituency trees or dependency graphs.

For example, the sentence “The analyst reviewed the report” contains a subject–verb–object relation. A dependency parser represents “analyst” as dependent on “reviewed” in a subject relation, and “report” as its object.

Semantics

Semantics concerns literal and compositional meaning. Tasks include word-sense disambiguation, semantic role labelling, textual entailment and semantic similarity. A system must distinguish, for example, whether “bank” denotes a financial institution or a river edge.

Pragmatics and Discourse

Pragmatics examines intended meaning in context. “Can you open the window?” is grammatically a question about ability but commonly functions as a request. Discourse analysis studies relationships across sentences, including reference, topic continuity and coherence. In “Maya called Priya because she needed advice,” the pronoun “she” is ambiguous without additional context.

4. Major NLP Tasks

NLP tasks may be classified as analytical, retrieval-oriented, predictive or generative.

Text Classification

A classifier assigns labels to documents or passages. Applications include spam detection, sentiment analysis, intent recognition, toxicity detection and document routing. Classification may be binary, multiclass or multilabel.

Sequence Labelling

Sequence labelling assigns a label to each token. Part-of-speech tagging and named-entity recognition are common examples. In “Dr Rao joined Acme in Delhi,” a system may label “Dr Rao” as a person, “Acme” as an organisation and “Delhi” as a location.

Information Extraction

Information extraction converts unstructured text into structured facts. Relation extraction may identify that a person works for an organisation; event extraction may identify an acquisition, date and participants.

Information Retrieval and Question Answering

Information retrieval ranks documents relevant to a query. Question-answering systems may retrieve evidence and produce an answer. Retrieval-augmented generation combines search with generation, but retrieved material must be relevant, authoritative and correctly used.

Translation, Summarisation and Generation

Machine translation maps text between languages. Summarisation produces a shorter representation while preserving important content. Generation includes dialogue, drafting, explanation and controlled text production. These tasks require attention to factuality, style, terminology and user intent.

5. Ambiguity in Language

Ambiguity is a foundational difficulty rather than an exceptional error.

  • Lexical ambiguity: “light” may refer to illumination or low weight.
  • Syntactic ambiguity: “I saw the student with a telescope” has multiple possible attachments.
  • Semantic ambiguity: the literal composition may support more than one interpretation.
  • Pragmatic ambiguity: the intended meaning depends on context or social convention.
  • Referential ambiguity: a pronoun or noun phrase may refer to multiple entities.
  • Scope ambiguity: “Every researcher read a paper” does not specify whether the same paper was read.

Ambiguity is handled through context, world knowledge, discourse modelling, probabilistic inference, user clarification and domain constraints. No single technique resolves all ambiguity.

6. NLP Architectures and Modelling Paradigms

Symbolic Architecture

A symbolic system typically contains a lexicon, grammar, rules, parser and inference engine. It is transparent and useful when rules are stable, data are scarce or explanations are mandatory. Its weaknesses include maintenance cost, brittleness and limited coverage.

Statistical Architecture

Statistical systems estimate parameters from data. They may use n-gram models, probabilistic grammars, maximum-entropy classifiers or conditional random fields. They offer measurable uncertainty and often perform well with moderate data, but feature design and independence assumptions can limit performance.

Neural Architecture

Neural systems learn representations and prediction functions jointly. A generic supervised objective is to minimise average loss:

L(θ) = −(1/N) ∑ᵢ₌₁ᴺ log pθ(yᵢ | xᵢ)

Here, N is the number of training examples, xᵢ is an input, yᵢ is its target, pθ is the model probability parameterised by θ, and L is the average negative log-likelihood. This objective applies when targets are represented as observed outcomes and the model assigns them probabilities. It does not by itself guarantee fairness, factuality or generalisation.

Transformer and Foundation-Model Architecture

A Transformer processes token representations using attention and feed-forward layers. Encoder-oriented models are commonly used for understanding and classification; decoder-oriented models predict subsequent tokens and are suited to generation; encoder–decoder models support sequence-to-sequence tasks such as translation.

Foundation models are pretrained at scale and adapted to multiple downstream tasks. Their advantages include transfer learning and broad capability. Their risks include training-data contamination, hidden biases, high computational cost, privacy concerns and unreliable output.

7. The NLP Development Lifecycle

A professional NLP project should proceed iteratively:

  1. Problem formulation: define users, decisions, constraints and success criteria.
  2. Data acquisition: identify lawful, relevant and representative sources.
  3. Data governance: address consent, privacy, licensing, retention and access.
  4. Exploration and annotation: inspect distributions, create guidelines and measure agreement.
  5. Baseline development: establish a simple, reproducible reference system.
  6. Model selection: compare symbolic, statistical, neural and retrieval-based approaches.
  7. Training and validation: separate training, validation and test data to avoid leakage.
  8. Evaluation: measure task performance and subgroup, robustness, latency and cost.
  9. Deployment: integrate monitoring, security, versioning and human escalation.
  10. Maintenance: detect drift, update data and models, and review incidents.

Accuracy alone is insufficient. For a classification task, precision is the proportion of predicted positives that are correct, while recall is the proportion of actual positives that are found:

Precision = TP ÷ (TP + FP)
Recall = TP ÷ (TP + FN)

Here, TP denotes true positives, FP false positives and FN false negatives. Precision and recall are meaningful only with clearly defined positive labels and an appropriate evaluation sample. Their harmonic mean is the F1 score:

F₁ = 2 × (Precision × Recall) ÷ (Precision + Recall)

8. Relationship Among Computational Linguistics, Machine Learning and Generative AI

Computational linguistics applies linguistic theory and computational methods to model language. It asks questions about grammar, meaning, discourse and communication, and often develops formal representations.

Machine learning provides methods for learning patterns from data. In NLP, it supports prediction, representation learning, ranking and generation. Machine learning does not replace linguistic reasoning; it is a family of modelling strategies whose success depends on data, objectives and evaluation.

Generative AI refers to systems that create content such as text, speech, images or code. Generative NLP models learn a distribution over language and produce outputs conditioned on prompts or context. Thus, computational linguistics supplies theories and analytical concepts, machine learning supplies learning mechanisms, and generative AI supplies large-scale content production. The boundaries overlap, but the terms are not synonyms.

9. Illustrative Case: Customer-Service Complaint Triage

Background

A fictional telecommunications company receives 50,000 customer messages monthly. Complaints concern billing, connectivity, fraud, cancellation and service quality. Manual routing delays urgent cases.

Problem

The company wants an NLP system to assign an intent, identify urgency and extract account-related entities without exposing sensitive information.

Analysis

Initial review reveals spelling variation, code-switching, sarcasm, repeated messages and ambiguous urgency. A purely accuracy-based evaluation could conceal poor performance for minority languages or fraud-related cases.

Approach

The team first defines a taxonomy and annotation manual. A keyword baseline is compared with a supervised classifier and a pretrained language model. Personally identifiable information is masked before training. A retrieval component supplies approved troubleshooting passages, while a human agent approves high-risk fraud decisions.

Evaluation includes macro-averaged class metrics, subgroup analysis, calibration, latency and escalation rate. Error analysis shows that “my bill is shocking” may express either high cost or dissatisfaction; additional context and a clarification workflow are introduced.

Outcome

The system reduces routine routing time, but it does not autonomously resolve complaints. Monitoring detects changes after a new pricing plan is introduced, prompting annotation and retraining.

Learning Points

The case demonstrates that successful NLP combines taxonomy design, data governance, linguistic analysis, modelling, human oversight and continuous monitoring. A larger model is not automatically a better operational solution.

10. Challenges, Ethics and Governance

NLP systems may reproduce social stereotypes, disadvantage dialect speakers, expose personal data or generate misleading content. Important risks include:

  • Representation bias: some languages, groups or genres are underrepresented.
  • Annotation bias: labels reflect subjective guidelines and annotator assumptions.
  • Privacy risk: text may contain health, financial, biometric or identifying information.
  • Automation bias: users may over-trust fluent system outputs.
  • Security threats: prompt injection, data poisoning and information leakage can compromise systems.
  • Environmental and financial cost: large models require substantial computation.
  • Accountability gaps: responsibility may be unclear when systems are built from third-party models.

Best practice includes data minimisation, access control, documentation, consent where applicable, representative testing, red-team evaluation, provenance tracking, human review and incident response. Regulatory obligations vary by jurisdiction and application; high-impact uses require especially careful risk assessment and auditability.

11. Contemporary Directions

Current research includes multilingual and low-resource NLP, retrieval-augmented generation, instruction tuning, parameter-efficient adaptation, multimodal language systems, efficient inference, factuality evaluation, interpretability and agentic workflows. These developments raise methodological questions: how should factual knowledge be measured, how can evaluation resist benchmark contamination, and how should systems communicate uncertainty?

A mature NLP practitioner treats benchmarks as evidence rather than proof of real-world reliability. Deployment context, user incentives, data drift and consequences of error must remain central.

Chapter Summary

NLP is an interdisciplinary field that computationally represents and processes human language. Its history has progressed from symbolic rules through statistical modelling to neural and foundation-model architectures. Linguistic analysis spans phonology, morphology, lexicon, syntax, semantics, pragmatics and discourse. Major tasks include classification, sequence labelling, extraction, retrieval, translation, summarisation and generation.

Ambiguity is intrinsic to language and requires context, world knowledge and uncertainty-aware methods. Computational linguistics contributes theories of language; machine learning provides data-driven modelling; generative AI produces new content using learned language distributions. Professional NLP development is an iterative lifecycle involving problem definition, governed data, annotation, baselines, modelling, evaluation, deployment and monitoring. Ethical practice requires privacy protection, bias assessment, transparency, security and human accountability.

Key Terms

Natural Language Processing: Computational study and processing of human language.

Computational linguistics: Application of computational methods to linguistic representation and analysis.

Corpus: Digitally collected body of language data.

Tokenisation: Division of text into computational units.

Morphology: Study of word structure.

Syntax: Study of grammatical structure.

Semantics: Study of literal and compositional meaning.

Pragmatics: Study of meaning in context and use.

Discourse: Language structure and coherence across sentences.

Ambiguity: Availability of multiple interpretations.

Annotation: Assignment of labels or metadata to language data.

Embedding: Dense vector representation learned from data.

Attention: Mechanism that weights information according to relevance.

Transformer: Neural architecture based primarily on attention mechanisms.

Pretraining: Initial learning from large-scale data before task adaptation.

Fine-tuning: Updating a pretrained model for a target task or domain.

Hallucination: Unsupported or incorrect generated content.

Precision: Fraction of predicted positives that are correct.

Recall: Fraction of actual positives that are identified.

Data drift: Change in input or target distributions over time.

Review Questions

5 Short Answer Questions

  1. Define NLP and explain why it is interdisciplinary.
  2. Distinguish morphology from syntax.
  3. What is lexical ambiguity? Give an example.
  4. Explain the purpose of a baseline system.
  5. Differentiate pretraining from fine-tuning.

5 Long Answer Questions

  1. Trace the development of NLP from symbolic systems to generative AI.
  2. Explain the major linguistic levels and their computational applications.
  3. Compare symbolic, statistical, neural and Transformer-based architectures.
  4. Describe an end-to-end NLP development lifecycle, including governance.
  5. Explain the relationship among computational linguistics, machine learning and generative AI.

3 Analytical / Application Questions

  1. Design an NLP approach for classifying hospital messages while protecting patient privacy. Specify data, labels, evaluation and human oversight.
  2. A classifier has high accuracy but performs poorly for a minority language variety. Analyse possible causes and propose an evaluation and remediation plan.
  3. A generative assistant produces fluent but unsupported legal advice. Analyse the technical and governance risks and design a safer system workflow.

Multiple Choice Questions with Answers

Question 1

Which linguistic level primarily concerns how words combine into phrases and sentences?

A. Phonology

B. Syntax

C. Morphology

D. Pragmatics

Correct Answer: B. Syntax

Question 2

In the expression “river bank,” the word “bank” illustrates which problem?

A. Lexical ambiguity

B. Token leakage

C. Data drift

D. Speech synthesis

Correct Answer: A. Lexical ambiguity

Question 3

What is the main purpose of a baseline in an NLP project?

A. To guarantee fairness

B. To replace evaluation

C. To provide a reproducible reference for comparison

D. To eliminate the need for data

Correct Answer: C. To provide a reproducible reference for comparison

Question 4

Which architecture made attention central to modern large-scale NLP?

A. Decision tree

B. Transformer

C. Finite-state automaton

D. Relational database

Correct Answer: B. Transformer

Question 5

Recall is the proportion of:

A. Predicted positives that are correct

B. All predictions that are correct

C. Actual positives that are identified

D. Negative cases that are rejected

Correct Answer: C. Actual positives that are identified

Question 6

Which task assigns a label to each token in a sentence?

A. Sequence labelling

B. Document clustering only

C. Machine translation only

D. Speech compression

Correct Answer: A. Sequence labelling

Question 7

What does fine-tuning usually mean in modern NLP?

A. Deleting all pretrained parameters

B. Adapting a pretrained model to a task or domain

C. Converting text into speech exclusively

D. Removing labels from a corpus

Correct Answer: B. Adapting a pretrained model to a task or domain

Question 8

Which issue is most directly associated with a fluent but unsupported generated answer?

A. Hallucination

B. Tokenisation

C. Lemmatisation

D. Parsing

Correct Answer: A. Hallucination

Question 9

Which practice best addresses privacy risk in a customer-message corpus?

A. Publishing all raw messages

B. Removing data governance controls

C. Masking personally identifiable information and limiting access

D. Increasing model size only

Correct Answer: C. Masking personally identifiable information and limiting access

Question 10

Computational linguistics is best described as:

A. Only the commercial deployment of chatbots

B. The application of computational methods to linguistic analysis and representation

C. A synonym for database administration

D. A method for encrypting documents

Correct Answer: B. The application of computational methods to linguistic analysis and representation

Natural Language Processing
Chapter 1 of 15