0
0
NLPml~12 mins

Why QA systems extract answers in NLP - Model Pipeline Impact

Choose your learning style9 modes available
Model Pipeline - Why QA systems extract answers

This pipeline shows how a Question Answering (QA) system finds and extracts the exact answer from a given text passage. It starts with the question and passage, processes the text, trains a model to locate answers, and finally predicts the answer span.

Data Flow - 5 Stages
1Input Data
1000 samples (question + passage pairs)Collect question and passage text pairs1000 samples (question + passage pairs)
Question: 'What is the capital of France?' Passage: 'France's capital is Paris, known for the Eiffel Tower.'
2Preprocessing
1000 samples (question + passage pairs)Tokenize text into words and convert to numerical IDs1000 samples x 2 sequences (question tokens, passage tokens)
Question tokens: ['What', 'is', 'the', 'capital', 'of', 'France', '?'] Passage tokens: ['France', "'s", 'capital', 'is', 'Paris', ',', 'known', 'for', 'the', 'Eiffel', 'Tower', '.']
3Feature Engineering
1000 samples x 2 sequencesCreate embeddings for tokens and position encodings1000 samples x 2 sequences x 768 features
Embedding vector for 'Paris' token: [0.12, -0.05, ..., 0.33]
4Model Training
1000 samples x 2 sequences x 768 featuresTrain QA model to predict start and end positions of answer in passageModel with learned weights
Model learns to predict start=4, end=4 for answer 'Paris' in passage tokens
5Prediction
New question + passage tokensModel predicts answer span indicesAnswer span indices (start, end)
Predicted answer span: start=4, end=4 corresponds to 'Paris'
Training Trace - Epoch by Epoch

Epochs
1 |***************
2 |************
3 |*********
4 |******
5 |****
Loss
EpochLoss ↓Accuracy ↑Observation
11.20.45Model starts learning, loss high, accuracy low
20.90.60Loss decreases, accuracy improves as model learns answer positions
30.70.72Model better at locating answers, loss continues to drop
40.50.80Good convergence, model accurately predicts answer spans
50.40.85Training stabilizes with high accuracy and low loss
Prediction Trace - 4 Layers
Layer 1: Input tokenization
Layer 2: Embedding layer
Layer 3: Model prediction
Layer 4: Answer extraction
Model Quiz - 3 Questions
Test your understanding
Why does the QA system tokenize the input text?
ATo split text into manageable pieces for the model
BTo remove stop words from the text
CTo translate the text into another language
DTo increase the length of the input
Key Insight
QA systems extract answers by learning to locate the exact position of the answer in a passage. This focused extraction helps provide precise and relevant answers rather than generating text from scratch.