Skip to main content
Natural Language Processing

Introduction to Natural Language Processing

Published: 2026-08-13
Level: postgraduate
Audience: Postgraduate students in a first NLP course, and anyone who wants a grounded overview of how machines handle language.

This first session sets the stage for the whole course. It answers four questions: what NLP is, where it sits inside AI, what a modern NLP pipeline looks like, and how you judge whether an NLP system is any good. It also runs a small live demo of text preprocessing with NLTK and spaCy, and it spends a long time on one uncomfortable truth: human language is deeply ambiguous, and that ambiguity is the reason this field exists.

1.1 What NLP Is and Why It Matters

This section answers the opening question of the course: what exactly is NLP, where does it sit inside artificial intelligence, and why does it deserve a whole course? The answer builds up through a definition, a quick tour of what the course will cover, the students' own reasons for studying the field, and a famous movie dialogue that shows how much language skill humans run without noticing.

1.1.1 Definition and Place in AI

Hook: You understood every sentence of this session so far without once thinking about grammar rules. Which meaning of "model" applied? Which topic did the discussion belong to? When was a question actually a question? You carried all of that context with you the whole time, without effort. Now imagine building a machine that does the same. That is NLP.

Natural Language Processing (NLP) is the branch of artificial intelligence that helps machines understand, analyze, and generate human language. Take the three verbs seriously, because they split the field into three job families:

  • Understand — read a sentence and know what it means: which "bank" is meant in "I sat by the bank" (the river bank, not a financial bank).
  • Analyze — pull structure out of text: label each word with its part of speech, find the names of people and companies, or measure the sentiment of a review.
  • Generate — produce new language: write a summary, translate a sentence, or answer a question in full sentences.

The goal is simple to say and hard to build: machines should do what humans do when they talk to each other. The layered act of understanding that you perform without effort — context, word senses, topic, intent — is exactly what NLP tries to copy.

The direction flipped. For decades, humans bent toward computers. We learned programming languages, worried about syntax errors, and memorized library names. Instead of us learning the machine's language, the goal now is to teach the machine ours. Coding assistants already let you state what you want in plain English and they write the code. The machine has been trained to understand our natural language, so we no longer have to learn its.

Where does NLP fit in computer science? Picture a set of nested boxes. AI is the big umbrella — the whole project of making machines behave intelligently. Inside it sit machine learning (systems that learn from data), deep learning (learning with many-layered neural networks), and NLP itself. NLP borrows from all of them: a Naive Bayes classifier is a machine learning technique you might use for sentiment analysis, and transformers are deep learning techniques you use inside language models. NLP also borrows from linguistics, psycholinguistics, and cognitive science, plus math and statistics. So NLP is not one technology. It is an area — the way networks or cloud computing are areas.

Q: Is NLP the same as an LLM? Is it the same as an agent? Is it the same as AI? A: No. A language model is a part of NLP, not the whole field. NLP is a broad area — a subject like networks or cloud computing — and it is a component of AI. So the input/output framing is wrong; the right frame is area and part.

That exchange is worth lingering on, because it is the most common category mistake newcomers make. A language model is one family of techniques inside NLP. An agent is a system that uses language models. NLP is the whole subject that contains both, and NLP itself is one branch of AI. This course is about the whole area, not about one model family.

Scope: This course processes text only. Speech, images, and video are language-adjacent, but multimodal work belongs to other electives — and even there, speech and video usually get converted into words before further processing. Also note what NLP is not: it is not a single algorithm you download, and it is not a synonym for "chatbots". Every chatbot uses NLP, but NLP also includes a 1960s rule-based dialogue system and the tokenizer that prices your API bill. If the topic is "make machines handle human language", it is in scope; if the input is not language, it is not.

1.1.2 What This Course Covers

The course is built as a fundamentals course on purpose. Industry professionals consulted when the syllabus was designed made one point again and again: a degree-level program should teach understanding of the algorithms, not just API calls. In an agentic AI world where automated agents do most of the execution, the human's job is judgment — knowing when to apply which technique, which algorithm suits which application, and which model makes sense when you have SLMs, LLMs, nano models, edge AI, and physical AI all competing for your attention. The teaching principle is also deliberately old-school: go from known to unknown, easy to difficult, so nothing arrives above your head.

The topic list, in order:

  • Vector semantics — the idea that words become numbers. Machines crunch numbers far better than strings of letters, so you convert a word into a numeric vector. A word like "vector" gets represented by a list of weights, and those weights are learned by neural networks. The details of how the numbers are learned come in later modules (contextual embeddings, GPT-style models), but the concept is this: strings in, numbers out.
  • Word embeddings — the learned vector representations themselves, covered in the same block of modules.
  • Language modeling — starting with simple n-gram language models and moving up to neural language models and an introduction to large language models. The recap of transformers, attention, and LSTM is promised for later sessions (the class has already met attention in a deep neural networks course).
  • Classical NLP methods — part-of-speech tagging and parsing. The instructor makes a deliberate argument for keeping these: even in the agentic era, many applications still need them, and the session returns to that point later.
  • Post mid-semester: encoder–decoder models, attention mechanisms, contextual word embeddings.
  • Disambiguation — natural language is a live language, with new jargon appearing constantly (Gen Z slang and beyond), so resolving ambiguity is a core task.
  • Knowledge graphs — and their close relative, ontology. Nobody uses ontology directly anymore, but a knowledge graph is just a populated ontology, and the concept matters for RAG and especially GraphRAG, which is popular in industry.
  • Text summarization — the capstone application where all earlier techniques get applied.

Vector semantics, formalized. The whole idea of the first module block fits in one line: a word is mapped to a numeric vector of learned weights.

Read the pieces one at a time. On the left, the string "vector" is the input. The arrow says "is mapped to". On the right, (bold, for "vector") is a list of numbers: is the dimensionality — how many numbers we allow per word. Each entry is a real number, so the whole object lives in , the space of -tuples of real numbers. The word "learned" is the load-bearing one: the entries are not hand-crafted by a linguist. A neural network decides them during training, the same way a classifier learns its weights.

A concrete taste, with :

Two points. First, the individual numbers mean nothing by themselves — dimension 1 is not "noun-ness" and dimension 3 is not "math-ness". Second, what matters is the pattern: words used in similar contexts ("vector", "matrix") end up with similar vectors, which you can see here even by eye. That property — words in similar contexts get similar vectors — is the distributional hypothesis, and later modules build everything on it.

Picture a graph with two of these dimensions as its axes. "vector" and "matrix" land as two points close together in a corner; an unrelated word like "mango" lands far away. The whole field of word embeddings is about choosing those numbers so that closeness on the graph means closeness in meaning. One-sentence takeaway: you trade a word for a point, and then meaning becomes geometry.

Two books anchor the course. Jurafsky and Martin is the main textbook — the pioneer book of the field, used by nearly every college, and it covers roughly 80% of the course content. A free PDF of the updated 2024/2025 edition exists, and an Indian edition is also available; the authors also run Stanford's NLP course. James Allen's classic book is old — it predates much of modern deep learning — but its core concepts still hold, and the fundamentals part of this session draws from it. A third reference book is optional and mostly useful for advanced NLP applications later.

1.1.3 Why Study NLP

The students gave their own reasons at the start, and they map well onto the field's selling points:

Q: Why did you take this course? A: The reasons the class gave: NLP is more relevant to industry, text is the largest available data form, understanding LLMs matters, AI engineering and architecture are driven by NLP, and everyone wants deeper knowledge of the tools they use — how GPT actually processes language. Plus the honest one: it is trending, with more use cases than almost anything else.

There is a deeper argument underneath. We judge a person intelligent largely because they communicate effectively and know a lot about the world — finance, medicine, everything. Communication and knowledge are what language carries. Artificial intelligence, at its core, is the project of making machines intelligent, and language is the biggest lever we have on that project. A machine that can use language well can show, explain, and teach what it knows; a machine that cannot is stuck signalling through buttons and sliders.

One more structural fact supports the choice: text is the largest repository of data we have. Even speech and video usually get converted into words before further processing. A speech recording is language; a video's captions are language; text is language directly. This course focuses on text only — multimodal work belongs to other electives — and text alone is already enormous.

The market backs this up. Growth in LLMs and agentic AI has been explosive, and the job roles are real and named: NLP engineer, prompt engineer, data scientist, conversational-AI-focused data scientist, AI engineer, conversational AI engineer, computational linguist. Companies such as OpenAI and Anthropic became giants on the back of language models — and language modeling is a core NLP concept. In a bank or hospital, the NLP person is the one who knows which of those roles needs which technique. So NLP is hot, well-funded, and sitting at the center of current AI.

1.1.4 The Hal–Dave Test: Reading Language Cues

The session opened its content with a worked example designed to show how much implicit language skill humans have. The class was shown a short two-person dialogue and asked: who is the machine, and who is the human?

The dialogue is from 2001: A Space Odyssey: Dave gives Hal a command, and Hal replies, "I'm sorry, Dave. I'm afraid I can't do that." — and then suggests that Dave take a stress pill and get some rest. The class had to identify the machine. The discussion is worth replaying in full, because every answer is a distinct language cue.

Worked example: spotting the machine in the Hal–Dave dialogue.

The setup. Two speakers, one line each. One is human (Dave), one is a machine (Hal). No technology clues — only the words.

The turn-by-turn reading.

  1. Who starts the conversation? Dave commands; Hal obeys. The opener is the human, because a conversation that starts with a machine giving orders to a human is hard to imagine outside science fiction. The conversational role is itself a cue.
  2. How does Hal speak? Long, grammatically perfect sentences. Polite hedges everywhere: "I'm sorry... I'm afraid...". The name "Dave" sits mid-sentence — "I'm sorry, Dave" — which is the pattern a machine was trained on, not the way people actually talk.
  3. How would a human say it? Humans drop words, use short forms, and rarely build such polished sentences in casual talk. "Can't do that, sorry" is human; "I'm sorry, Dave. I'm afraid I can't do that" is a customer-service script.

The controls. If someone had planted a grammar error or two in the dialogue, the class would have suspected the machine instead — over-perfect and sloppy are both tells. The reading uses no outside knowledge of the film; the words alone carry the answer.

Final answer: Hal is the machine. The formal register, the sentence length, the politeness, and the roles all point the same way. Sense-check: nothing about the movie's plot was needed — which is the whole point, because a machine must reason from text, not from having watched the film.

Q: How do we know Hal is the machine and Dave the human? A: The first answer — "because I've seen the movie" — was rejected as a cheat. Knowing the film is real knowledge, but it is not a language-based reason; anyone who had not seen the movie needed a real signal. The real cues are language cues: the conversation starts with the human, because Dave commands and Hal obeys — a machine commanding a human is hard to imagine. Hal speaks formally, in long, grammatically perfect sentences, with polite hedges like "I'm sorry... I'm afraid...", and the name "Dave" sits in the middle of the sentence — the sort of pattern a machine was fed, not the way people speak. Humans drop words, use short forms, and rarely build such polished sentences in casual talk.

Notice what happened during that discussion: the class used formal register, sentence length, grammatical correctness, politeness, conversational roles, and emotional framing — all at once, without effort. That is the skill NLP wants to build. A related practical observation: generated text has fingerprints. A summary written by ChatGPT tends to differ in style from one by Claude or Gemini. With practice you start to spot the pattern in how each model formulates language.

There is a second layer in the same dialogue. Hal suggests a stress pill and rest. That is an attempt at emotional intelligence — reading Dave's state and responding to it. Human communication also runs on tone: you can hear anger in a voice that goes too quiet or too screamy, you can spot a forced smile from gestures that don't match the words, and you resolve situations by context ("look at the situation" is how parents explain outbursts to kids). Machines today can parse the words but are not yet emotionally intelligent — some are picking it up slowly, but this gap is exactly what makes language processing hard. The machine is only as good as its training data: garbage in, garbage out.

Pitfalls when reading machine vs human.

  • Using outside knowledge as a cue. "I've seen the movie" is real information, but it is a cheat: it does not generalize to any dialogue you have not seen. A language cue must come from the text itself.
  • Assuming polished means machine, always. Formal, hedged speech is a machine tell in casual conversation — but a human writing an official email, or a model prompted to be casual, breaks that heuristic. Cues work in combination, not one at a time.
  • Judging from a single sentence. Register, roles, and length only become reliable tells across a conversation. One short line gives almost nothing.
  • Forgetting the data ceiling. A model can only imitate the styles in its training data. If the data was garbage, the language behavior will be too.

1.1.5 Student Questions and Answers

Q: A student floated the idea that an LLM is an "input" to NLP. Is that right? A: No — the language model is not an input to NLP. NLP is an area, a subject like networks or cloud computing. A language model is a part of NLP, and NLP is a component of AI that helps machines understand, analyze, and generate language. Inputs to NLP are sentences, documents, and speech; a language model is a tool the field uses, not a thing the field consumes.

The confusion keeps coming up, so pin it down one more time: area, part, and component. NLP is an area (a whole subject). A language model is a part of it (one family of techniques). NLP itself is a component of AI. When you hear "LLM", think "one tool on the workbench", not "the workshop".

NLP is the branch of AI that makes machines understand, analyze, and generate human language — a broad area, not one technology. Its central trick is mapping words to learned numeric vectors, and its hardest problem is the implicit language skill humans show without trying, as the Hal–Dave dialogue made visible. Next, the same field is put on a timeline: where did it come from, and which old ideas still run under the hood today?

1.2 A Short History of NLP

Every field looks inevitable in hindsight. This short timeline shows otherwise: NLP reinvented itself every couple of decades, and each reinvention happened because the previous approach hit a wall. Knowing the walls is the fastest way to understand why today's systems look the way they do.

1.2.1 Rule-Based Systems: Eliza and the Turing Test

Hook: The applications people now treat as modern — conversational AI, machine translation, sentiment analysis — have existed for decades. A chatbot that comforted patients was running in the 1960s. A test for whether machines can "think" by language alone was proposed in 1950 — and today's chatbots have almost reached the point where you cannot tell.

The field started with rule-based systems, in an era with no compute power and no training data. With no data to learn from, humans wrote the knowledge down by hand — and for narrow domains, the rules worked well.

Two landmarks from that era. The Turing test: Alan Turing's challenge of whether a human can tell if they are talking to a machine or another human. The setup is a typed conversation: a judge exchanges text messages with two hidden partners, one human and one machine. Turing's claim: if the judge cannot reliably say which is which, the machine has won. Notice that this is a behavioral test — nothing about what happens inside the machine. That is also how modern NLP is judged, which is why the test matters.

And Eliza, an early rule-based chatbot — a kind of ancestor of Alexa — built in the 1960s by Joseph Weizenbaum at MIT, originally to converse with depression patients. Eliza had no statistics and no learning at all. It ran on handwritten rules: a script of patterns matched against what the patient typed. Type "I am sad", and a rule rewrites it into the question "Why are you sad?"; type "my mother makes me angry", and it asks "Tell me more about your mother". The trick was that the rules echoed the patient's own words back at them, so the conversation felt understood. Remarkably, patients did find some comfort talking to it — some asked for privacy so they could "speak" to it alone, even though they knew it was a program. This became known as the ELIZA effect: people read human intention into a system that merely reflects their words.

Even geopolitics helped. During the Cold War standoff between the US and Russia, early machine translation ran on rule-based approaches and proved genuinely useful. The 1954 Georgetown–IBM experiment translated a handful of Russian sentences with a hand-built dictionary and grammar rules, and it worked well enough to launch a decade of funding. The point for this course: with a small, well-defined task — sixty sentences about chemistry — rules alone are enough.

Scope of rule-based systems: Rules are strong where the domain is narrow and stable — a toy dialogue, a fixed template, a small dictionary. They break where language is open-ended: every new sentence pattern needs a new handwritten rule, the rules start contradicting each other, and nobody can maintain them. This is why the field kept moving. When you see a rule-based approach today, it is usually inside a bigger system, guarding one small, well-understood step.

1.2.2 Symbolic, Statistical, and ML-Based NLP

Next came symbolic NLP: context-free grammars, knowledge-based systems, and expert systems that encoded grammar and world knowledge by hand. A context-free grammar is a set of rewrite rules like "a sentence is a noun phrase followed by a verb phrase" — writing S → NP VP — with a lexicon that maps categories to words. Knowledge-based systems store facts in a database of logic; expert systems add if-then rules collected from human experts. The weakness was shared: everything had to be typed in by a human, and language kept refusing to fit the boxes.

After that came statistical NLP — data-driven approaches that became possible once data itself became available in quantity. Instead of writing rules about how language should work, you count how language does work in large text collections (corpora), and let probabilities decide: which word usually follows "the", which translation of a word is most common. The same grammar question — "is this sentence structure likely?" — now got a number instead of a yes/no.

Machine learning approaches followed: SVMs, decision trees, and the like. But ML approaches demanded labeled training data and manual feature engineering. Feature engineering is the job of hand-designing the inputs the classifier will see: word counts, word lengths, whether a word is capitalized, whether the text contains an exclamation mark. The engineer guesses which signals matter, then the model learns weights on them. Feature engineering was hard and error-prone: the guess was often wrong, and a feature that helped on one task hurt on another. That gap is exactly what the next era filled.

1.2.3 Deep Learning, Transformers, and the Agentic Era

Deep learning arrived precisely because feature engineering was a bottleneck: instead of designing features by hand, the network learns features on its own. Give a deep network raw text, and the early layers learn the useful signals — word patterns, then phrase patterns, then sentence patterns. Then came the breakthrough of word-to-vector representation — word2vec-style embeddings that turned words into dense numeric vectors (the same word-to-vector mapping from the previous section, now at scale). After that, the transformer era: the attention mechanism and everything built on it. And today, the agentic AI era, where language models stop being answer-machines and start acting — planning multi-step tasks, calling tools, and checking their own work.

The honest footnote from industry: not everyone is actually running agentic AI. It is compute-intensive and expensive. Practitioners report that agentic systems only make sense when there is a return on investment — otherwise it is, in the instructor's own analogy, like using a rocket to go to the market. The right tool depends on the application, and the course will keep returning to that judgment call.

Pitfall: newest is not always best. The era ladder reads like progress, and in many ways it is — but era-thinking breaks when you pick the tool. A transformer for a tiny spam filter is a rocket to the market. Rules still ship for narrow, explainable steps; statistical methods still win when data is small and you must justify every decision. Judge by the application's size, cost, and explainability needs, not by fashion.

1.2.4 Why History Matters: Old Fundamentals Still Run Today

History is not trivia here. Research progress is mostly gap-filling: you study what exists, find the issues, and work on those. It is rarely the apple-falls-on-your-head moment. So the lineage matters because each era solved the previous era's bottleneck — no data led to rules, no features led to deep learning — and the same pattern is repeating in the agentic era.

Here is the whole ladder in one table, with the resource each era had and the wall it hit:

Era Era's fuel How language was handled The wall it hit
Rule-based (1950s–60s) Human knowledge Handwritten rules and scripts (Eliza) Rules don't scale; language won't stay in boxes
Symbolic (1970s–80s) Grammar and logic Context-free grammars, expert systems Hand-encoding world knowledge is endless
Statistical (1980s–90s) Data and counts Probabilities over n-grams and word alignments Counts can't see far; data was scarce
Machine learning (2000s) Labeled data SVMs, decision trees on engineered features Feature engineering is manual and fragile
Deep learning (2010s) Compute Neural networks that learn features (word2vec) Needs massive compute and data
Transformers + agents (2020s) Scale Attention-based models that plan and act Expensive; explainability and trust unresolved

Read the last column top to bottom: each era exists because it removed the previous era's wall. When the agentic era eventually gets expensive and opaque enough, the same gap-filling logic says the next era will target cost and transparency.

The Fourier series analogy is the instructor's favorite proof that old ideas stay alive: invented long ago, and still used in speech recognition, in multimodal models, and in signal processing for images. Fundamentals from the James Allen era survive the same way. This session, the instructor promised, is the easiest one of the course — the trailer before the film.

NLP's history is a chain of bottlenecks: no data gave birth to rules, no features gave birth to deep learning, and each era's fundamentals — including the old rule-based ones — still run inside modern systems. Next: if the field is this old and this hard, what do people actually use it for?

1.3 Applications of NLP

Before any theory, the tour of what NLP actually does. These are the systems you already touch daily — the point is to notice them, and to see how many of them are the same machinery in different clothes.

1.3.1 Speech, Healthcare, and Everyday Automation

Hook: Count the NLP systems you used today. The autocorrect that fixed your typing, the assistant that read out a message, the search box that guessed your full question, the chatbot that refunded your order. Each one converts language — yours or someone else's — into a form a machine can act on.

Speech recognition is now basic plumbing. The Whisper API can transcribe you in a noisy market, with background noise cancellation built in. Whisper is OpenAI's speech-to-text model: audio in, written text out, trained on a huge mix of languages and accents, and exposed as a simple paid API — the same pattern as the other commercial NLP APIs this session surveys. Text-to-speech is equally easy — it can mimic a lecturer's voice so well that voice deep fakes are now a serious, separate challenge. Notice the asymmetry: making the tools easy also made the abuse easy, which is why the safety applications later in this section matter.

Real-world: healthcare. India is a high-population country with queues everywhere — hospitals, insurance, appointments. FAQ agents, triage agents, and conversational AI can speed all of that up. A triage agent is the first contact a patient talks to: it sorts cases by urgency — booking routine appointments itself, and routing chest pain to a human doctor immediately. Sorting incoming cases by severity is what hospital staff call triage, and it is one of the highest-value places to put a conversational system, because it moves the queue instead of just answering it. Real-world: e-commerce too — Amazon-style question answering systems handle customer queries the same way.

One of the most practical industrial applications is the dialogue interface to databases. Around 80% of industry data sits in databases of various kinds. Instead of learning SQL, joins, foreign keys and primary keys, you write a question in natural language, the system queries the backend, and it can even convert the result back into natural language for you. There are many open-source and proprietary APIs for exactly this.

Why this matters: a database is only as useful as the number of people who can ask it questions. SQL is a wall — joins (combining rows from two tables), foreign keys (columns that point to rows in another table), and primary keys (columns that uniquely identify a row) are all concepts a business analyst may never learn. The NLP version moves the wall: question in, SQL out, rows back, then a natural-language summary of those rows.

Worked example: natural language to database.

Question in: "Which products sold more than 500 units last month in Mumbai?"

The system's job: understand the question, then generate a query against the sales database — the equivalent of SELECT product FROM sales WHERE units > 500 AND month = 'last' AND city = 'Mumbai' — run it, and turn the resulting table into the answer.

Answer out: "Wireless earbuds (1,203 units) and water purifiers (612 units) sold more than 500 units in Mumbai last month."

Sense-check: the user never typed SQL, never named a table, and never saw a foreign key. The NLP layer absorbed all of it — understanding on the way in, generation on the way out.

Real-world: code agents are NLP applications too. "Write me code that does this — in Python, or Java, or whatever language" is natural language input that produces code. And search itself is NLP territory: in retrieval augmented generation (RAG), finding the relevant context out of a huge corpus is an NLP problem. RAG splits the job in two: a retriever finds passages that might answer the question, and a generator writes the answer using those passages as evidence. Both halves are NLP, and the course revisits RAG (and its knowledge-graph cousin GraphRAG) in a dedicated module.

1.3.3 Information Retrieval vs Information Extraction

These two sound alike and get confused constantly, so the contrast matters. Information retrieval is searching: given a topic, find the knowledge or the passages. Information extraction is different: pull out the structured pieces — named entities, relations, events. Given a paragraph, extraction answers: who is the person named here, what organization, what event?

Information Retrieval (IR) Information Extraction (IE)
Question it answers "Where can I read about this?" "Who, what, when, where — as structured fields?"
Input A query, a topic A document or paragraph
Output A ranked list of documents or passages Entities, relations, events — slots filled in a table
Granularity Whole documents Individual facts
Downstream use Reading, ranking, RAG context Databases, knowledge graphs, analytics

Take one paragraph: "Tata Motors announced a new plant in Pune on Tuesday." IR, given the query "Tata plant", returns this paragraph (and others like it) ranked by relevance. IE fills a table: organization = Tata Motors, event = announcement, location = Pune, date = Tuesday. Same paragraph, two different products. When to pick which: IR when the user wants to read, IE when the user wants fields — and many pipelines run IR first, then IE over the retrieved passages.

It is harder than it looks. The name "Tata" versus "Ratan Tata Foundation" — one string could be a person, an organization, or a company depending on context. Real-world: Amazon's NLP tools do relationship extraction — "X is the capital of Y", or "this person teaches NLP at that university" — automatically. Amazon also sells PII (personally identifiable information) detection for guardrail use.

1.3.4 Writing, Translation, and Safety Applications

Real-world: QuillBot bundles plagiarism detection, a "humanizer" that rewrites AI text, an AI chat, an image generator, an automatic summarizer, and citation generation in IEEE or ACM formats, plus grammar checking and paraphrasing. Most of it is open for small use, paid at larger scale. Real-world: Grammarly has made spell check and grammar check part of daily life. The instructor's nostalgia lands here: in school, Wren and Martin grammar drills were torture, and now nobody memorizes past participles because tools do it. Those tools are NLP applications.

Real-world: machine translation. Traveling in regions that prefer local languages is easier when MT is strong, and languages are worth preserving anyway — so translation stays a key application. Real-world: cybersecurity. Cyberbullying detection is a critical, growing NLP application — cyber cells around the world use NLP to detect these issues, and fake news and plagiarism detection belong to the same family. They share one core trick: classification over text. The difference is only what the labels mean — "toxic / not toxic", "fake / real", "plagiarized / original".

Pitfall: demos are not solved problems. Every application in this tour is real, but none is finished. Transcription still fumbles accents and jargon; translation still flattens tone; detection systems still make the wrong call on sarcasm — a teenager's "nice haircut" can read as praise to a classifier. When you build on these tools, budget for the errors: watch the edge cases before you promise accuracy.

1.3.5 Student Questions and Answers

Q: A question came in about relations between entities — how are they detected and stored? A: Relation extraction and how relations are represented will be covered properly in the next session. For now: a relation is a typed link between two entities ("capital of", "teaches at"), and extraction systems produce those links as structured triples.

NLP applications split into two families: read-and-find tasks (IR, RAG, search) and pull-out-fields tasks (IE, entity and relation extraction), wrapped in products for speech, healthcare, databases, code, writing, translation, and safety. All of them rest on the same small set of building blocks — which is what the next section surveys: the tools and libraries that provide those blocks.

1.4 NLP Tools and Libraries

Nobody builds NLP systems from zero. Every application in the previous section is assembled from pre-built pieces — and choosing which pieces is a core engineering skill in itself.

Hook: You would not write your own operating system to send an email. The same logic applies to NLP: tokenizers, taggers, and models already exist, battle-tested and free. The question is never "how do I build this from scratch" but "which existing piece fits my application, budget, and language".

1.4.1 Commercial Tools

The giants sell NLP as APIs. Google Cloud NLP offers pre-trained models for entity analysis (similar to information extraction), sentiment analysis, and document classification. Amazon provides relationship extraction (part of entity and relation extraction) and PII detection for guardrails. Microsoft Azure is strong at enterprise deployments, especially in healthcare. IBM is used across industries for text understanding. All of them are paid.

The commercial model is simple to understand: you send text to a hosted endpoint, and you get structured results back — no GPUs, no model downloads, no setup. What you pay for is three things: the trained model, the infrastructure that runs it, and the service guarantees (uptime, compliance, support) that enterprises demand. What you give up: control, transparency about what happens inside, and money that scales with every API call.

1.4.2 Open-Source Libraries

The open-source side is where most learning happens:

  • Hugging Face — the hub of language models, plus the Transformers and other libraries. Almost everyone in the field uses it.
  • NLTK — the classic NLP toolkit. Open source, very easy, needs minimal resources, runs fast, and dominates education and research because it is free. You can explore a huge range of tasks in NLTK, and today it even has bindings for deep learning transformers. Bonus: it supports many Indian languages — stop words, POS tagging, and more exist for Hindi, Marathi, Tamil, Bengali, and others.
  • spaCy — the industrial-strength alternative. Fast, production-oriented, and today optimized mainly for English (though it supports more languages).
  • Stanford CoreNLP — the Java option for those working in Java stacks.
  • TextBlob — a very easy library for many NLP tasks, popular in applications.

There are many more, but these are the ones industry actually reaches for.

Two rules of thumb cut through the catalog. First, paid API vs open-source library: pick the paid API when you want a hosted, maintained service with no infrastructure work and the budget exists; pick the open-source library when you need control, offline capability, zero per-call cost, or a language the APIs handle poorly. Second, heavy vs light: Hugging Face and spaCy carry real machine-learning models; NLTK and TextBlob are lighter, classical toolkits that run anywhere — the same lightness-vs-power trade the preprocessing section explores next.

Pitfalls when choosing tools.

  • Free tier blindness. Open-source means no license fee, not no cost — models still need RAM, GPUs, and engineering time. And commercial APIs have per-token bills that surprise people at scale.
  • Language coverage as an afterthought. If the application must handle Hindi or Marathi, the choice between toolkits changes. Check the language list before you pick the library, not after you built the demo.
  • Learning on the wrong tool. For this course, learn on NLTK and spaCy: they expose the concepts (tokenization, tagging, lemmatization) directly. A hosted API hides the very mechanics you are here to understand.

Commercial NLP APIs sell hosted, pre-trained convenience; open-source libraries sell control, transparency, and free learning. Most practitioners hold both sets of tools at once — and the next section opens the toolbox: a hands-on walk through the preprocessing steps every NLP system starts with.

1.5 Hands-On Text Preprocessing with NLTK and spaCy

Midway through the session, the class ran two small shared code notebooks (one NLTK, one spaCy) in Jupyter or Colab. They were deliberately simple — beginner level, runnable in seconds. The payoff is that every preprocessing step below is a real, runnable technique, not a diagram. Preprocessing is the front door of every NLP system: whatever you plan to do later — classify, retrieve, embed — the raw text must first be cut, cleaned, and normalized into pieces the machine can chew.

1.5.1 Tokenization: Splitting Text into Words and Sentences

Hook: A language model has never seen a "document". It sees numbers — specifically, small reusable pieces of text called tokens. Everything downstream, including your API bill, is counted in tokens. So the first question of every pipeline: how do we chop raw text into those pieces, and where exactly do the cuts go?

Tokenization — purpose and steps. Tokenization is splitting a bigger chunk of text into smaller pieces — sentences, words, or subwords.

  1. Sentence tokenization. Split the text into sentences. The demo imports nltk, the standard library modules string and re, and punkt (NLTK's tokenizer component). punkt is a trained model in its own right: it learned from real text where sentence boundaries tend to fall.
  2. Word tokenization. Split each sentence into words.
  3. The hard part is the punctuation. A full stop ends a sentence — but it also ends an abbreviation. The tokenizer must look at the context and decide, which is exactly what the demo shows.

Worked example: the "Dr. X" test.

Input text: "Hello all, I'm Dr. X. Welcome to the lab session."

Step 1 — sentence tokenizer. NLTK correctly splits the text into two sentences:

  • Hello all, I'm Dr. X.
  • Welcome to the lab session.

It even handles brackets cleanly. The interesting full stop is the one after "Dr." — it belongs to the abbreviation, not to a sentence boundary.

Step 2 — word tokenizer. The word tokenizer splits each sentence into individual words — and here is the impressive part: it does not split the full stop after "Dr." from the name. The token is Dr., not Dr + .. The tokenizer correctly tells the difference between a sentence-ending full stop and the abbreviation dot in "Dr.". NLTK makes that distinction automatically, because punkt has seen enough real English to know that "Dr." is usually an abbreviation.

Final answer: 2 sentences; in the first, the tokens Hello, all, ,, I, 'm, Dr., X, . — the abbreviation dot stays attached, the sentence dot stands alone. Sense-check: a naive split on every full stop would have produced three sentences and broken the title "Dr.", which is exactly the failure this example guards against.

Why care about subwords? This is the deep motivation. Words need to be split into smaller subword units so they can be stored and retrieved from memory efficiently. That is why every OpenAI-style bill is priced in tokens — tokens are the unit everything is measured in. GPT itself uses a more advanced tokenizer, byte pair encoding (BPE), rather than the simple space-based tokenizer shown here. BPE builds its cuts from data: it starts with characters and repeatedly merges the most frequent character pairs, so common pieces like "ing" or "tion" become single tokens. Later sessions will cover BPE, WordPiece, and SentencePiece properly, but the underlying concept is the same: split text into small reusable pieces.

Real-world: tokenization quality even explains model efficiency stories. When DeepSeek arrived, a big part of the "it is faster and cheaper" claim came down to a better tokenization technique — the same concept, executed better.

1.5.2 Punctuation Removal and Stop Words

After tokenization, the demo removed punctuation using the string library. Brackets, commas, and full stops may carry little meaning for many tasks — and every one of them still consumes a token. In RAG pipelines, where you retrieve context to reduce LLM hallucination, trimming useless punctuation shrinks token counts and costs.

Next, stop words. NLTK ships with a stop word list in its corpus — words like "down", "themselves", "be", "each", "you" — that may not carry much significance for the content. The demo removed words like "I", "am", "is", "are". You can also build your own domain-specific stop word list — different words matter in genomics than in finance — and NLTK lets you add custom lists.

Q: What does "stop word" mean exactly, and is stop word removal mandatory? A: Stop words are the words that may not carry much importance in a document — the short connective words people often drop in texts and messages, like "the", "a", "of". The words that carry significance are the important ones; the rest are stop words. Removal is optional and depends on the application: search engines and web-scale search do use stop word removal, and many ChatGPT-style systems use it too just to run faster and save token cost. You can always modify the list for your application.

Scope: preprocessing is application-dependent. For a grammar checker you must keep stop words — "a" versus "an" is the entire job. For conversational AI, question answering, or text summarization, removing them is often fine. The rule is not "always remove"; it is "remove only what your downstream task does not need". A stop list that helps retrieval can silently destroy a task that depends on those very words.

Two practical bonuses make this technique valuable. First, it is cheap: for a startup or small organization, classical preprocessing on light hardware gives good, accurate results without burning GPU money. Second, it is highly explainable — there are no mysterious failures, and hallucination risk is basically zero in these steps. And yes, the same removal works for local languages — Hindi, Marathi, Tamil, Bengali, and also French and German.

1.5.3 Lemmatization and Stemming

Both techniques compress word forms back toward a shared base. Every word has a lemma — the root word — plus an affix or suffix. This is the same idea BPE uses: break the whole word into subparts. If "processing" becomes "process" + "ing", and "interested" becomes "interest" + "ed", then you store one embedding for "interest", one for "ing", one for "ed" — and you cover interested, interesting, interests, and more without storing each full word separately.

Two ways to reach the base form. Lemmatization strips suffixes by consulting a dictionary — WordNet or a domain dictionary. Because it looks words up, meanings stay intact, but it can keep words longer, and it needs that domain knowledge to work. Stemming is the fast, generic cousin: it applies fixed rules without looking at meaning. The classic algorithm is the Porter stemmer, with Snowball, Lancaster, and Regex stemmers as alternatives.

The two techniques sit on different ends of a trade-off:

Stemming Lemmatization
Method Fixed rewrite rules on word endings Dictionary lookup, then suffix removal
Knowledge needed None — same rules for every domain WordNet or a domain dictionary
Speed and size Fast, tiny, no storage Slower, needs the dictionary loaded
Meaning safety Can produce non-words ("natur") Always returns a real word with its meaning intact
Typical use Search, clustering, anything cheap and coarse Tasks where the exact word matters

Worked example: what the Regex stemmer actually did.

The demo results showed exactly the trade-off.

  1. "friendship" → Regex stemming reduced it to "friend", stripping the "s" (and the "hip" that follows it — the stemmer's rules are greedy, not careful).
  2. "natural" → reduced to "natur" by removing "al". "Natur" is not an English word.

Read the two results as a pair. "friend" is a win: "friendship", "friends", and "friend" now all map to one base, so the system stores one embedding instead of three. "natur" is the cost: slightly wrong, but fast, small, and fine for many tasks where the exact word does not matter — search and clustering do not care that "natur" is not in the dictionary. Lemmatization would keep the forms more intact ("friendship" stays "friendship"; "natural" stays "natural") but needs the dictionary behind it. Sense-check: stemming optimizes coverage at the price of precision; lemmatization pays for precision with a dictionary.

Q: What is a domain dictionary, and how does it change lemmatization? A: A domain dictionary lists the terms that matter for your field — for example, in an AI/ML domain dictionary you would say that "natural language processing" must be kept as it is, and "processing" must not be reduced to "process". Only outside that dictionary entry — say, "digital processing" — would suffix stripping apply. You give the dictionary before the suffix stripping runs, so the domain decides what gets broken up.

That is the dictionary side. The next question pushes one level deeper, into the rule mechanics themselves.

Q: How are stemming and lemmatization different, at the rule level? A: Stemming uses a fixed set of rules. For example: if a word ends in "ing" and the letter before "ing" is a consonant, remove the "ing"; if the letter before is a vowel, do not remove it. These are generic rules that ignore meaning and stay the same across every domain. Lemmatization instead looks at a dictionary (WordNet or a domain dictionary) and then decides whether to strip the suffix, so it needs domain knowledge and keeps meanings. Stemming is generic; lemmatization is domain-aware.

The practical advice: there are many ready-made stemmers and lemmatizers — like sklearn, you don't write the algorithm from scratch — and you can try multiple stemmers and pick whichever gives the best results for your data.

1.5.4 Part-of-Speech Tagging and WordNet

NLTK also ships a POS tagger — the perceptron tagger, a neural-network-based library that labels each token with its part of speech: noun, verb, and so on. The demo output used tag codes like DT and JJ (determiners, adjectives, and the rest) — those will be explained in the dedicated POS tagging module later.

Why tag at all — the pipeline chain. Named entities — person names, organization names — are typically proper nouns or common nouns. They are not adjectives or adverbs. So POS tags are a strong signal for named entity recognition (finding the names in text), which feeds relation extraction and events, which feed conversational AI: to book a movie ticket the system has to know which words are movie names, dates, and places. The chain is interlinked: tokenization feeds tagging, tagging feeds entities, entities feed dialogue. Each stage narrows the ambiguity of the text and hands a cleaner structure to the next stage.

Two codes, decoded here so the demo output is readable: DT is a determiner (words like "the", "this" that point at a noun), and JJ is an adjective (words like "blue", "tall" that describe a noun). The dedicated POS module covers the full tag set; for now the point is that a code like JJ tells a downstream system "this word describes things, so it cannot be a person name".

The demo also touched WordNet — the lexical database of word meanings — but only in passing; it returns properly in the word sense disambiguation module. One preview of why it matters: WordNet organizes words into meaning relations — "cat" is a kind of "animal", "tire" is a part of "car" — and those relations are the raw material for resolving word senses. There are many ready-made POS taggers, open source and free, that need almost no compute.

1.5.5 NLTK vs spaCy: Student Questions and Answers

The spaCy notebook ran the same ideas — tokenization, stop words, lemmatization, POS tagging — and handled the same "Dr. X" example correctly. The visible differences: spaCy tokens also carry their character position in the text (which NLTK does not report), and spaCy's POS output spells things out in full ("proper singular noun") where NLTK gives codes. spaCy is faster; NLTK gives fewer extras.

Q: What is the basic difference between NLTK and spaCy, and when should I use which? A: Both are open-source libraries, like having multiple APIs for the same job — think OpenAI versus Gemini. NLTK was the original library, with very broad multilingual support. spaCy is optimized for English and is fast; NLTK supports a lot more languages. Most people use NLTK for preprocessing; spaCy is often chosen for things like dependency parsing. They are interchangeable for much of the work — you can use spaCy without NLTK. When multilingual support matters, check how many languages spaCy covers; NLTK covers many.

On the lab side, one practical note: the virtual labs earn marks — using them for the programming assignments earns one or two marks — so they are worth the setup friction.

Q: The virtual lab VM shuts down after about 15 seconds when the mouse is idle, but training runs take 30 minutes. Do I have to keep moving the mouse? A: Report the issue to the lab support team — they have improved the labs this term. If a lab problem is genuinely blocking, running on a local machine or Google Colab is allowed as a fallback, but try the labs first.

Preprocessing is a four-step assembly line — tokenize, clean (punctuation and stop words), normalize (stem or lemmatize), tag — and every step is application-dependent: keep what your task needs, cut what it does not, and prefer the cheap, explainable classical step until the task demands more. The next section flips the lens: these steps exist because raw language is deeply ambiguous, and the pipeline is the field's answer to that mess.

1.6 Why Language Is Hard: Ambiguity Everywhere

1.6.1 Sources of Difficulty

Hook: NLP is roughly fifty years old and still going strong — which tells you something about the size of the problem. Fifty years, and the state of the art still cannot reliably tell a river bank from a money bank without help. Human language is a moving target that humans themselves keep changing.

Language has rules, and rules have exceptions. English is famously irregular — sometimes "an" attaches before words that merely sound vowel-like: you say "an hour" (silent h, so it sounds vowel-initial) but "a university" (starts with the y-sound of "you"). Nobody taught you that rule explicitly; you absorbed it. And every language, from French to any Indian language, has its own thicket of rules and exceptions — each one a separate pile of traps for a machine.

Then there is ambiguity. The word "cool" meant something boring a generation ago and now means everything is fine. Gen Z uses words sarcastically, inverting meanings. Some things are culturally acceptable in one country and not another. New words keep entering the dictionary — words like "tandoori" and "yoga" have been absorbed into English. Add Gen Z jargon and emoticons, and the input is noisy. For humans this is all obvious and effortless. For machines, it is a very difficult training problem — because every one of those shifts breaks the assumption a machine is trained on: that words keep their meaning.

1.6.2 Worked Example: The Black Panther Booking Dialogue

A four-line dialogue with a conversational AI system shows how much a machine must do. Walk through it turn by turn.

Worked example: four lines, six skills.

Turn 1 — User: "Where is Black Panther playing in Mountain View?"

The system must recognize that Black Panther is a movie name — not a color plus an animal. It must recognize that Mountain View is a place — not a view of a mountain. Then it must infer that the user wants a theater, that theaters have locations, and that it needs geographic information to answer. The system resolves all this and answers with the theater: Century 16, in Mountain View.

Turn 2 — User: "When is it playing there?"

Now coreference resolution kicks in: linking a pronoun back to what it stands for. The system must infer that "it" refers to Black Panther and "there" refers to Century 16. It answers with three time slots: 2 p.m., 5 p.m., and 9 p.m.

Turn 3 — User: "Book me for the first show."

The system must infer that among the three time slots, 2 p.m. is the first show. "First" is a temporal inference over the list it just offered — the list order now becomes meaning.

Turn 4 — User: "I want one adult and two children."

Now the system must check seat availability, look up the adult ticket cost and the children ticket cost, and verify whether children are allowed at all for this show — then compute the total. The booking is no longer about language at all; it is about constraints and arithmetic, and the language layer must hand off cleanly to them.

Sense-check: every turn added a layer — entity recognition, place disambiguation, coreference, temporal inference, constraint checking, arithmetic — and no turn gave the system explicit instructions to do any of it. The user said "it", "there", and "first", and expected to be understood.

None of that information needed to exist at training time. A modern agentic system reaches out at run time — external APIs for the theater, calculator access for the total — and composes an answer. But look at what four short lines demanded: named entity recognition, place disambiguation, coreference, temporal inference, constraint checking, and arithmetic. A human does it without noticing. That gap is the field.

1.6.3 How Humans Process This Dialogue

The instructor turned the question on the class: how did you know Black Panther was a movie and Mountain View was a place?

Q: How are you able to figure all of this out — the movie name, the place, the references? A: The class's answer: we have learnings from the past — a knowledge base. We have world knowledge and discourse history. The word "playing" tells us an action is happening, which makes "Black Panther" a noun in a movie context. The sentence is grammatically correct in a familiar order. Scramble it — "Where is Mountain View playing in Black Panther?" or "Black Panther, where playing in is Mountain View?" — and even a human struggles. So syntax, word order, world knowledge, and context all do the work invisibly.

That is the uncomfortable part: you cannot point to the step where you decided "Black Panther is a movie". It was not a lookup in a dictionary, and it was not a grammar rule you applied consciously. Your knowledge base (everything you have seen and heard), your discourse history (what was said earlier in this conversation), the word "playing", and the familiar sentence order all voted together, instantly. A machine has to rebuild each of those votes from scratch — which is why the scrambled-sentence experiment works: break the word order, and the whole vote collapses, for humans too.

1.6.4 Word Order and Structural Ambiguity

Bag-of-words models make the point crisply. A bag-of-words model is exactly what it sounds like: the text is reduced to the set of words it contains, with every word's position thrown away — like shaking all the words out of a sentence into a bag. Compare two sentences:

Worked example: the Namrata swap.

  1. "Namrata thinks she understands me."
  2. "She thinks Namrata understands me."

Swap "Namrata" and "she" and the meaning flips — in the second, "she" is someone else entirely, a third person, and Namrata is the one being understood. Yet the bag of words is identical: {Namrata, thinks, she, understands, me}. A bag-of-words model sees both sentences as the same input, and is forced to give them the same output. Final answer: the two sentences mean different things with identical bags — so word order carries meaning that the bag destroys. Sense-check: any model that must distinguish these sentences needs some record of position or grammar.

A second classic: "Visiting relatives can be a nuisance."

Q: Does this sentence have two meanings? A: Yes. One reading: we are visiting the relatives, and that is a nuisance. The other: the relatives are visiting us, and that is a nuisance. Read "visiting" as a verb and you get one meaning; read "visiting relatives" together as a compound noun and you get the other. You did not consciously run a grammar parser to find this — the analysis happened implicitly in your head, as it has been happening since childhood.

The deeper point: the same word can have multiple parts of speech, and the meaning changes with the part of speech — exactly what happened with "visiting". This is structural ambiguity: the words are fixed, but the grammar tree can be built two ways, and each tree yields a different meaning.

1.6.5 Lexical Ambiguity and Changing Meanings

More everyday cases:

  • "I go now." Translate this into an Indian language and you must commit to gender. In Marathi, "mī jāte" (मी जाते) marks a female speaker, "mī jāto" (मी जातो) a male one. English hides the information; the translation forces it out.
  • "Can." A milk can or water can — a noun, a container. "Can I go?" — a modal verb. And a third meaning many people miss: to can is to pack something (as in canned food). One word, three parts of speech.
  • "Bank." River bank or financial bank? Only context decides.

Pitfall: the one-vector-per-word trap. A naive model stores a single fixed vector for "bank" — one point in space. But "bank" is two unrelated words sharing a spelling: the river sense and the money sense. Squeezing both into one vector gives you a point that is neither, and both senses get worse. This is why a fixed vector cannot capture the senses, and why contextual word embeddings were a breakthrough: the vector for "bank" is built fresh each time from the surrounding words, so "river bank" and "bank account" land in different places. The trap, then: assume words have stable meaning, and every ambiguous word quietly degrades your model.

These ambiguities are not edge cases — they are the reason contextual word embeddings were a breakthrough. A fixed vector for "bank" cannot capture both senses; a context-dependent vector can. The closing quote of the session, from Khalil Gibran, says the same thing in one line: "Wisdom is not in words. Wisdom is meaning within the words."

Language is hard because meaning lives in context, not in words: order, word class, world knowledge, and discourse all shift what a sentence means, and the same word means different things in different settings. Next, the field organizes this difficulty into a clean stack — the six levels of language understanding, from word parts up to whole conversations.

1.7 The Six Levels of Language Understanding

Humans build language understanding in layers, starting from the very first words learned in childhood, and the field maps its work onto those layers. The stack runs: morphological, lexical, syntactic, semantic, pragmatic, discourse. Today's systems sit around the pragmatic level; discourse still has work to do. Each higher layer assumes the lower layers are already handled.

Hook: Picture a six-floor building. Each floor stands on the one below it, and each floor answers one question about a sentence. Floor 1 asks "what are the word parts?"; the top floor asks "what did that earlier sentence mean for this one?" A system that skips a floor collapses when the question of that floor matters — which is why the field named and studies all six.

Level Question it answers Example of the knowledge
Morphological How are words built from parts? "un-" + "friend" + "-ly"
Lexical Which parts legally combine with which words? "friendship", never "friendful"
Syntactic What word orders are grammatical? "I eat mango", never "I mango eat"
Semantic What does the sentence mean? "green ideas" carries no meaning
Pragmatic What did the speaker mean in this world? "cut the banana with a pen" fails
Discourse How do sentences connect over distance? "they" = the king and queen, pages earlier

1.7.1 Morphological Knowledge

Morphological knowledge is about word structure. Every word can be built from a morpheme — the smallest meaning-carrying piece, which is the same thing as the lemma, the root word, from the lemmatization demo. A book like Word Power Made Easy (the classic GRE vocabulary book) teaches exactly this skill: if "-logy" means "the study of something", then biology is the study of life and bioinformatics is information about life. You can figure out unknown words by knowing the parts. BPE and subword tokenizers encode the parts of words for exactly this reason — they capture the affixes and suffixes, the reusable pieces.

The textbook version of this level sorts word-building into three processes: inflection (grammatical variations of one word: walk, walks, walking — same word, different grammatical clothes), derivation (making a new word class: wide → widely, weak → weaken), and compounding (joining two words: tea kettle, disk drive). All three matter to machines for one reason: language is productive. Any text you process will contain words nobody has listed in a dictionary, and the only way to handle them is to understand their parts.

1.7.2 Lexical Knowledge

Lexical knowledge is about which affixes attach to which words. It is beautiful, not "friendful". It is friendship, not "beautyship". Over years of exposure, your brain's neural network learned which suffix goes with which word. Lexical knowledge is the learned wiring of which combinations are legal.

Push the pattern one step and you feel the rule you carry: you accept "unhappy" but not "unsad"; "happiness" but not "angriness". There is no master list you memorized — your exposure to language wired in the frequencies. That is precisely the signal a machine can learn too: show it enough text, and it picks up that "friendship" happens and "friendful" never does. This level is the quiet bridge between the previous two: morphology says what the parts could build, lexical knowledge says which builds the language actually accepts.

1.7.3 Syntactic Knowledge

Syntactic knowledge is grammar — and every language has its own. English is SVO: subject, verb, object. "I eat mango." Indian languages are typically SOV: "Mī āmbā khātē" — the verb comes at the end. In Marathi the verb also agrees with the speaker's gender: "मी आंबा खातो" (mī āmbā khāto) for a male speaker and "मी आंबा खाते" (mī āmbā khāte) for a female speaker — the word order rule and the gender rule ride together. You would never say "I mango eat" in English, because you know the grammar of your language. And for complex sentences, wrong grammar makes meaning unrecoverable — you cannot even parse what was meant.

That last sentence is the reason syntactic knowledge sits below semantics in the stack: if the word order is scrambled past recognition, the meaning layer has nothing to build on. Grammar is not decoration; it is the load-bearing structure meaning stands on.

1.7.4 Semantic Knowledge

Semantic knowledge is where meaning lives. Contextual word embeddings, attention, and the whole semantic layer of modern NLP are trying to capture meaning. The demonstration sentence: "Green ideas have large noses." Grammatically perfect. Meaningless — ideas cannot be green, and ideas cannot have noses. You know the words "green" and "ideas" don't combine into meaning. That knowledge is semantic.

The classic version of this sentence is "Colorless green ideas sleep furiously" — grammatically flawless and semantically empty. Both versions make the same point: grammar can pass while meaning fails. A machine that only checks syntax would happily accept "green ideas have large noses" as a good sentence; a machine with real semantic knowledge must notice that nothing in the world is a green idea with a nose.

1.7.5 Pragmatic Knowledge

Pragmatic knowledge is meaning in the world, not in the dictionary.

Worked example: the pen that cannot cut a banana.

The sentence: "Cut the banana with a pen."

Semantic reading: every word combines legally and meaningfully — "cut" takes an object and an instrument, "banana" is a cuttable thing, "pen" is an object you can hold. The sentence has a reading. Semantically fine.

Pragmatic reading: you know from world knowledge that the instrument for cutting fruit is a knife, not a pen. (In an Indian travel scenario, a steel spoon might do — but you know that is not the standard instrument either.) So the sentence is pragmatically wrong: the words parse, the world refuses.

What saved the reading: not the dictionary. Your semantic memory (what things are: pens write, knives cut) plus your episodic memory (what happened when you tried odd tools) supplied the world knowledge that says a pen does not cut bananas.

Sense-check: the same words would be perfectly fine in a cartoon, where world knowledge is different — which proves the failing ingredient was world knowledge, not language.

This is the level where agentic AI systems struggle today. The connection to agent memory is direct: semantic memory holds what things are; episodic memory holds what happened; together they supply the world knowledge that says a pen does not cut bananas.

1.7.6 Discourse Knowledge

Discourse knowledge is cross-sentence connection — coreference stretched over distance. "She" refers back to Namrata across sentences, not just within one. The context window in an LLM is discourse knowledge in machine form: give a model 50,000 tokens of history and it can figure out meaning after 50,000 words. The childhood story example: "There was a king and a queen. ... They lived happily together." You know "they" means the king and queen, even paragraphs later. That is the context window you carry in your head.

Notice what makes discourse different from every lower level: nothing in a single sentence tells you who "they" is. The information lives in the history — in sentences already said. A model with a context window stores that history and consults it; a model without one faces every sentence alone, and "they" means nothing.

1.7.7 These Levels Inside LLMs and Agentic Systems

Modern agentic systems use all of these levels without advertising it. A conversational AI system that finds user intent is doing syntactic, semantic, and pragmatic analysis. Personalization uses personal history and goals — discourse and pragmatic knowledge in action. The reason contextual word embeddings were a breakthrough is exactly this: they capture the meaning of words through vector representation, and in the agentic era, capturing user intent is the same problem one level up. If the intent is wrong, the output is weird — and nobody wants weird outputs.

Language understanding is a six-layer stack — morphological, lexical, syntactic, semantic, pragmatic, discourse — where each layer stands on the one below and each answers its own question about a sentence. Machines today are solid at the lower layers and climbing toward pragmatic and discourse. Next, the same stack appears inside real NLP systems: the anatomy of a system that must both understand and generate.

1.8 Anatomy of an NLP System

The applications, tools, and preprocessing steps all snap together here. This section opens the hood and shows what a complete NLP system looks like on the inside — and why the design that wins in production is neither the classical textbook diagram nor the pure transformer.

1.8.1 Understanding and Generation

Hook: Every conversation you have is really two skills: listening, then replying. An NLP system is the same. Whatever the application — question answering, conversational AI, machine translation, summarization — the system first has to understand the input and then has to generate the output. A system that is great at one half and broken at the other is not half-good; it is useless.

The two mirrored halves. Every NLP system has two halves, and they mirror each other.

The understanding half (in): Input can be text or speech (speech-to-text converts it first). On the way in, the system does grammatical checking — modern LLMs silently correct your spelling errors and grammar, so you don't have to be an English expert. Then it applies domain knowledge — this is the RAG idea, providing context so the system can figure out what the user wants. So two knowledge sources feed understanding: general language knowledge (grammar, vocabulary, sentence structure) and application-specific knowledge (what this user's domain is about).

The generation half (out): Generation needs the same pieces in reverse: correct grammar, correct spelling, and domain knowledge, so the output is real sentences, not gibberish. The mirror matters because both halves fail the same way — an LLM that misunderstands the user produces a confident wrong answer, which is exactly what "hallucination" is. Even prompt engineering relies on this split: the prompt must make the understanding half succeed, or the generation half has nothing true to say.

Picture the classical pipeline diagram from the James Allen era: text enters on the left, passes through a row of boxes — input, syntactic analysis, semantic analysis, domain knowledge — and exits on the right as generated text. The exact boxes changed over the years, but the shape never did: understand in, generate out. That shape is the anatomy of every NLP system that has ever shipped.

1.8.2 Classical, Modern, and Hybrid Systems

The diagram from the James Allen era looks dated, but the blocks are the same; only the implementation differs.

The classical system: input, syntactic analysis, semantic analysis, domain knowledge, and generation — all explicit, hand-built stages. Each box is a separate program you can open, read, and debug. The cost is that every box had to be built by hand, which is why the classical systems were narrow and brittle.

The modern system: input, tokenization (text preprocessing), then a transformer that does syntax and semantics internally — with no transparency. It is not explainable; parameters and GPUs replace explicit steps. The transformer is a single box that learned to do what the classical row of boxes did, but nobody can point to where the syntax stage lives inside it.

The hybrid system is what production actually uses. Classical preprocessing (tokenization, stop word removal, lemmatization) replaces the expensive transformer for the basic steps. Then retrieval models — RAG tools, agentic flows, or vector databases for traditional RAG — provide context. Then the LLM generates. Then classical post-processing cleans up generation.

Classical Modern Hybrid (production)
Syntax and semantics Explicit hand-built stages Inside the transformer, invisible Split: cheap steps classical, hard steps in the LLM
Context / domain knowledge Hand-encoded rules Baked into model weights Retrieved at run time (RAG, vector databases)
Explainability Fully explainable A black box The classical parts stay explainable
Compute cost Tiny — runs anywhere GPUs required GPUs only where they pay off
Maintenance Every rule by hand Retrain / fine-tune Mix of both

One sentence to pick: classical when the task is narrow and you need explanations; modern when the task is broad and you have GPUs; hybrid — the production default — when you want the cheap classical steps to do the cheap work and the LLM to do only the expensive, genuinely hard work.

1.8.3 Why Hybrid Systems Win in Production

The economics decide. Transformers need GPUs, and GPUs are expensive: an A800 or H800 — the "800-series" GPU the instructor quoted — runs about 5–6 lakh rupees, and an H100 costs more, around 12 lakhs. Four GPUs at 5 lakhs each is 20 lakhs — unaffordable for a startup doing basic text processing. Lighter classical preprocessing runs anywhere and gives good results for simple tasks.

The engineering argument is transparency. The preprocessing steps are highly explainable and their hallucination risk is basically zero.

Pitfall: the black box has no clues. If you treat the transformer as a black box, tomorrow it will do something strange and you will have no clue why. Classical steps leave a trail — you can see exactly which token got dropped and why. The transformer leaves none. That is the engineering reason the hybrid design keeps classical steps around the LLM: when something goes wrong, you want at least part of the system to be explainable, so the failure can be found. The instructor's production story makes the same point from the practitioner side: real-world systems use hybrid designs, so knowing what the transformer does internally — which is what this course teaches — is what lets you make intelligent calls.

Two final cost notes. One: agentic AI is resource-intensive; use it only when there is a return on investment, otherwise you are taking a rocket to the market. Two: prefer search engines over LLMs when you are just looking things up — LLMs have roughly 100 times the carbon footprint, meaning far more resources consumed.

Every NLP system is understand-then-generate, and the winning production design is hybrid: cheap, explainable classical preprocessing at the edges, retrieval for context, and the LLM only in the middle where the hard work is. Next, the last anatomy question: once a system is built, how do you prove it is any good — the metrics, data, and economics of evaluation.

1.9 Evaluating NLP Systems

The system is built. Now the uncomfortable question: is it any good? This final section turns evaluation into a checklist — the right metric, the right data, the right economics, and the ability to explain failures.

1.9.1 Why Evaluation Matters

Hook: A client will not accept a production system that fails on edge cases, and you cannot blame the model for the failures — the instructor's joke has a sharp edge: "Your bank lost money? Go catch hold of OpenAI." The client does not want to hear who to sue; they want the failure rate before it becomes a lawsuit. Reliability, certainty, and accountability have legal implications, and evaluation is how you get them. A good NLP practitioner knows which metric to use for which application.

1.9.2 Classification Metrics: Accuracy, Precision, Recall, F1

The session assumes you already know these from earlier ML/DL courses, so it does not derive them — but the standard forms are included here for completeness, because every later metric in this course leans on them. The starting point is the confusion matrix: four counts of what a classifier did. With true positives (TP, the correct hits), true negatives (TN, the correct rejections), false positives (FP, the false alarms), and false negatives (FN, the misses):

The four counts and the four metrics. Every classification metric is a ratio built from TP, TN, FP, FN.

Accuracy is the share of all predictions that were right — hits plus correct rejections over everything.

Precision is the share of positive predictions that were right — of everything the system flagged, how much was really a hit. Recall is the share of real positives the system caught — of everything that should have been flagged, how much it found.

F1 is the harmonic mean of the two: it is pulled down hard when either precision or recall is low, so a system must do well on both to score well. Every symbol above is a count of examples, so every metric lands in .

Worked example: a sentiment classifier on 100 reviews.

A classifier labels reviews positive or negative. On 100 test reviews the confusion matrix is:

Predicted positive Predicted negative
Actually positive TP = 60 FN = 10
Actually negative FP = 5 TN = 25

Accuracy: . The system is right 85% of the time.

Precision: . Of the 65 reviews it called positive, about 92% really were.

Recall: . Of the 70 genuinely positive reviews, about 86% were caught.

F1: .

Final answers: accuracy 0.85, precision 0.923, recall 0.857, F1 0.889. Sense-check: precision and recall are both high, so F1 sits near them; accuracy is lower because the classifier leaked 5 false alarms and missed 10 positives. A different metric highlights a different failure — which is exactly why metric choice matters.

Accuracy and F1 dominate classification tasks like sentiment analysis and spam detection. Precision and recall matter most where errors are asymmetric — fraud detection and medical scenarios. The session's most memorable example: in cancer research, both false directions are dangerous. A false positive tells a healthy person they have cancer, and the mental damage is real. A false negative tells a sick person they are fine, and that can cost a life. In such scenarios you must control both, and the choice of metric is part of the design.

Pitfall: the accuracy trap. Accuracy lies when the classes are unbalanced. A spam filter that calls everything "not spam" scores 98% accuracy on a mailbox where 98% of mail is genuine — and catches zero spam. Before you report a number, ask which error costs more: a false alarm (precision) or a miss (recall). Pick the metric that punishes the expensive error, not the one that flatters the system.

1.9.3 Task-Specific Metrics: BLEU, ROUGE, Perplexity

Different tasks need different yardsticks. BLEU is the standard for machine translation: it compares the system's translation against human reference translations by counting matching word sequences, with a penalty for very short outputs. ROUGE is used for text summarization: it measures how much of the reference summary's wording the system's summary recovers. Perplexity is the language modeling metric — it measures how good the LLM is, in one number: the inverse probability the model assigns to a test text, read as "how surprised is the model by the next word". Lower surprise means a better model. It will be covered properly in the language modeling module. (The Perplexity product many students know is a separate thing — the name is borrowed.) The later modules cover BLEU and ROUGE in detail; for now, know which metric belongs to which task.

1.9.4 Data Quality: Generalization and Fairness

The data decides the system. It must generalize — test performance must match training performance, with no overfitting, and it must hold on diverse, unseen datasets. Overfitting is the specific failure this guards against: the model memorizes the training examples instead of learning the pattern, so it scores well on the training set and collapses on anything new. It must be fair: no gender bias, no caste bias, nothing baked in. Bias is not a bug in the training code — it enters through the data, and once a biased pattern is in the training text, the model treats it as truth. Garbage in, garbage out — low-quality input data produces a system you cannot trust, and trust is fragile. One visible failure and users abandon the system, and in enterprise deployments a faulty model loses customers.

1.9.5 Efficiency: ROI, Latency, and Cost

Efficiency is an evaluation criterion too. Return on investment: if the infrastructure costs a crore of rupees, you expect at least two crores back. Latency matters more than people admit — measured as time to first token, the delay between your query and the first word of the answer appearing. If ChatGPT took ten minutes to produce its first result, you would stop using it. Users have lost their patience; results need to arrive within seconds, or at worst a minute or two. The system also has to scale — handling ten users is not the same as handling ten thousand, and an evaluation that ignores load is testing a demo, not a product.

1.9.6 Observability and Root-Cause Analysis

Finally, observability: can you reproduce a result by repeating the same steps? Do you know when failures happen and why? Which errors are most prominent, and what causes them? Root-cause analysis of failures is evaluation too — a system is not "evaluated" if you cannot say why it failed, only that it did. The scale problem makes this urgent: a large language model can have 145 billion parameters, a small language model 1 billion, some models a few million, and nano models around 100,000. With that many parameters, explaining why a system behaved a certain way is one of the biggest open challenges in AI — and it is why governance has become such a big issue.

Evaluation is not one number; it is a checklist: the metric that matches the task (accuracy, F1, BLEU, ROUGE, perplexity), data that generalizes and stays fair, economics (ROI, latency, scale), and observability for root-cause analysis. Next, two closing appendices: the exam structure for this course, and the consolidated list of industry applications from today.

Exam Guidance Summary

Everything the session said about how this course is graded and run, in one place.

  • Weightage map. Two quizzes worth 5% total, with the best of the two counted. Experiential learning / lab assignment 1: 12%. One more assignment covering pre-mid-sem and post-mid-sem material: 13%. A closed-book makeup exam worth 30%, and an open-book end-semester (comprehensive) exam worth 40%.
  • Deadlines are hard. There is no extension for any quiz or assignment. The dates have already been shared — mark them in advance.
  • Virtual labs earn marks. Using the virtual labs for programming assignments earns one or two marks, so use them. If the labs are genuinely blocking (e.g., the VM idles out during long runs), a local machine or Google Colab is allowed as a fallback — but try the labs first, and report lab problems to the lab support team.
  • Groups. Programming assignment groups may be formed across sections.
  • Assumed knowledge. Accuracy, precision, recall, and F1 are assumed known from earlier ML/DL courses and will not be re-derived. BLEU, ROUGE, and perplexity will be covered in later modules (machine translation, summarization, language modeling respectively).
  • Textbook. Roughly 80% of the course content comes from Jurafsky and Martin; the James Allen book supplies the fundamentals content of this session.
  • Homework. At the students' request, short practice homework (not graded assignments) will be given after every session from the next session onward.

Q: Can we expect some homework after every session — not assignments, just practice material? A: Yes — starting from the next session, small practice homework will be provided after each class.

  • AI tools are allowed, but contribute. You may use AI tools for assignments — but write your own work and understand it. Faculty can recognize the stylistic fingerprints of code and text generated by Copilot, ChatGPT, Claude, or Gemini, so outsourced work is detectable. The tools are a help, not a substitute.

Exam note: The end-semester open-book exam (40%) and the makeup exam (30%) dominate the grade, so the textbook fundamentals matter more than the quizzes. Deadlines are final, virtual labs add one or two marks for free, and homework from the next session onward is practice — the exact habit that pays off in those exams.

Key Industry Applications

Consolidated list of every real-world connection made in this session:

  • Real-world: Conversational AI and agents — booking systems (movie tickets), FAQ agents, customer support; systems combine named entity recognition, coreference resolution, and external API calls at run time.
  • Real-world: Speech — Whisper API for speech recognition with noise cancellation; text-to-speech that can mimic voices; voice deep fakes as an emerging risk.
  • Real-world: Healthcare — triage agents, FAQ agents, and conversational AI to cut hospital and insurance queues in high-population countries.
  • Real-world: E-commerce — question answering systems for customer queries (Amazon).
  • Real-world: Databases — natural language interfaces to databases, replacing SQL, joins, and keys; results converted back into natural language.
  • Real-world: Code agents — natural language to code generation in any language.
  • Real-world: Search and RAG — retrieval of relevant context; hybrid systems with vector databases; GraphRAG built on knowledge graphs (a knowledge graph is a populated ontology).
  • Real-world: Information extraction — named entities, relations, events; ambiguity of names like Tata vs Ratan Tata Foundation; Amazon's relationship extraction and PII detection for guardrails.
  • Real-world: Writing tools — QuillBot (plagiarism, humanizer, summarizer, citations in IEEE/ACM format), Grammarly (spell and grammar checking).
  • Real-world: Machine translation — travel and local-language preservation; gender resolution required in Indian languages.
  • Real-world: Safety — cyberbullying detection used by cyber cells worldwide, fake news detection, plagiarism detection.
  • Real-world: Model economics — token-based pricing; DeepSeek's efficiency advantage from better tokenization; GPU costs (5–6 lakhs for an 800-series GPU, about 12 lakhs for an H100); hybrid classical-plus-LLM systems as the production norm; LLM carbon footprint about 100 times that of search engines.
  • Real-world: Careers — named roles: NLP engineer, prompt engineer, data scientist, conversational AI engineer, computational linguist.

Read the list once more and notice the pattern: every row is one of the course modules wearing an industry costume. Conversational AI is tokenization, POS tagging, and named entity recognition chained together. Search and RAG is information retrieval plus embeddings. Databases is understanding and generation with a query in between. The session's whole argument lands here — the fundamentals are the applications.

NLP Lecture 1 Notes · Introduction to Natural Language Processing

Natural Language Processing· postgraduate· 2026-08-13

Sections Breakdown

1What NLP Is and Why It Matters

Defines NLP and its place in AI, previews the course roadmap, and reads the Hal-Dave dialogue for the language cues humans use without effort.

2A Short History of NLP

The era ladder from rule-based Eliza and the Turing test through symbolic, statistical, and ML-based NLP to transformers and the agentic era.

3Applications of NLP

Speech, healthcare triage, database dialogue, search and RAG, information retrieval versus extraction, writing, translation, and safety applications.

4NLP Tools and Libraries

Commercial NLP APIs versus open-source libraries - Hugging Face, NLTK, spaCy, Stanford CoreNLP, TextBlob - and how to choose between them.

5Hands-On Text Preprocessing with NLTK and spaCy

Tokenization, punctuation and stop-word removal, stemming versus lemmatization, part-of-speech tagging, and the NLTK-versus-spaCy decision.

6Why Language Is Hard: Ambiguity Everywhere

The Black Panther booking dialogue, word order versus bag-of-words, structural and lexical ambiguity, and why contextual embeddings were a breakthrough.

7The Six Levels of Language Understanding

The six-layer stack from morphological to discourse knowledge, with the pen-and-banana pragmatic example and the LLM context window as machine discourse.

8Anatomy of an NLP System

The mirrored understand-and-generate halves; classical, modern, and hybrid system designs; and why hybrid wins in production.

9Evaluating NLP Systems

Accuracy, precision, recall, and F1 from the confusion matrix, task metrics BLEU, ROUGE, and perplexity, plus data quality, efficiency, and observability.

10Exam Guidance Summary

Grading weightages, deadlines, virtual-lab marks, assumed knowledge, and the AI-tools policy for this course.

11Key Industry Applications

Every real-world NLP connection from the session, from conversational AI to NLP careers.

Postgraduate students in a first NLP course, and anyone who wants a grounded overview of how machines handle language.

Exam Revision Notes

Below is the distilled, exam-ready core. Every entry comes from the full explanation above. Use this section for rapid review; return to the main notes when a point needs more context.

What NLP Is and Why It Matters

Must-know: NLP is the branch of AI for understanding, analyzing, and generating human language; it is a broad area, a language model is a part of it, and NLP is itself a component of AI.

⚠️ Top pitfall: Treating an LLM as an input to NLP, or as the whole of NLP, instead of as one technique family inside the area.

Self-check: In the Hal-Dave dialogue, which language cues identify the machine, and why is 'I've seen the movie' rejected?

Connects to: 1.2, 1.6, 1.7.

A Short History of NLP

Must-know: Each NLP era arose to fix the previous era's bottleneck: no data led to rule-based systems, no features led to deep learning; the agentic era repeats the pattern, and right-tool judgment (not newest-tool fashion) is the skill to keep.

⚠️ Top pitfall: Assuming the newest approach is always best; agentic AI only pays when there is return on investment.

Self-check: Which bottleneck did each era remove — rules, symbolic NLP, statistical NLP, ML, deep learning?

Connects to: 1.1, 1.3, 1.8.

Applications of NLP

Must-know: Information retrieval finds documents or passages for a query; information extraction pulls structured fields (entities, relations, events) out of text. Pick IR to read, IE to fill fields.

⚠️ Top pitfall: Confusing retrieval with extraction, and treating polished demos (speech, translation, detection) as fully solved.

Self-check: For the sentence 'Tata Motors announced a new plant in Pune', what would IR return and what would IE return?

Connects to: 1.4, 1.8, 1.6.

NLP Tools and Libraries

Must-know: Pick paid APIs for hosted convenience at per-call cost; pick open-source libraries (NLTK for learning and multilingual work, spaCy for fast production English) for control and free use.

⚠️ Top pitfall: Ignoring language coverage and per-token costs when choosing a tool; learning NLP through hosted APIs that hide the mechanics.

Self-check: Which toolkit is the classic education-and-research choice, and which is the fast industrial-strength one?

Connects to: 1.3, 1.5.

Hands-On Text Preprocessing with NLTK and spaCy

Must-know: Tokenization splits text into sentences, words, and subwords (BPE is the modern tokenizer behind token-based pricing); stemming applies fixed meaning-blind rules while lemmatization consults a dictionary; every preprocessing step is application-dependent, and POS tagging feeds named entity recognition.

⚠️ Top pitfall: Removing stop words and punctuation unconditionally — a grammar checker needs them; also expecting stemming to keep meanings intact (it happily produces 'natur').

Self-check: Why does the sentence tokenizer keep 'Dr.' together, and what does Regex stemming do to 'friendship' and 'natural'?

Connects to: 1.4, 1.6, 1.7.

Why Language Is Hard: Ambiguity Everywhere

Must-know: Meaning lives in context, not in words: word order, part of speech, world knowledge, and discourse all determine interpretation, and lexical/structural ambiguity is the core difficulty that contextual embeddings address.

⚠️ Top pitfall: Storing one fixed vector per word — it cannot represent both senses of 'bank', so every ambiguous word quietly degrades the model.

Self-check: What six skills did the four-turn Black Panther dialogue demand, and why do 'Namrata thinks she understands me' and 'She thinks Namrata understands me' differ despite identical bags of words?

Connects to: 1.5, 1.7, 1.1.

The Six Levels of Language Understanding

Must-know: The six levels run morphological, lexical, syntactic, semantic, pragmatic, discourse; each higher level assumes the lower ones, machines are strongest at the lower levels, and the LLM context window implements discourse knowledge.

⚠️ Top pitfall: Confusing semantic and pragmatic failure: 'green ideas have large noses' is semantically empty, 'cut the banana with a pen' is semantically fine but pragmatically wrong.

Self-check: Which level rejects 'cut the banana with a pen', and which level rejects 'green ideas have large noses'?

Connects to: 1.6, 1.8, 1.5.

Anatomy of an NLP System

Must-know: Every NLP system must understand then generate; the production design is hybrid — classical preprocessing and retrieval around an LLM — because classical steps are cheap and explainable while transformers are expensive black boxes.

⚠️ Top pitfall: Treating the transformer as a black box and losing all clues when it misbehaves; also spending GPU money on tasks classical preprocessing handles.

Self-check: Why do production systems keep classical preprocessing when a transformer could do everything?

Connects to: 1.5, 1.9, 1.2.

Evaluating NLP Systems

Must-know: Accuracy = (TP+TN)/(TP+TN+FP+FN), Precision = TP/(TP+FP), Recall = TP/(TP+FN), F1 = 2PR/(P+R); choose the metric that punishes the expensive error — BLEU for translation, ROUGE for summarization, perplexity for language modeling.

⚠️ Top pitfall: Reporting accuracy on unbalanced classes (a 98%-accurate spam filter that catches nothing); ignoring latency and data bias in evaluation.

Self-check: A test with TP=60, FP=5, TN=25, FN=10: compute accuracy, precision, recall, and F1.

Connects to: 1.8, 1.3, 1.6.

Exam Guidance Summary

Must-know: End-semester open-book exam is 40% and the closed-book makeup is 30%; deadlines have no extensions; virtual labs earn one or two marks; AI tools are allowed only if you write and understand your own work.

⚠️ Top pitfall: Outsourcing assignments to AI tools — faculty can recognize the stylistic fingerprints, and the tools are a help, not a substitute.

Self-check: What are the weightages of the two quizzes, the lab assignment, the second assignment, the makeup exam, and the end-semester exam?

Key Industry Applications

Must-know: Every course module has a named industry application: preprocessing and tagging power conversational AI, retrieval powers RAG and search, and knowledge graphs power GraphRAG.

⚠️ Top pitfall: Treating applications as separate from fundamentals — each application is a chain of the course's core techniques.

Self-check: Name the NLP techniques behind a movie-ticket booking agent and behind a GraphRAG search system.

Was this lecture useful?

Loading comments…
🤖

BitsNotes AI Assistant

Subject Notes Assistant

Configure AI Chat

Choose how to access the chatbot
Have your own API key?

Switch to "Bring Your Own Key" tab above for unlimited access with any OpenAI-compatible provider.

🔑 Enter API key above to fetch live models from provider, or enter model name manually.
OpenAI-Compatible API Support

Choose any provider preset (Gemini, DeepSeek, Kimi, GLM, MiniMax, Qwen, OpenAI, Groq, Ollama, etc.) or enter a custom endpoint URL.

Security & Privacy First

Your API key is sent directly from your browser to your specified provider. BitsNotes servers never store or see your key.