Model Pipeline - Transformer decoder
The Transformer decoder takes encoded information and previous outputs to predict the next word in a sequence. It helps machines understand and generate language step-by-step.
The Transformer decoder takes encoded information and previous outputs to predict the next word in a sequence. It helps machines understand and generate language step-by-step.
Loss 5.2 |***** 4.1 |**** 3.3 |*** 2.7 |** 2.2 |** 1.8 |* 1.5 |* 1.3 |* 1.1 |* 0.95|*
| Epoch | Loss ↓ | Accuracy ↑ | Observation |
|---|---|---|---|
| 1 | 5.2 | 0.12 | High loss and low accuracy at start |
| 2 | 4.1 | 0.25 | Loss decreased, accuracy improved |
| 3 | 3.3 | 0.38 | Model learning meaningful patterns |
| 4 | 2.7 | 0.48 | Steady improvement in metrics |
| 5 | 2.2 | 0.57 | Model converging well |
| 6 | 1.8 | 0.65 | Good balance of loss and accuracy |
| 7 | 1.5 | 0.71 | Further refinement of predictions |
| 8 | 1.3 | 0.76 | Model nearing stable performance |
| 9 | 1.1 | 0.80 | Strong accuracy, low loss |
| 10 | 0.95 | 0.83 | Training converged well |
import torch from torch.nn import TransformerDecoder, TransformerDecoderLayer layer = TransformerDecoderLayer(d_model=256, nhead=8) decoder = TransformerDecoder(layer, num_layers=3) memory = torch.rand(10, 32, 256) # (source_seq_len, batch_size, d_model) tgt = torch.rand(20, 32, 256) # (target_seq_len, batch_size, d_model) output = decoder(tgt, memory)
import torch from torch.nn import TransformerDecoder, TransformerDecoderLayer layer = TransformerDecoderLayer(d_model=128, nhead=4) decoder = TransformerDecoder(layer, num_layers=2) memory = torch.rand(15, 16, 128) tgt = torch.rand(15, 16, 64) # Incorrect feature size output = decoder(tgt, memory)
Pass the test and this pattern moves unknown