Tutorials¶
Welcome to the TorchLingo tutorials! These interactive Jupyter notebooks will guide you through building a complete neural machine translation system.
🚀 Run in Google Colab (Recommended)¶
The easiest way to run these tutorials is in Google Colab—no installation required!
| Tutorial | Description | Open in Colab |
|---|---|---|
| 1. Data and Vocabulary | Load data, build vocabularies | |
| 2. Train a Tiny Model | Build and train a Transformer | |
| 3. Inference and Beam Search | Generate translations |
Enable GPU in Colab
For faster training, enable GPU: Runtime → Change runtime type → GPU
Colab provides free access to NVIDIA GPUs!
Learning Path¶
Follow these tutorials in order for the best learning experience:
-
Data and Vocabulary
Learn how to load parallel data, build vocabularies, and prepare your data for training.
-
Train a Tiny Model
Build and train your first Transformer model on a small dataset—runs in seconds!
-
Inference and Beam Search
Generate translations using greedy and beam search decoding strategies.
Prerequisites¶
For Google Colab (Recommended):
- A Google account
- Basic Python knowledge
For Local Setup:
- TorchLingo installed
- Basic Python knowledge
- Jupyter Notebook installed (
pip install notebook)
Running the Tutorials¶
Option 1: Google Colab (Recommended)¶
- Click any "Open in Colab" badge above
- Go to Runtime → Change runtime type → GPU
- Run the first cell to install TorchLingo:
%pip install torchlingo
Option 2: Run Locally¶
Option 3: Read Online¶
You can read the tutorials directly in the documentation—the code cells and outputs are rendered for you.
Tutorial Overview¶
Tutorial 1: Data and Vocabulary¶
Time: ~15 minutes
You'll learn:
- Loading TSV, CSV, and other data formats
- Building source and target vocabularies
- Encoding and decoding text
- Creating PyTorch datasets
Key classes covered: load_data(), SimpleVocab, NMTDataset
Tutorial 2: Train a Tiny Model¶
Time: ~20 minutes
You'll learn:
- Creating a Transformer model
- Setting up the training loop
- Teacher forcing explained
- Monitoring training progress
- Saving and loading checkpoints
Key classes covered: SimpleTransformer, Config, collate_fn
Tutorial 3: Inference and Beam Search¶
Time: ~15 minutes
You'll learn:
- Greedy decoding
- Beam search decoding
- Comparing decoding strategies
- Evaluating with BLEU score
Key concepts: Inference modes, decoding algorithms, evaluation metrics
Tips for Success¶
Run Every Cell
Execute cells in order—many depend on previous outputs.
Experiment!
Try changing hyperparameters, model sizes, and data. Breaking things is how you learn.
What's Next?¶
After completing the tutorials:
- đź“– Dive deeper into Concepts
- 🔍 Explore the API Reference
- 🚀 Try your own dataset
Ready to begin?