Chapter 8 - Applications of NLP-3
Chapter 8 - Applications of NLP-3
I
Information
The Retrieval
Retrieval
Process Classic IR
Information
Models
Extraction Machine
IR Performance
Translation
Evaluation NLP in IR
Question-Answering and Dialogue
The Retrieval S ystem s
Text Summarization
Process
User Interface
user need
Text Operations text text
Searching Index
Text
ranked docs retrieved
Database
docs
Ranking
Depending on how index terms are treated, there are three classic IR models: Boolean,
Vector and Probabilistic models.
These term weights are used to compute the degree of similarity each
document stored in the systems and the user query.
Retrieved documents can be sorted in decreasing order to get ranked list of
documents.
Advantages:
Captures the IR problem with the assumption that for a given user query there is a set
of documents which contains exactly the relevant documents and no other.
This set of documents is the ideal answer set.
Given the description of this ideal answer set, there would be no problem in
retrieving its documents.
The querying process can then be thought of as a process of specifying the properties
of an ideal answer set.
Initially guess the properties (we can start by using index terms).
User feed back is then initiated and taken to improve the probability that the
user will find document d with query q.
Measure of document similarity to the query:
P(d relevant-to q)
P(d non-relevant-to q)
The main advantage is that documents are ranked in decreasing order of their
probability of being relevant.
The journey of an IR process begins with a user query sent to the IR system which
encodes the query, compares the query with the available resources, and returns the
most relevant pieces of information. Thus, the system is equipped with the ability to
store, retrieve and maintain information.
In the early era of IR, the whole process was completed using handcrafted features and
ad-hoc relevance measures.
Later, principled frameworks for relevance measure were developed with statistical
learning as a basis.
Recently, deep learning has proven essential to the introduction of more opportunities to
IR. This is because data-driven features combined with data-driven relevance measures
can effectively eliminate the human bias in either feature or relevance measure design.
Deep Learning is used for IR for all components.
Document Ranking
Document Indexing
Query Processing
Document Searching
The performance of IR systems can be evaluated by using two commonly used metrics:
precision and recall.
Recall is the fraction of the relevant documents which has been retrieved.
relevant retrieved
R ecall =
relevant
Information Extraction (IE) focuses on the recognition, tagging, and extraction of certain
key elements of information (e.g. persons, companies, locations, organizations, etc.)
from large collections of text into a structured representation.
Extracted Information:
INDUSTRY: Advertising
POSITION: Assistant
Account Manager LOCATION:
Bole, Addis Ababa.
Department of Computer Science, SC, DDIT, DDU Applications of NLP 12/59
Information Components of Information
Retrieval Extraction Na m ed Entity
Information Recognition
Extraction Machine Relation Detection and
Translation Classification Temporal and
Question-Answering and Dialogue Event Processing Template
Components of Information S ystem s Filling
Text Summarization
Extraction
Named Entity Recognition is the process of recognition of entity names such as:
Organization: Ministry of Education, ABC Company, ትምህርት ሚኒስቴር, ሀለመ ኩባንያ, etc.
Quantities: three quintals of teff, 3000 Birr, ሶስት ኩንታል ጤፍ, 3ሺ ብር, etc.
etc.
Examples:
Temporal and Event Processing recognizes and normalizes temporal expressions and
analyzes events.
It has three major components:
Template Filling is the final task of information extraction systems where structured
data is to be filled in the template slots.
Example:
Machine Translation (MT) refers to a translation of texts from one natural language to
another by means of a computerized system.
MT is one of the earliest studied applications of NLP.
Direct (dictionary-based) translation uses a large bilingual dictionary and translates the
source language text word-by-word.
The process of direct translation involves morphological analysis, lexical transfer, local
reordering, and morphological generation.
Fast
Simple
Inexpensive
No translation rules hidden in lexicon
Cons:
Unreliable
Not powerful
Rule proliferation
Requires too much context
Major restructuring after lexical substitution
NP VP S
N V NP NP VP
Syntactic Syntactic Syntactic
Abebe broke Det N Structure Transfer Structure N N V
Offers the ability to deal with more complex source language phenomena than
the direct approach.
High quality translations can be achieved as compared to direct translation.
Relatively fast as compared to Interlingual translation.
Cons:
EVENT:
breaking TENSE:
past
AGENT: Abebe
PATIENT:
window
Interlingu
DEFINI
a
Analysi TENES Generatio
s S: n
Source definite Target text
Abebetext
broke the አበበ መስኮቱን ሰበረው
window
Interlingual translation is suitable for multilingual machine translation, and its main
drawback is that the definition of an Interlingua is difficult and maybe even impossible
for a wider domain.
Statistical Machine Translation (SMT) finds the most probable target sentence given a
source text sentence.
Parameters of probabilistic models are derived from the analysis of bilingual text
corpora.
Source text
Target text
Language Model tries to ensure that words come in the right order.
Some notion of grammaticality
Given an English string e, language model assigns p(e) by formula.
Good English string high p(e); and bad English string low p(e).
Calculated with:
A statistical grammar such as a probabilistic context free grammar; or
An n-gram language model.
Trigram probabilities
The job of the translation model is to assign a probability that a given source language
sentence generates target language sentence.
We can model the translation from a source language sentence S to a target language
sentence Tˆ as:
best-translation Tˆ = argmax faithfulness(T,S) * fluency(T)
T
Suppose that we want to build a foreign-to-English machine
translation system.
Thus, in a probabilistic model, the best English sentence e is the
one whose probability ê = argmax p(e|
f) e
p(e|f) is the highest.
Bayes’ rule:
p(e|f ) = p(f|e) * p(e) /
p(f )
argmax p(e|f ) = argmax p(f|e) * p(e) /
e
p(f )
e ê = argmax p(f|e) * p(e) [for a given
f] e
Noisy channel equation: Translation model Language model
count (f,e)
p(f |e) = count (e)
probability.
The translation probability t(fj|ei) is calculated by counting as follows:
count (fj , ei )
t(fj | ei )
= count (ei )
አበበ በሶ በላ ።
Abebe
ate
besso
Source text
f
Target text
e
A decoder searches for the best sequence of transformations that translates a source
sentence.
Look up all translations of every source word or phrase, using word or phrase
translation table.
Recombine the target language phrases that maximizes the translation model
probability * the language model probability.
This search over all possible combinations can get very large so we need to find
ways of limiting the search space.
Decoding is, therefore, a searching problem that can be reformulated as a classic
Artificial Intelligence problem, i.e. searching for the shortest path in an implicit graph.
Cons:
Does not explicitly deal with syntax
Choosing S M T
Economic reasons:
Low cost
Rapid prototyping
Practical reasons:
Many language pairs don't have NLP resources, but do have parallel corpora
Quality reasons:
Uses chunks of human translated text as its building blocks
Produces state of the art results (when very large data sets are available)
Decoder
For example, Pharaoh (phrase-based decoder that builds phrase tables from
Giza++ word alignments and produces best translation for new input using the
phrase table plus SRILM language model)
Fundamental idea:
People do not translate by doing deep linguistics analysis of a sentence.
They translate by decomposing sentence into fragments, translating each of
those, and then composing those properly.
Uses the principle of analogy in translation
Example:
Given the following translations:
Cons:
May have limited coverage depending on the size of the example database, and
flexibility of matching heuristics
Segment1 Segment2
Translated by rule-based Translated by example-based
The application of deep learning approaches for machine translation is called Neural
Machine translation.
Neural machine translation (NMT) is an approach to machine translation that uses
an artificial neural network to predict the likelihood of a sequence of words, typically
modeling entire sentences in a single integrated model.
NMT is not a drastic step beyond what has been traditionally done in statistical machine
translation.
Its main departure is the use of vector representations ("embeddings", "continuous
space representations") for words and internal states. The structure of the models is
simpler than phrase-based models.
There is no separate language model, translation model, and reordering model, but just
a single sequence model that predicts one word at a time. However, this sequence
prediction is conditioned on the entire source sentence and the entire already produced
target sequence.
NMT: it is simple architecture and ability in capturing long dependency in the sentence,
which indicates a huge potential in becoming a new trend of the mainstream.
NMT needs less linguistic knowledge than other approaches but can produce a
competitive performance.
Motivation of NMT: The inspiration for neural machine translation comes from two
aspects: the success of Deep Learning in other NLP tasks as we mentioned, and the
unresolved problems in the development of MT itself.
NMT task is originally designed as an end-to-end learning task. It directly processes a
source sequence to a target sequence. The learning objective is to find the correct
target sequence given the source sequence, which can be seen as a high dimensional
classification problem that tries to map the two sentences in the semantic space.
End-to-End means the model processes source data to target data directly, without
explicable intermediate result.
End-to-End architecture of NMT contains four components.
Source Sentence: is an input sentence for the models from the source natural
language.
Encoder - is used to represent the source sentence to semantic vector.
Decoder - makes prediction from this semantic vector to a target sentence.
Target Sentence: is an output sentence from the model for the target natural
language.
The common deep learning algorithm used for encoding and decoding in NMT are:
Recurrent Neural networks such as Conventional RNN, LSTM, GRU, BRNN, BLSTM,
BGRU, these models with attention mechanism and Full attention mechanism
models.
All the above models are used to model the word sequence of the source and target
natural languages.
The encoder model is the first model that is used by the neural network to encode a
source sentence for a second model, known as a decoder.
The decoder model is used to predict words in the target natural language.
Recurrent neural networks face difficulties in encoding long inputs into a single vector.
This can be compensated by an attention mechanism which allows the decoder to focus
on different parts of the input while generating each word of the output.
The common approaches of NMT are:
NMT with Deep Learning
NMT with Deep Learning and Attention Mechanism
Full Attention based NMT e.g. Transformer
Question
Answer
Question Question
Answer Answer
QA Systems deal with a wide range of question types such as fact, list, “wh”-questions,
definition, hypothetical, and semantically-constrained questions.
Search engines do not speak natural language.
Human beings need to speak the language of search engines.
QA Systems attempt to let human beings ask their questions in the normal way
using natural languages.
QA Systems are important NLP applications especially for inexperienced users.
QA Systems are closer to human beings than search engines are.
QA Systems are viewed as natural language search engines.
QA Systems are considered as next step to current search engines.
Question answering can be approached from one of two existing NLP research areas:
Information Retrieval: QA can be viewed as short passage retrieval.
Information Extraction: QA can be viewed as open-domain information
extraction.
The performance of QA Systems is heavily dependent on good search corpus.
User
Question Response
Clarification Request
Docume
nt
Collectio
n
Dialogue Systems differ in the degree with which human or computer takes the
initiative.
Question
Answer
Question
Answer
Computer-Initiative Human-Initiative
Computer maintains tight control Human maintains tight control
Human is highly restricted Computer is highly restricted
E.g., Dialogue Boxes E.g., ELIZA
Mixed-Initiative
Human and computer have flexibility to specify constraints
Mainly research prototypes
In the process of Natural Language Understanding, there are many ways to represent
the meaning of sentences.
For dialogue systems, the most common is “frame and slot semantics”
representation.
SHOW:
FLIGHTS:
ORIGIN
CITY: Addis
Ababa DATE:
Tuesday TIME:
morning
DESTINATION
CITY:
London
DATE:
TIME:
Domain Identification
User Intent Detection
Slot Filling
Dialogue Manager
Deep Learning algorithms are applied to all these components of the Dialogue System,
and achieved a state of the art result.
Given the original text T and summary S, two measures are commonly used to
evaluate Text Summarization systems:
Length (S)
CR =
Length (T)
Retention Ratio (RR)
Information (S)
RR =
Information (T)
Measuring length:
Number of letters
Number of words
Number of sentences
Measuring information:
Question
Shannon Game: test reader’s
quantify understanding.
information content.
Variants of Recurrent Neural Networks (RNNs), i.e. Gated Recurrent Neural Network (GRU)
or Long Short Term Memory (LSTM), are preferred as the encoder and decoder
components. This is because they are capable of capturing long term dependencies by
overcoming the problem of vanishing gradient.
Word embeddings are a type of word representation that allows words with similar
meaning to have a similar representation.
Attention mechanism is used to secure individual parts of the input which are more
important at that particular time.
It can be implemented by taking inputs from each time steps and giving
weightage to time steps.
The weightage depends on the contextual importance of that particular time
step.
It helps pay attention to the most relevant parts of the input data sequence so
that the decoder can optimally generate the next word in the output sequence.
BLEU - measures precision - how much the words (and/or n-grams) in the machine
generated summaries appeared in the human reference summaries.
ROUGE - measures recall - how much the words (and/or n-grams) in the human
reference summaries appeared in the machine generated summaries.
F1-score - F1 = 2 * (Bleu * Rouge) / (Bleu + Rouge)