The five hosted backends (Claude, ChatGPT, Gemini, Mistral, DeepSeek) put every glossary term into the system prompt of every batch, up to 100 terms.
The Ollama and OpenAI-compatible path already keeps only terms that occur in the batch and at most 15.
- What to change
- In LLMBackend._assemble_messages, reuse the filter from build_prompt_with_glossary: keep an entry only when its source term occurs in the escaped lines being translated, and cap the count.
- Why it matters
- A default batch is 15 lines, about 180 tokens of subtitle text, while 100 terms are about 800 tokens that are sent again for every batch of the file. Terms that do not occur in the batch cannot change the output.
- How often it happens
- The code shows the problem; how often it happens is assumed. To measure it: how many approved glossary terms a typical series has in a real install (the cap is glossary_max_terms, default 100)
- Who reaches this
- series with a large glossary, on the Claude, ChatGPT, Gemini, Mistral or DeepSeek backends
- Estimate
- about 790 prompt tokens per call on a series with a full 100-term glossary; about 395k per 1,000 calls if half the calls run with one (estimate)
What the estimate assumes
about 8 tokens per 'source -> target' pair (estimated from character count, not tokenised); batch_size 15 and lookback 10 / lookahead 5 as in config_settings.py; 1 to 3 terms occur per batch; half of all calls carry a full glossary, which is a guess.