Installation¶
This guide will help you get TorchLingo installed and ready to use in just a few minutes.
🚀 Recommended: Google Colab (Easiest)¶
The fastest way to get started! Google Colab requires zero setup on your machine and provides free GPU access.
Step 1: Open a Colab Notebook¶
- Go to Google Colab
- Click File → New notebook (or open one of our tutorial notebooks)
Step 2: Enable GPU (Important for Training!)¶
- Click Runtime → Change runtime type
- Select GPU from the "Hardware accelerator" dropdown
- Click Save
Free GPU Access
Colab provides free access to NVIDIA GPUs. Training is 10-50x faster with GPU compared to CPU!
Step 3: Install TorchLingo¶
In the first cell of your notebook, run:
Step 4: Verify Installation¶
# Check that everything is working
import torch
print(f"PyTorch version: {torch.__version__}")
print(f"CUDA available: {torch.cuda.is_available()}")
if torch.cuda.is_available():
print(f"GPU: {torch.cuda.get_device_name(0)}")
# Test TorchLingo
import torchlingo
from torchlingo.config import get_default_config
config = get_default_config()
print(f"\n✓ TorchLingo is ready! Default batch size: {config.batch_size}")
You should see output showing CUDA is available and a GPU name (like "Tesla T4").
💻 Local Installation¶
If you prefer to run locally or want to explore/modify the source code:
Prerequisites¶
Before installing TorchLingo, make sure you have:
- Python 3.10 or higher - Download Python
- pip (comes with Python)
- Git (optional, for cloning the repository)
Check your Python version
Open a terminal and run:
You should seePython 3.10.x or higher.
Method 1: Install with pip (Simplest)¶
Method 2: Install from Source (For Development)¶
This is the best method if you want to explore the code, run tutorials, or modify things:
Verify Installation¶
Let's make sure everything is working:
# In a Python shell or script
import torchlingo
from torchlingo.config import get_default_config
config = get_default_config()
print(f"TorchLingo is ready! Default batch size: {config.batch_size}")
You should see output like:
Installing Dependencies¶
TorchLingo has a few key dependencies that are automatically installed:
| Package | Purpose |
|---|---|
torch |
Deep learning framework |
pandas |
Data loading and manipulation |
sentencepiece |
Subword tokenization |
tensorboard |
Training visualization |
sacrebleu |
Translation quality metrics |
Optional: Language-Specific Dependencies¶
TorchLingo supports specialized tokenizers for Asian languages. Install based on your needs:
Installs fugashi and unidic-lite for Japanese morphological analysis.
Installs jieba for Chinese word segmentation.
| Extra | Packages Installed | Use Case |
|---|---|---|
japanese |
fugashi, unidic-lite | Japanese tokenization |
chinese |
jieba | Chinese word segmentation |
asian |
fugashi, unidic-lite, jieba | Both Japanese and Chinese support |
Optional: Development Dependencies¶
If you want to run tests, lint code, or contribute to TorchLingo:
This installs:
| Package | Purpose |
|---|---|
ruff |
Fast Python linter and formatter |
isort |
Import sorting |
build |
Building distribution packages |
twine |
Publishing to PyPI |
Optional: Documentation Dependencies¶
To build these docs locally:
GPU Support¶
TorchLingo works on CPU out of the box, but training is much faster with a GPU.
PyTorch should automatically detect your NVIDIA GPU. Verify with:
On M1/M2/M3 Macs, PyTorch can use the Metal Performance Shaders backend:
No GPU? No problem! All tutorials work on CPU. Just expect longer training times for larger models.
Common Issues¶
ImportError: No module named 'torchlingo'
Make sure you've activated your virtual environment:
ModuleNotFoundError: No module named 'torch'
PyTorch didn't install correctly. Try:
Permission denied when installing
Don't use sudo pip install. Use a virtual environment instead (Method 1 above).
Next Steps¶
Now that TorchLingo is installed, let's build something!