This project provides a small MLX-based translation CLI for beko-translate.
The primary entrypoint is the beko-translate command (installed via uv run).
- Install deps:
uv sync(oruv add --dev ...when adding dev tools) - Run CLI:
uv run beko-translate --text "Hello" --input-lang en --output-lang ja - PDF CLI:
uv run beko-translate-pdf paper.pdf --input en --output ja - Interactive (default when no args + tty):
uv run beko-translate - Streaming (one-shot):
uv run beko-translate --stream --server never --text "こんにちは" - Server mode:
- Start:
uv run beko-translate server start - Status:
uv run beko-translate server status - Stop:
uv run beko-translate server stop - Use server automatically:
uv run beko-translate --server auto
- Start:
- Run tests + lint + typecheck:
uv run tox(includes MLX integration tests)- Lint only:
uv run ruff check . - Typecheck only:
uv run ty check - Tests only:
uv run pytest - MLX integration tests:
RUN_MLX_INTEGRATION=1 uv run pytest -m integration
- Lint only:
- Release:
- Keep
release-log.mdupdated (useHEADfor unreleased changes). - Run
python ./build.py --releaseto test, build, publish, and tag. build.pyfails if git is dirty oruv.lockis out of date.
- Keep
beko_translate/cli.py: MLX-only translation CLI implementationpdf_cli.py: PDF translation CLI (pdf2zh_next + beko-translate)__init__.py: exposesmain
scripts/to_mlx.py: convert HF models to MLX (q4/q8) usingmlx_lm.converttranslate.py: example script for HF/MLX translation
tests/- unit + optional MLX integration tests
output/- local MLX model outputs (when converting locally)
.venv/,.tox/- local dev environments
- Default MLX model (remote):
hotchpotch/CAT-Translate-0.8b-mlx-q4 - Other available MLX repos:
hotchpotch/CAT-Translate-0.8b-mlx-q8hotchpotch/CAT-Translate-1.4b-mlx-q4hotchpotch/CAT-Translate-1.4b-mlx-q8mlx-community/HY-MT1.5-1.8B-4bitmlx-community/HY-MT1.5-1.8B-8bitmlx-community/HY-MT1.5-7B-4bitmlx-community/HY-MT1.5-7B-8bit- Aliases:
hymt-> 1.8B-4bit
beko-translatesupports--textor stdin input.- If
--input-langand--output-langare omitted,fast-langdetectis used to detect English/Japanese (k=3) and infer the direction. beko-translatedefaults:- model:
hotchpotch/CAT-Translate-0.8b-mlx-q4 - sampling: temperature=0.0, top_p=0.98, top_k=0
- no-repeat: ngram=4, window=128
- trust remote code: enabled by default
- KV cache:
max_kv_size = prompt_tokens + max_new_tokens(auto)
- model:
- Model aliases:
cat->hotchpotch/CAT-Translate-1.8b-mlx-q8plamo->mlx-community/plamo-2-translate
beko-translate-pdfdefaults:- en->ja, model
hotchpotch/CAT-Translate-1.4b-mlx-q8 - max-new-tokens=1024
- pdf2zh args include
--qps 4
- en->ja, model
- If
beko-translate-pdfstarts a server itself, it will stop it after the translations finish. Existing servers are left running. - Server uses a Unix domain socket under
~/.config/beko-translate/withbeko-translate.sockandserver.logby default. Override with--socket/--log-fileorBEKO_TRANSLATE_SOCKET/BEKO_TRANSLATE_LOG.