Translation
PyTorch
English
Polish
transformer
sentencepiece

Educational EN -> PL Transformer

A compact (~11.5M parameters) encoder-decoder Transformer trained from scratch in PyTorch for English-to-Polish machine translation, created for the Deep Learning (Uczenie Głębokie) laboratory course at Poznan University of Technology.

Model Architecture

Parameter Value
Architecture Pre-LN Encoder-Decoder Transformer
Parameters 11,468,608 (~11.5M)
Encoder / Decoder layers 4 / 4
d_model 256
d_ff 1024
num_heads 4 (head_dim = 64)
Activation GELU
Positional encoding Sinusoidal (base = 1000.0, max_len = 96)
Dropout 0.1
Weight tying Shared tgt_embed.weight and output projection
Tokenizers Separate SentencePiece Unigram (8,000 EN / 8,000 PL)

Training Data & Setup

  • Datasets: Combined en-pl pairs (~348k sentences before filtering to <= 96 tokens) from:
  • Split: 90% train / 5% validation / 5% test (seed = 42).
  • Optimization: AdamW (lr = 1e-3, betas = (0.9, 0.98), weight_decay = 0.01) with OneCycleLR (pct_start = 0.1, div_factor = 10, final_div_factor = 1), trained for 40 epochs (batch_size = 256, length-bucketed batching, FP16 AMP).
  • Regularization: Cross-entropy with label_smoothing = 0.1 and SentencePiece subword regularization (enable_sampling = True, alpha = 0.5).

Files in This Repository

  • best_model.pth — PyTorch state_dict of the best validation checkpoint.
  • en_combined.model — Source (English) SentencePiece tokenizer (8k unigram).
  • pl_combined.model — Target (Polish) SentencePiece tokenizer (8k unigram).

Intended Use & Limitations

This model is intended exclusively for educational and research purposes (demonstrating self-attention, cross-attention visualization, and Transformer training dynamics). Because it is small (~11.5M parameters) and trained on short Tatoeba/TED sentences (<= 96 tokens), it is not suitable for production translation or long documents.

License

Released under CC-BY-NC-4.0.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Datasets used to train Antollo/dl-lab-transformer-en-pl