跳转到内容

Configuration

此内容尚不支持你的语言。

VariableDefaultDescription
POLYGLOT_MODELtranslategemma:12bDefault Ollama model for translation
POLYGLOT_CONCURRENCY1Max concurrent Ollama API calls

Three TranslateGemma model sizes are available:

ModelParametersVRAMUse case
translategemma:4b4 billion3.3 GBQuick translations, limited GPU
translategemma:12b12 billion8.1 GBGeneral use, balanced quality/speed
translategemma:27b27 billion17 GBMaximum quality, large GPU required

Set the default model via environment variable:

Terminal window
export POLYGLOT_MODEL=translategemma:4b

Or override per-request:

from pypolyglot import translate, TranslateOptions
result = await translate("Hello", "en", "ja",
TranslateOptions(model="translategemma:27b"))

The concurrency setting controls how many Ollama API calls run simultaneously. This is GPU-bound — running too many concurrent calls can cause VRAM exhaustion.

Terminal window
export POLYGLOT_CONCURRENCY=2

Recommendations:

  • 1 (default) — Safe for any GPU, sequential processing
  • 2 — Good for 12+ GB VRAM with the 4b model
  • 3 — Maximum, only for 24+ GB VRAM

The semaphore prevents more than concurrency calls from hitting the GPU at once. Additional requests queue until a slot opens.

The built-in software glossary covers 12 technical terms. Add your own:

from pypolyglot import translate, TranslateOptions, GlossaryEntry
custom_glossary = [
GlossaryEntry("Widget", {"ja": "ウィジェット", "zh": "小部件"}),
GlossaryEntry("Dashboard", {"ja": "ダッシュボード", "zh": "仪表盘"}),
]
result = await translate(text, "en", "ja",
TranslateOptions(glossary=custom_glossary))

Glossary entries only apply when the term appears in the source text AND the target language has a translation defined.

Translation cache stores segment-level results in .polyglot-cache.json. It uses Levenshtein distance for fuzzy matching — segments that are similar enough to a cached entry reuse the cached translation.

Cache is per-directory and per-language pair. To clear it, delete the cache file:

Terminal window
rm .polyglot-cache.json