Skip to main content

Pantogloss

Pantogloss is a TensorFlow/Keras many-to-English machine-translation library. Its first model, pantogloss-500-en, was converted and numerically validated from the model described in Many-to-English Machine Translation Tools, Data, and Pretrained Models (ACL-IJCNLP 2021).

The Python package is distributed through PyPI, while the initial model is kept in a separate public Hugging Face repository. Pantogloss 0.3.0 and later download it anonymously by default; cached or explicit Hugging Face credentials remain supported for private and gated model repositories.

The codebase and converted model are licensed under Apache-2.0. This repository is private during initial development.

Intended API

from pantogloss import Translator

translator = Translator.from_pretrained("pantogloss-500-en")
print(translator.translate("Comment allez-vous ?"))

RTG-compatible beam search is available without changing the return type:

print(
    translator.translate(
        "Comment allez-vous ?",
        beam_size=4,
        length_penalty=0.6,
    )
)

Pantogloss selects the first TensorFlow GPU automatically and enables memory growth. Device choice can also be made explicit:

translator = Translator.from_pretrained("pantogloss-500-en", device="gpu")
print(translator.device_info)

Using device="gpu" fails clearly if TensorFlow cannot see a GPU; use device="cpu" to force CPU inference.

Greedy translation uses an encode-once, graph-compiled TensorFlow decoding loop with decoder self-attention and cross-attention key/value caches by default. If a TensorFlow backend cannot compile that loop, Pantogloss falls back to the equivalent eager decoder. The fallback can also be selected explicitly for diagnostics or parity testing:

translator = Translator.from_pretrained(
    "pantogloss-500-en", compiled_decode=False
)

Structured results are additive to the original string API:

result = translator.translate_detailed("Bonjour le monde.")
print(result.text, result.source_tokens, result.target_tokens)
print(result.execution_device, result.elapsed_seconds)

For extracted documents, one shared model can segment, batch, and reconstruct text while retaining blank lines and paragraph boundaries:

from pantogloss import DocumentTranslator

documents = DocumentTranslator(translator)
result = documents.translate(
    extracted_text,
    source_language="fr",
    max_source_tokens=512,
    long_input="split",
)
print(result.text)

Long segments can use split, truncate, or error policy. Failures are isolated to individual segments and recorded in result.segments; successful neighbors remain ordered. Layout-only segments such as page numbers, dot leaders, and separator rules are preserved verbatim instead of being sent to the translation model.

Install pantogloss[tika] to use the pantogloss-tika extraction-to-English command without a translation server or Docker container. It supports bounded trials and page ranges, displays progress, writes output incrementally, and resumes from a fingerprint-protected JSONL checkpoint. See examples/tika_to_english.py for its compatibility wrapper.

The August 2026 full-document validation translated a 285,527-character Russian dissertation on an Apple M3 Max in 58 durable chunks. All 6,517 aligned segments completed without failures or truncation, 793 layout-only segments were preserved verbatim, and the 284,804-character English result contained no Cyrillic characters. A matching three-page CUDA trial on an RTX 3080 Ti Laptop GPU completed 139 segments with zero failures or truncation.

Install the accelerator backend for the machine:

# Linux with an NVIDIA GPU
pip install 'pantogloss[cuda]'

# Apple Silicon
pip install 'pantogloss[metal]'

Both use the same device="auto" or device="gpu" Python API. The CUDA extra does not install or replace the host NVIDIA driver. The Metal extra uses Apple's TensorFlow PluggableDevice and the TensorFlow 2.18 runtime combination validated by the Bytewise project.

Greedy decoding runs on the selected device. On Apple Silicon, beam decoding uses a correctness-first CPU execution fallback because Panto-500 validation found shape-sensitive corruption in Metal beam-expanded inference. CUDA beam decoding remains on GPU. Pantogloss records the effective beam execution device in evaluation manifests instead of silently claiming Metal placement.

The model is stored separately in the public Hugging Face repository chrismattmann/pantogloss-500-en; it is never included in the Python wheel.

The default token=None uses a locally cached Hugging Face credential when one exists but does not require one for public repositories. Use token=False to force anonymous access or pass a token explicitly without storing it:

import os

translator = Translator.from_pretrained(token=os.environ["HF_TOKEN"])

Command line

The pantogloss command loads the model once and supports arguments, files, and line-oriented Unix pipelines:

pantogloss info
pantogloss translate "Comment allez-vous ?"
printf 'Hola señor\nWie geht es Ihnen?\n' | pantogloss translate --device gpu
pantogloss translate --input source.txt --output english.txt --batch-size 16
pantogloss translate --beam-size 4 --length-penalty 0.6 "Hola señor"
pantogloss translate --max-source-tokens 512 --source-length-policy truncate "..."

Use --json for JSON Lines output and --offline to require an already cached model snapshot. Translation data goes to stdout (or --output); model and device diagnostics are suppressed by default so pipelines remain clean. Use --verbose for Pantogloss loading progress or --tensorflow-logs for TensorFlow, CUDA, and Metal startup diagnostics.

Development status

The complete 307-variable Keras model has been converted locally from all 308 learned PyTorch tensors (the target embedding and output projection are tied). Greedy parity against the archived RTG implementation passes across a ten-language batch: token IDs and translations match exactly, while final logits have a maximum absolute error of 1.24e-5. With the original beam size 4 and length penalty 0.6, all decoded four-best candidate sets match. One near-tied example changes top rank because of framework floating-point ordering. Model version 0.1.0 is released in the public Hugging Face repository at an immutable commit.

The source model and generated artifacts stay under the ignored artifacts/ directory. To reproduce conversion after acquiring the source archive:

python tools/convert_rtg_checkpoint.py \
  artifacts/source/rtg500eng-tfm9L6L768d-bsz720k-stp200k-ens05 \
  artifacts/converted/pantogloss-500-en-candidate

Run the reference parity harness with:

CUDA_VISIBLE_DEVICES=-1 python tools/check_parity.py \
  artifacts/source/rtg500eng-tfm9L6L768d-bsz720k-stp200k-ens05 \
  artifacts/converted/pantogloss-500-en-candidate

To require and verify real GPU placement:

python tools/check_gpu.py artifacts/converted/pantogloss-500-en-candidate

Apple Silicon validation

Pantogloss uses the same hardware-neutral GPU API for CUDA and Metal. On an M-series Mac with Python 3.12 and Xcode command-line tools installed:

python3.12 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -e '.[metal,test]'
hf auth login
python tools/check_platform.py --device cpu
python tools/check_platform.py --device gpu
python tools/benchmark_inference.py --device gpu --runs 5

The portable platform report identifies the selected backend as cpu, cuda, or metal, verifies the first model variable's actual TensorFlow placement, and runs a real translation. Metal placement and inference are validated on an Apple M3 Max with TensorFlow 2.18.1. Before compiled decoding, a short batch-one sentence had warmed medians of 0.545 seconds on CPU and 0.633 seconds on Metal.

Decoding benchmark

Use the same input repeated into batches of 1, 8, 16, and 32:

for batch in 1 8 16 32; do
  python tools/benchmark_inference.py --device gpu --runs 5 \
    --batch-size "$batch"
done

The August 2026 TensorFlow 2.18.1 validation produced the following warmed throughput. CPU and CUDA were measured on Linux; Metal was measured on an Apple M3 Max with 128 GB unified memory.

Batch size CPU CUDA (RTX 3080 Ti Laptop) Metal (M3 Max)
1 11.6/s 14.2/s 3.83/s
8 62.1/s 94.9/s 29.15/s
16 96.8/s 160.6/s 60.20/s
32 143.0/s 330.0/s 115.28/s

The M3 Max batch-one median was 0.253 seconds with compiled cached decoding, down from the pre-compilation measurement of 0.633 seconds. Cold model load and first-call graph compilation are reported separately from the warmed runs.

The benchmark JSON also reports total process peak RSS and, where supported by the TensorFlow backend, allocator current memory, peak memory, and the peak increment above its post-warmup baseline. At batch 32, CUDA's allocator rose by 22.5 MiB above the 2,114.5 MiB model baseline. Peak process RSS was approximately 8.4 GiB on CPU, 5.9 GiB with CUDA, and 4.0 GiB with Metal. TensorFlow Metal 1.2 reports zero for its allocator counters, so process RSS is the meaningful Metal memory measurement.

Translation evaluation

Pantogloss includes a versioned evaluation runner and a checksum-pinned, project-authored CC0 smoke corpus covering 12 languages and seven scripts. It supports durable resumable translation artifacts, model-free rescoring, adaptive batch recovery, deterministic paired-bootstrap confidence intervals, and aligned regression comparisons. Reports include BLEU, chrF, per-language diagnostics, failures, empty and unknown-token outputs, latency, and throughput.

Install the development extras and run the complete automated suite:

# Linux CUDA
python -m pip install -e '.[cuda,evaluation,test]'

# Apple Silicon Metal
python -m pip install -e '.[metal,evaluation,test]'

python -m pytest

The August 2026 smoke validation used Panto-500 revision 250fc3b4122d79ac0734b28b368d2c1d68f72f7e and TensorFlow 2.18.1:

Platform and decoding BLEU chrF Failures
Linux CPU greedy 64.72 73.29 0
Apple M3 Max Metal greedy 64.72 73.29 0
Linux CPU beam-4 70.96 76.64 0
Apple M3 Max CPU beam fallback 70.96 76.64 0

The M3 beam fallback matched CPU exactly across all 12 translations: zero metric delta, zero disagreements, and zero new failures. The automated suite passed on both Kubuntu and Apple Silicon; hardware validation supplements the routine tests because hosted CI does not provide these accelerators.

See evaluation/README.md for commands, checked-in reports, reproducibility details, and the important limits on interpreting this deliberately small regression fixture.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pantogloss-0.5.0.tar.gz (76.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pantogloss-0.5.0-py3-none-any.whl (44.7 kB view details)

Uploaded Python 3

File details

Details for the file pantogloss-0.5.0.tar.gz.

File metadata

  • Download URL: pantogloss-0.5.0.tar.gz
  • Upload date:
  • Size: 76.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pantogloss-0.5.0.tar.gz
Algorithm Hash digest
SHA256 81bbe3b931a49afbf4070413b6722e5c5b07b987e2e54db1c8de133e2d8aae90
MD5 e061767cd028ba8977f4801544f3a714
BLAKE2b-256 5a338e9a76632cc24e0126f75b01cd88c767586bdc3cc8f3f81964c039e3302a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pantogloss-0.5.0.tar.gz:

Publisher: release.yml on chrismattmann/pantogloss

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pantogloss-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: pantogloss-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 44.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pantogloss-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5e517076f5d4258ef95b48174f17c00701b67bf0b4144e4542f8bb34f6755c28
MD5 28792c53fc7b866104c9494c02547aaf
BLAKE2b-256 46bebb0a9725ab5260556191c30076ee7ba20e4e61c56f2500da1bf216a21658

See more details on using hashes here.

Provenance

The following attestation bundles were made for pantogloss-0.5.0-py3-none-any.whl:

Publisher: release.yml on chrismattmann/pantogloss

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page