0
0
Prompt Engineering / GenAIml~12 mins

Translation in Prompt Engineering / GenAI - Model Pipeline Trace

Choose your learning style9 modes available
Model Pipeline - Translation

This pipeline translates sentences from one language to another using a neural network model. It takes text in the source language, processes it, and outputs the translated text in the target language.

Data Flow - 6 Stages
1Input Text
1 sentence (variable length)Receive raw sentence in source language1 sentence (variable length)
"Hello, how are you?"
2Tokenization
1 sentence (variable length)Split sentence into tokens (words or subwords)1 sequence of tokens (e.g., 7 tokens)
["Hello", ",", "how", "are", "you", "?"]
3Embedding
1 sequence of tokens (7 tokens)Convert tokens to numeric vectors1 sequence of vectors (7 tokens x 512 features)
[[0.12, -0.05, ..., 0.33], ..., [0.01, 0.07, ..., -0.02]]
4Encoder
1 sequence of vectors (7 x 512)Process input sequence to capture meaning1 sequence of encoded vectors (7 x 512)
[[0.45, 0.12, ..., -0.22], ..., [0.33, -0.11, ..., 0.05]]
5Decoder
1 sequence of encoded vectors (7 x 512)Generate output tokens step-by-step1 sequence of output token probabilities (8 tokens x vocabulary size)
[[0.01, 0.02, ..., 0.05], ..., [0.10, 0.03, ..., 0.01]]
6Detokenization
1 sequence of output tokens (8 tokens)Convert tokens back to text1 sentence (variable length)
"Bonjour, comment ça va ?"
Training Trace - Epoch by Epoch

Loss
5.2 |***************
4.0 |************
2.7 |*********
1.9 |******
1.3 |****
1.0 |***
0.85|**
0.75|**
0.70|*
0.68|*
     +----------------
      Epochs 1 to 10
EpochLoss ↓Accuracy ↑Observation
15.20.15Initial training with high loss and low accuracy
23.80.35Loss decreased, accuracy improved
32.70.52Model learning better translations
41.90.68Significant improvement in accuracy
51.30.78Model converging with good translation quality
61.00.83Further fine-tuning, stable performance
70.850.87Loss decreasing steadily, accuracy high
80.750.90Model producing accurate translations
90.700.91Minor improvements, nearing best performance
100.680.92Training converged with low loss and high accuracy
Prediction Trace - 5 Layers
Layer 1: Tokenization
Layer 2: Embedding
Layer 3: Encoder
Layer 4: Decoder
Layer 5: Detokenization
Model Quiz - 3 Questions
Test your understanding
What happens during the embedding stage?
ASentence is split into words
BOutput tokens are combined into a sentence
CTokens are converted into numeric vectors
DModel predicts the next word
Key Insight
This visualization shows how a translation model learns to convert sentences from one language to another by gradually improving its predictions over training. The encoder-decoder structure helps the model understand input meaning and generate accurate translations.