Serve

mammoth_serve: run a local Mammoth translation server.

mammoth_serve –model path/to/checkpoint_dir # training checkpoint mammoth_serve –model ./model # folder made by mammoth_download mammoth_serve –model org/mammoth-modular –tasks eng-spa,deu-fra mammoth_serve –model path/to/checkpoint_dir –tasks eng-spa –src in.txt.gz –output out.txt

–model takes a training checkpoint directory or any HF export (modular, –single-artifact bundle, standalone; local directory or Hub repo id). By default only directions whose files are already on disk are loaded, so a folder made by mammoth_download serves what was downloaded into it, and nothing is downloaded at start. Other directions can be loaded (and, if needed, downloaded) later from the web page or with POST /api/tasks. API: see mammoth/serving/app.py.

With –src the server does not start: the file is translated with the one direction in –tasks and the command exits. One segment per line, as in training data; the output has exactly one line per input line, in order (empty lines stay empty).

usage: mammoth_serve [-h] --model MODEL [--tasks TASKS] [--step STEP]
                     [--device DEVICE] [--dtype {bf16,fp16,fp32}]
                     [--threads THREADS] [--host HOST] [--port PORT]
                     [--src SRC] [--output OUTPUT] [--num-beams NUM_BEAMS]
                     [--max-new-tokens MAX_NEW_TOKENS]
                     [--max-length-factor MAX_LENGTH_FACTOR]
                     [--max-batch-size MAX_BATCH_SIZE]
                     [--max-batch-tokens MAX_BATCH_TOKENS]

Named Arguments

--model

Training checkpoint directory, or HF export: local directory or Hub repo id

--tasks

Directions to load at start: comma-separated ‘src-tgt’ list, ‘downloaded’ (default: the trained tasks, plus the directions downloaded with mammoth_download, whose files are on disk), ‘trained’ (every trained task), ‘all’ (also every zero-shot direction) or ‘none’

Default: 'downloaded'

--step

Checkpoint step to load (training checkpoints; default: best, else latest)

--device

cpu, cuda, cuda:N or mps; auto = cuda if available, else cpu

Default: 'auto'

--dtype

Possible choices: bf16, fp16, fp32

Weight dtype (default fp32; bf16 halves memory)

Default: 'fp32'

--threads

CPU threads for torch (default: torch’s choice)

--host

Interface to listen on (default: this machine only; 0.0.0.0 for all)

Default: '127.0.0.1'

--port

Default: 8888

file mode (translate a file and exit instead of starting the server)

--src

Input file, one segment per line; .gz is read as gzip, ‘-’ is stdin. Needs exactly one direction in –tasks

--output

Output file, one translation per line; .gz is written as gzip (default: stdout)

Default: '-'

generation defaults (requests may lower max_new_tokens or change num_beams)

--num-beams

Default: 4

--max-new-tokens

Default: 512

--max-length-factor

Default: 2.0

--max-batch-size

Default: 32

--max-batch-tokens

Default: 4096