Skip to content

TorchLingo

TorchLingo Logo

A beginner-friendly PyTorch library for learning Neural Machine Translation

Python 3.10+ PyTorch License: AGPL-3.0

Getting Started View Tutorials


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!

%pip install torchlingo

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.

    Quick Start

  • Learn by Doing


    Interactive Jupyter notebooks walk you through every concept step-by-step.

    Tutorials

  • Readable Code


    Every function is documented. Every tensor shape is explained. No black boxes.

    API Reference

  • Two Architectures


    Learn both classic LSTM and modern Transformer models side by side.

    Model Concepts

๐Ÿš€ 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:

  1. Explicit is better than implicit โ€” You can trace every tensor operation
  2. Notebooks are first-class โ€” Every concept is executable
  3. Start simple, add complexity later โ€” Basic tokenization โ†’ SentencePiece โ†’ Multilingual
  4. Docs that teach โ€” Every docstring explains why, not just what

Read more about our design philosophy.


Ready to translate?

Get Started