Installation
This guide covers installing MAMMOTH on a local machine or a generic GPU server. For the CSC supercomputers (LUMI and Roihu), which need cluster-specific modules or a container, see the LUMI & Roihu quickstart.
Requirements
Python 3.11 or newer
PyTorch 2.8 or newer (the test suite is verified on 2.8.0). A GPU build is needed for real training. A CPU-only build is enough for inference: Mammoth trains big and runs small. Training a multilingual model needs many GPUs, but translating one direction loads only the encoder and decoder components that direction uses, so a single task runs comfortably on a laptop CPU (see Running a Translation Server). CPU-only is also fine for tests and small experiments.
A Unix-like OS (Linux or macOS)
Install from PyPI (recommended)
python -m venv .venv
source .venv/bin/activate
pip install mammoth-nlp
This installs MAMMOTH, its dependencies and its command-line tools.
Choosing the right PyTorch build
mammoth-nlp asks for torch>=2.8, which pip resolves to the default PyPI build. For a specific CUDA or ROCm version, install PyTorch first by following the selector at pytorch.org, then install MAMMOTH:
# example: CUDA 12.6 wheels
pip install torch --index-url https://download.pytorch.org/whl/cu126
pip install mammoth-nlp # keeps the torch you just installed if it satisfies torch>=2.8
Install from source
Install from source if you want the latest unreleased code or want to edit MAMMOTH itself.
git clone https://github.com/Helsinki-NLP/mammoth.git
cd mammoth
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
pip install -e .
To pick a PyTorch build, install it first as shown above. If you need a torch older than 2.8, skip the torch line with grep -v '^torch' requirements.txt | pip install -r /dev/stdin.
Verify the installation
python -c "import mammoth, torch; print('torch', torch.__version__, '| cuda', torch.cuda.is_available())"
mammoth_train --help
The command-line tools installed with the package are:
Command |
Purpose |
|---|---|
|
train a model |
|
translate with a trained model |
|
train a BPE tokenizer |
|
convert a trained model to Hugging Face format |
|
upload a converted model to the Hugging Face Hub |
|
download a model (or one task of a bundle) from the Hugging Face Hub |
|
run a local translation server with a web page (serving); needs the |
See HF tokenizers for mammoth_build_vocab, the quickstart for training and translating, and export to Hugging Face for the three Hugging Face commands.
In a source checkout, the repository root also has train.py and translate.py, which do the same as mammoth_train and mammoth_translate.
Optional dependencies
Hugging Face tokenizers and export.
requirements.txtalready includestokenizers,transformers,huggingface-hubandsafetensors. See the HF tokenizers guide and the export guide.Translation server.
pip install 'mammoth-nlp[server]'adds FastAPI and uvicorn formammoth_serve.
Troubleshooting
mammoth_<cmd>: command not found. The commands exist only after pip install (from PyPI or pip install -e .), and only while that venv is active. In a source checkout without installing, run the module instead, from the repository root:
Command |
Module |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Next steps
Quickstart: train and translate English→German on Multi30k.
LUMI & Roihu quickstart: running on the CSC supercomputers.
Data preparation: preparing your own corpora.