TorchLingo¶
A beginner-friendly PyTorch library for learning Neural Machine Translation
What is TorchLingo?¶
TorchLingo is a compact, educational library designed to teach you the fundamentals of Neural Machine Translation (NMT) using PyTorch. Whether you've never touched PyTorch before or you're looking to understand how Google Translate works under the hood, TorchLingo has you covered.
Perfect for Students
TorchLingo was built for university coursework. The code is intentionally simple, readable, and well-documentedβno magic, no hidden complexity.
Run in Google Colab
The easiest way to get started is with Google Colabβno installation required on your machine!
Colab provides free GPU access which speeds up training significantly. Just go to Runtime β Change runtime type β GPU.
β¨ Features¶
-
Easy to Start
Get your first translation model running in under 5 minutes with our quickstart guide.
-
Learn by Doing
Interactive Jupyter notebooks walk you through every concept step-by-step.
-
Readable Code
Every function is documented. Every tensor shape is explained. No black boxes.
-
Two Architectures
Learn both classic LSTM and modern Transformer models side by side.
π Quick Example¶
Here's a taste of what working with TorchLingo looks like:
from torchlingo.config import Config
from torchlingo.data_processing import NMTDataset, create_dataloaders
from torchlingo.models import SimpleTransformer
# 1. Create a configuration
config = Config(
batch_size=32,
learning_rate=1e-4,
d_model=256,
)
# 2. Load your data
train_dataset = NMTDataset("data/train.tsv", config=config)
# 3. Create your model
model = SimpleTransformer(
src_vocab_size=len(train_dataset.src_vocab),
tgt_vocab_size=len(train_dataset.tgt_vocab),
config=config,
)
# 4. Train and translate!
# (See our tutorials for the complete training loop)
πΊοΈ Where to Go Next¶
| If you want to... | Go here |
|---|---|
| Install TorchLingo | Installation Guide |
| Build your first model in 5 minutes | Quick Start |
| Understand the theory behind NMT | What is NMT? |
| Follow step-by-step notebooks | Tutorials |
| Look up a specific function | API Reference |
π Philosophy¶
TorchLingo follows a few key principles:
- Explicit is better than implicit β You can trace every tensor operation
- Notebooks are first-class β Every concept is executable
- Start simple, add complexity later β Basic tokenization β SentencePiece β Multilingual
- Docs that teach β Every docstring explains why, not just what
Read more about our design philosophy.
π Acknowledgements¶
This project was initially developed by Josh Christensen as part of his undergraduate work at BYU.
"I hope that TorchLingo will be a valuable resource for students learning about neural machine translation, and that they will consider improving this project and the entire world with the knowledge they gain."
β Josh Christensen
Ready to translate?