[go: up one dir, main page]

0% found this document useful (0 votes)
4 views4 pages

Natural Language Processing Language Models? - Term...

Uploaded by

20CE033 Dhruvi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views4 pages

Natural Language Processing Language Models? - Term...

Uploaded by

20CE033 Dhruvi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Natural Language Processing (NLP) and Language Models

Natural Language Processing (NLP) is a field of artificial intelligence that focuses on enabling
computers to understand, interpret, and generate human language in a way that is both
meaningful and useful. At its core, NLP bridges the gap between human communication and
computer understanding, allowing machines to perform tasks like translation, summarization,
and sentiment analysis.
Language Models are a fundamental component of NLP. They are statistical or neural
network-based models that are trained on vast amounts of text data to predict the next word or
a sequence of words in a sentence. Essentially, they learn the probability distribution of word
sequences, which allows them to generate coherent and contextually relevant text.

1. Terms Used in Communication


Communication involves several key terms that are relevant to NLP:
●​ Syntax: The grammatical structure of a sentence. It refers to the rules that govern how
words are combined to form phrases and sentences. For example, "The cat sat on the
mat" follows English syntax, while "Cat the mat the on sat" does not.
●​ Semantics: The meaning of words and sentences. It's about understanding the concepts
and ideas conveyed by language. For example, "I am going to the bank" can have two
different semantic meanings: a financial institution or a river bank.
●​ Pragmatics: The context-dependent meaning of language. It considers how social
context, speaker intent, and background knowledge influence the interpretation of an
utterance. For example, "Can you pass the salt?" is not a question about ability but a
polite request.
●​ Phonology: The study of the sound system of a language. It deals with the organization
of speech sounds and how they are used to convey meaning.
●​ Morphology: The study of the internal structure of words and how they are formed. It
involves analyzing morphemes, the smallest units of meaning. For example, the word
"unbelievable" is composed of the morphemes "un-", "believe", and "-able".

2. Understanding Action-Agent Steps of Natural Language


This concept is often used in the context of conversational AI and task-oriented systems. It
breaks down a user's request into actionable components:
1.​ Identify the User's Intent: Determine the primary goal or purpose of the user's utterance.
For example, in the sentence "Book me a flight from New York to London for tomorrow,"
the intent is "book a flight."
2.​ Extract Entities (Slots): Identify the key pieces of information (entities or "slots") required
to fulfill the intent. In the example above, the entities are:
○​ Departure Location: "New York"
○​ Destination Location: "London"
○​ Date: "tomorrow"
3.​ Determine the Action: Based on the intent and entities, the system decides what action
to take. In this case, the action is to initiate a flight booking process.
4.​ Formulate a Response: The system generates a response, which might involve
confirming the details, asking for more information, or executing the action. A typical
response might be: "I'm booking a flight from New York to London for you for tomorrow. Is
that correct?"

3. Example of Formal Grammar that Represents English


A formal grammar provides a set of rules for constructing valid sentences in a language. One of
the most common types is Context-Free Grammar (CFG), which uses production rules to
generate sentences. A simplified CFG for a subset of English might look like this:
●​ S \rightarrow NP \ VP (A sentence is composed of a Noun Phrase and a Verb Phrase)
●​ NP \rightarrow Det \ N (A Noun Phrase can be a Determiner followed by a Noun)
●​ NP \rightarrow Adj \ N (A Noun Phrase can be an Adjective followed by a Noun)
●​ NP \rightarrow NP \ PP (A Noun Phrase can be a Noun Phrase followed by a
Prepositional Phrase)
●​ VP \rightarrow V \ NP (A Verb Phrase can be a Verb followed by a Noun Phrase)
●​ VP \rightarrow V (A Verb Phrase can be just a Verb)
●​ PP \rightarrow P \ NP (A Prepositional Phrase is a Preposition followed by a Noun
Phrase)
●​ Det \rightarrow a \mid the
●​ N \rightarrow cat \mid dog \mid mat
●​ V \rightarrow sat \mid chased
●​ Adj \rightarrow big \mid small
●​ P \rightarrow on \mid with
Using these rules, we can generate a sentence like "The cat sat on the mat." The process is a
derivation:
S \rightarrow NP \ VP S \rightarrow Det \ N \ VP S \rightarrow The \ N \ VP S \rightarrow The \
cat \ VP S \rightarrow The \ cat \ V \ PP S \rightarrow The \ cat \ sat \ PP S \rightarrow The \ cat \
sat \ P \ NP S \rightarrow The \ cat \ sat \ on \ NP S \rightarrow The \ cat \ sat \ on \ Det \ N S
\rightarrow The \ cat \ sat \ on \ the \ N S \rightarrow The \ cat \ sat \ on \ the \ mat

4. Working of Natural Language Processing


The core working of NLP involves a pipeline of processes to convert raw human language into a
form that a machine can understand. Modern NLP, especially with the rise of deep learning,
often bypasses some of these explicit steps and uses end-to-end models, but the underlying
concepts remain relevant.
1.​ Data Collection and Preprocessing:
○​ Corpus: Gathering a large body of text data.
○​ Tokenization: Breaking down text into individual words or sub-word units (tokens).
○​ Stop Word Removal: Eliminating common words like "the," "a," and "is" that often
don't carry significant meaning.
○​ Stemming/Lemmatization: Reducing words to their base or root form (e.g.,
"running" \rightarrow "run," "ran" \rightarrow "run").
2.​ Feature Extraction:
○​ Bag-of-Words: Representing text as a collection of words, ignoring grammar and
word order, and using their frequency.
○​ TF-IDF (Term Frequency-Inverse Document Frequency): A statistical measure
that reflects how important a word is to a document in a corpus.
○​ Word Embeddings: Representing words as dense vectors in a continuous vector
space, where words with similar meanings are located closer to each other.
Examples include Word2Vec, GloVe, and FastText.
3.​ Modeling and Training:
○​ Rule-based Systems: Using hand-crafted rules (like CFGs) for specific tasks.
○​ Machine Learning Models: Using traditional models like Naive Bayes, Support
Vector Machines (SVMs), or Hidden Markov Models (HMMs) for classification or
sequence labeling.
○​ Deep Learning Models: Using neural networks, especially Recurrent Neural
Networks (RNNs), Long Short-Term Memory (LSTMs), and most notably, the
Transformer architecture. Transformers, which use attention mechanisms, are the
foundation for large language models (LLMs) like GPT and BERT.

5. Steps in Natural Language Processing


NLP tasks typically follow a sequence of steps, though the exact pipeline can vary:
1.​ Lexical Analysis: The process of breaking down the text into basic linguistic units, such
as words, punctuation marks, and numbers. This is the first step of tokenization.
2.​ Syntactic Analysis (Parsing): Analyzing the grammatical structure of the sentence. This
involves building a parse tree or dependency tree to show the relationships between
words.
3.​ Semantic Analysis: Determining the meaning of the words and the sentence as a whole.
This often involves techniques like Named Entity Recognition (NER) (identifying names
of people, places, organizations) and Word Sense Disambiguation (WSD) (determining
the correct meaning of a word in a specific context).
4.​ Pragmatic Analysis: Understanding the context and implicit meaning. This is a complex
step that requires background knowledge and reasoning. For example, understanding
sarcasm or irony.
5.​ Discourse Analysis: Analyzing how sentences and utterances are connected to form a
coherent text or conversation. It deals with concepts like anaphora resolution (e.g.,
determining what "it" refers to in a sentence).

6. Knowledge Levels Used in NLP


NLP systems draw upon various levels of knowledge to process language effectively:
●​ Phonological/Orthographical Knowledge: Knowledge of sounds (for speech) and
spelling conventions (for text).
●​ Morphological Knowledge: Understanding the structure of words and their component
morphemes.
●​ Lexical Knowledge: A dictionary or lexicon that contains information about words,
including their spelling, part of speech, and possible meanings.
●​ Syntactic Knowledge: Grammatical rules that dictate how words can be combined to
form sentences.
●​ Semantic Knowledge: Knowledge about the meaning of words and how they relate to
real-world concepts. This includes ontologies (structured knowledge bases) and
semantic networks.
●​ Pragmatic Knowledge: Understanding how language is used in social contexts,
including speaker intent and conversational conventions.
●​ World Knowledge: General knowledge about the world that is not explicitly stated but is
necessary for understanding. For example, knowing that "New York" is a city.

7. NLP Techniques
NLP employs a wide array of techniques to accomplish its tasks. These can be broadly
categorized as follows:
●​ Rule-Based Techniques:
○​ Regular Expressions: Used for pattern matching in text, such as finding email
addresses or phone numbers.
○​ Hand-crafted Grammars: As seen in the CFG example, these are explicit rules for
parsing sentences.
●​ Statistical Techniques:
○​ N-grams: Predicting the next word based on the previous n-1 words.
○​ Bayesian Models: Using probability theory to classify text, such as in spam
filtering.
○​ Hidden Markov Models (HMMs): Used for sequence labeling tasks like
Part-of-Speech (POS) tagging.
●​ Machine Learning Techniques:
○​ Support Vector Machines (SVMs): Effective for text classification tasks.
○​ Conditional Random Fields (CRFs): A popular model for sequence labeling,
offering an improvement over HMMs.
●​ Deep Learning Techniques:
○​ Recurrent Neural Networks (RNNs) and LSTMs: Designed to handle sequential
data and were foundational for tasks like machine translation and text generation.
○​ Convolutional Neural Networks (CNNs): Often used for text classification and
sentiment analysis.
○​ Attention Mechanisms: A key innovation that allows models to focus on the most
relevant parts of the input sequence.
○​ Transformer Architecture: The current state-of-the-art architecture for NLP. It
relies on attention mechanisms and has given rise to:
■​ BERT (Bidirectional Encoder Representations from Transformers): A
model that learns deep bidirectional representations from unlabelled text,
used for tasks like question answering and named entity recognition.
■​ **GPT (Generative Pre-trained Transformer): A family of models designed for
text generation, translation, and other tasks.
○​ Large Language Models (LLMs): A broad term for massive transformer-based
models (like GPT-4, Llama 2, and Gemini) that are trained on vast amounts of data
and can perform a wide range of NLP tasks.

You might also like