0
0
Prompt Engineering / GenAIml~12 mins

Question answering in Prompt Engineering / GenAI - Model Pipeline Trace

Choose your learning style9 modes available
Model Pipeline - Question answering

This pipeline takes a question and a related text passage as input. It processes the text to understand the context, then uses a trained model to find the answer to the question within the passage.

Data Flow - 6 Stages
1Input data
1000 samples x 2 texts (question and passage)Receive pairs of questions and passages1000 samples x 2 texts
Question: 'What color is the sky?' Passage: 'The sky is blue on a clear day.'
2Preprocessing
1000 samples x 2 textsTokenize and convert texts to numerical tokens1000 samples x 2 sequences of tokens (max length 128)
Question tokens: [101, 2054, 2079, 2003, 1996, 3710, 102] Passage tokens: [101, 1996, 3710, 2003, 2631, 2006, 1037, 2706, 2154, 1012, 102]
3Feature Engineering
1000 samples x 2 sequences of tokensCreate input embeddings combining question and passage tokens1000 samples x 128 tokens x 768 features
Embedding vector for token 101: [0.12, -0.05, ..., 0.33]
4Model Training
1000 samples x 128 tokens x 768 featuresTrain transformer-based QA model to predict answer span1000 samples x 2 indices (start and end positions)
Predicted answer span: start=4, end=4 (tokens corresponding to 'blue')
5Evaluation
1000 samples x 2 indicesCalculate exact match and F1 score comparing predicted and true answersMetrics: exact match=0.78, F1=0.85
Exact match: 78% of predicted answers exactly match true answers
6Prediction
1 sample x 2 textsModel predicts answer span for new question and passage1 sample x answer text
Question: 'What color is the sky?' Answer: 'blue'
Training Trace - Epoch by Epoch
Loss
1.2 |****
0.9 |***
0.7 |**
0.5 |*
0.4 |
EpochLoss ↓Accuracy ↑Observation
11.20.45Model starts learning, loss high, accuracy low
20.90.60Loss decreases, accuracy improves
30.70.70Model learns better answer spans
40.50.78Loss continues to decrease, accuracy rises
50.40.82Model converges with good performance
Prediction Trace - 5 Layers
Layer 1: Tokenization
Layer 2: Embedding Layer
Layer 3: Transformer Encoder
Layer 4: Answer Span Prediction
Layer 5: Answer Extraction
Model Quiz - 3 Questions
Test your understanding
What does the model predict as output after training?
AA yes or no answer
BA summary of the passage
CStart and end positions of the answer in the passage
DThe question rewritten
Key Insight
This visualization shows how a question answering model learns to find exact answer spans in text passages by converting words into meaningful vectors and improving predictions over training epochs.