Solutions to common problems with TranslateBookWithLLM.
- Connection Issues
- Model Issues
- Context Length Configuration
- Performance Issues
- Thinking Models
- EPUB Issues
- SRT Issues
- Style Preset Issues
- Web Interface Issues
- Configuration Issues
- Language Detection Issues
- Checkpoint & Resume Issues
- Quick Reference
- Debugging
- Getting Help
Cause: Ollama is not running or unreachable.
Solutions:
- Check Ollama icon in system tray
- Test connection:
curl http://localhost:11434/api/tags - Restart Ollama from Start Menu
- Check firewall (allow port 11434)
- Verify endpoint in
.env:API_ENDPOINT=http://localhost:11434/api/generate
Cause: Wrong, expired, or missing API key.
Solutions:
- Verify key is copied correctly (no extra spaces)
- Check key is active on provider's website
- Verify you have credits/quota remaining
- Check the correct environment variable is set:
- Gemini:
GEMINI_API_KEY - OpenAI:
OPENAI_API_KEY - OpenRouter:
OPENROUTER_API_KEY - Mistral:
MISTRAL_API_KEY - DeepSeek:
DEEPSEEK_API_KEY - Poe:
POE_API_KEY - NVIDIA NIM:
NIM_API_KEY
- Gemini:
Cause: Too many requests to the API.
Solutions:
- Wait a few minutes before retrying
- The system will automatically retry with exponential backoff
- Consider using a local model (Ollama) for large files
- Check your API plan limits
Cause: Model not downloaded or wrong name.
Solutions:
- List installed models:
ollama list - Download missing model:
ollama pull model-name - Check exact model name (case-sensitive)
- For cloud providers, verify the model ID is correct
Cause: Chunk is too large for model's context window.
Solutions:
- Reduce chunk size:
MAX_TOKENS_PER_CHUNK=200(default: 450 — see src/config.py) - Increase context window:
OLLAMA_NUM_CTX=8192 - Enable adaptive context:
AUTO_ADJUST_CONTEXT=true(default) - Use a model with larger context window
Formula: required_context = prompt_tokens + (MAX_TOKENS_PER_CHUNK * 2) + 50
See also: Context Length Configuration to find your model's real limit.
Cause: Not enough RAM/VRAM for the model.
Solutions:
- Use a smaller model (8B instead of 14B)
- Reduce context window:
OLLAMA_NUM_CTX=2048 - Close other applications
- Try a cloud provider (OpenRouter, Gemini, OpenAI)
Cause: The context window belongs to the model server, not to TBL. Ollama and LM Studio decide how many tokens a loaded model can hold; TBL can only stay inside that budget, or ask Ollama for a bigger one. It cannot raise the limit of an OpenAI-compatible server such as LM Studio.
Symptoms of a context window that is too small: output truncated mid-chunk, the same sentence repeated until the response ends, or chunks left in the source language.
Step 1 — check the model's real context window
- Ollama:
ollama show <model>prints the model's details, including its context length. Useollama listto get the exact model name. - LM Studio: the context length is a load setting of the model, chosen in the app before or when the model is loaded. Check the value there and reload the model if it needs to be larger.
An advertised context length is only an upper bound - a server can load the model with less.
Step 2 — set the two TBL settings in .env
| Setting | Default | Effect |
|---|---|---|
MAX_TOKENS_PER_CHUNK |
450 (src/config.py) |
Hard token limit for the source text of one chunk. Editable in the web UI under Settings; values are floored at MIN_CHUNK_SIZE_TOKENS (50) with no upper bound. |
OLLAMA_NUM_CTX |
4096 (src/config.py) |
Context window requested from Ollama (num_ctx). Ollama only - other providers ignore it. |
Formula: required_context = prompt_tokens + (MAX_TOKENS_PER_CHUNK * 2) + 50, where prompt_tokens is roughly 500 (instructions) plus MAX_TOKENS_PER_CHUNK (source text), and the response buffer is doubled because a translation can be up to twice as long as its source.
MAX_TOKENS_PER_CHUNK |
Context needed |
|---|---|
| 450 (default) | ~2048 |
| 700 | ~4096 |
| 800 | ~4096 |
| 1600 | ~8192 |
There is no hard ceiling on MAX_TOKENS_PER_CHUNK. Large-context cloud models (Gemini, GPT, Claude) will not run out of window at any realistic value; the practical limit is translation quality, since a model asked to translate a very long passage is more likely to condense or skip parts of it, and a failed chunk is retried in full.
Solutions:
- Ollama: raise
OLLAMA_NUM_CTXto at least the value the formula gives, or lowerMAX_TOKENS_PER_CHUNKuntil it fits the model you already load. - LM Studio, llama.cpp, vLLM and other OpenAI-compatible servers:
OLLAMA_NUM_CTXhas no effect. Raise the context in the server's own load settings, or lowerMAX_TOKENS_PER_CHUNKto fit what the server allocates. - Leave
AUTO_ADJUST_CONTEXT=true(default, Ollama only): the runtime starts atADAPTIVE_CONTEXT_INITIAL(2048) and grows byADAPTIVE_CONTEXT_STEP(2048) when a prompt would not fit, instead of allocatingOLLAMA_NUM_CTXupfront. - Remember that context costs memory - see "Out of memory" / OOM errors if raising it destabilizes the server.
Cause: Request taking too long.
Solutions:
- Increase timeout:
REQUEST_TIMEOUT=1800(30 min, default: 900) - Reduce chunk size:
MAX_TOKENS_PER_CHUNK=200 - Try a smaller/faster model
- Try a cloud provider
Symptoms: Model repeats the same phrase endlessly (e.g., "I'm not sure. I'm not sure...")
Cause: Context window exceeded, model confusion, or thinking model issues.
Solutions:
- The system automatically detects repetition loops and will retry
- Increase context window:
OLLAMA_NUM_CTX=8192 - Reduce chunk size for simpler content
- Use a different model
- For thinking models, see Thinking Models section
Detection thresholds (configurable):
- Standard models: 10 repetitions (
REPETITION_MIN_COUNT) - Thinking models: 15 repetitions (
REPETITION_MIN_COUNT_THINKING)
Some models (DeepSeek R1, Qwen3, QwQ, etc.) produce internal reasoning within <think> tags before responding. This is normal behavior.
| Type | Models | Behavior |
|---|---|---|
| Controllable | qwen3:8b, qwen3:14b, qwen3:4b | Can disable thinking with think=false |
| Uncontrollable | qwen3:30b, deepseek-r1, qwq, marco-o1, phi4-reasoning | Always thinks, cannot be disabled |
| Standard | Most other models | No thinking capability |
Cause: Uncontrollable thinking models always include reasoning.
Solutions:
- This is expected behavior - the system filters out
<think>content - Use a controllable thinking model (qwen3:8b, qwen3:14b)
- Use a standard (non-thinking) model
- Increase context for thinking models:
ADAPTIVE_CONTEXT_INITIAL_THINKING=6144
Cause: Model not in known lists or auto-detection failed.
Solutions:
- Enable debug mode to see detection logs:
DEBUG_MODE=true - The system auto-detects thinking behavior at runtime
- Check if model name matches known patterns in
src/config.py
Cause: Reader rejects the EPUB format.
Solutions:
- Test with Calibre (most permissive reader)
- Validate EPUB: validator.idpf.org
- Try a larger model (better at preserving structure)
- Enable debug mode to see parsing errors
Cause: Model did not preserve placeholders during translation.
Note: The placeholder format is now [id0], [id1], etc. (not ⟦TAG0⟧).
Solutions:
- The system has a 3-phase fallback that handles most cases automatically:
- Phase 1: Normal translation with placeholder preservation
- Phase 2: Token alignment to reinsert missing placeholders
- Phase 3: Proportional fallback based on position
- If there are many formatting errors in the output file, use a more capable LLM
- Enable adaptive context:
AUTO_ADJUST_CONTEXT=true
Cause: Style tags not properly preserved.
Solutions:
- The 3-phase fallback system handles this automatically
- Try a larger model for better HTML handling
- Enable debug mode to see tag preservation details
Cause: Model translated content that should be preserved.
Note: Technical content protection is always enabled and automatic.
Protected content includes:
- Code blocks (
```python ```) - Inline code (
`variable`) - LaTeX formulas (
$E=mc^2$,$$\int_0^1 x dx$$) - Measurements (
10 Mbps,5V,100 mA) - Technical IDs (
TIA/EIA-485-A,DS1487)
Solutions:
- This should work automatically - check if content matches expected patterns
- Enable debug mode to see what's being protected
- Report issue if valid technical content is being translated
Cause: Subtitle timing metadata corrupted.
Solutions:
- SRT uses fixed-count grouping: every block contains exactly
SRT_LINES_PER_BLOCKsubtitles (default 10), shared by translate and refine - Tune via
SRT_LINES_PER_BLOCK=10in.env— lower for tiny models (e.g. 5 for 4B params), higher for big-context models - Try a smaller block size for better timing preservation
Cause: Subtitle index corruption during translation.
Solutions:
- The system preserves subtitle structure automatically
- Try a larger model with better instruction-following
- Reduce
SRT_LINES_PER_BLOCKfor simpler chunks
| Symptom | Cause / fix |
|---|---|
| Extraction returns 0 rules | Raise Total chars, try more Samples, or the sampled passages may simply be too uniform to yield distinguishable style traits. See docs/STYLE_EXTRACTION.md. |
| Preset not in the style dropdown | The filename must end in .yaml, .yml, or (legacy) .txt — other extensions are skipped when the list is built. If it has the right extension and still doesn't show up, check the server log for a YAML parse error. |
| Preset has no visible effect | Confirm the phase: a preset with only translation set does nothing during a refine-only run, and one with only refinement set does nothing during a translation-only run. Check the "Phases" column (T, R, T+R) in the Styles tab. |
See docs/STYLE_EXTRACTION.md for the full guide.
Cause: Port 5000 is used by another application.
Solutions:
- Find what's using it:
- Windows:
netstat -an | find "5000" - Mac/Linux:
lsof -i :5000
- Windows:
- Change port in
.env:PORT=8080 - Kill the other process
Cause: File too large or wrong format.
Solutions:
- Check file format:
.txt,.epub,.srt,.docx - Check file size limits
- Try a smaller file first
- Check directory permissions:
data/uploads/must be writable
Cause: Network issue, CORS, or proxy problem.
Solutions:
- Check browser console for WebSocket errors
- Verify
HOST=127.0.0.1orHOST=0.0.0.0in.env - Check firewall allows WebSocket connections
- Try a different browser
- Disable proxy/VPN temporarily
Cause: Missing .env file on first run.
Solutions:
- Copy template:
cp .env.example .env(orcopyon Windows) - Edit with your configuration
- Restart application
- The system will prompt you with a 5-second grace period on first run
Cause: Environment variable not loaded.
Solutions:
- Set in
.env:DEBUG_MODE=true - Set before running:
export DEBUG_MODE=true(Mac/Linux) orset DEBUG_MODE=true(Windows) - Verify
.envis in the working directory - Restart the application
Cause: Invalid provider name in configuration.
Valid providers: ollama, gemini, openai, openrouter, mistral, deepseek, poe, nim
Solutions:
- Check spelling in
.env:LLM_PROVIDER=ollama - Provider names are case-insensitive
- For Gemini models with Ollama, the system auto-switches if model starts with "gemini"
Cause: Too short text, mixed languages, or ambiguous content.
Solutions:
- Use file with at least 50+ characters of text
- Explicitly specify source language:
- CLI:
-sl English - Web: Select in dropdown
- CLI:
- Ensure file content is primarily in one language
- Detection confidence threshold is 70% for auto-fill
Cause: Language not in the 40+ supported languages.
Solutions:
- Check supported languages in
src/utils/language_detector.py - Use ISO 639-1 language codes or full language names
- For rare languages, specify manually instead of auto-detect
Cause: Checkpoint data corrupted or session mismatch.
Solutions:
- Check database exists:
data/jobs.db - Verify uploaded file exists:
data/uploads/{job_id}/ - Start a new translation if checkpoint is corrupted
- Check logs for specific checkpoint errors
Cause: Translation was interrupted before checkpoint was saved.
Solutions:
- Checkpoints are saved periodically during translation
- Very short translations may not have checkpoints
- For long translations, progress should be preserved
- Ensure
data/directory is writable
| Problem | Quick Fix |
|---|---|
| Ollama not connecting | Restart Ollama |
| Model not found | ollama pull model-name |
| Context exceeded | MAX_TOKENS_PER_CHUNK=200 |
| Timeouts | REQUEST_TIMEOUT=1800 |
| Out of memory | Try smaller model |
| Repetition loop | Increase OLLAMA_NUM_CTX |
| EPUB broken | Try larger model |
| Placeholders visible | System auto-recovers (3-phase fallback) |
| Thinking model slow | Use controllable model (qwen3:14b) |
| Port in use | Set PORT=8080 in .env |
| No debug logs | Set DEBUG_MODE=true in .env |
Set in .env:
DEBUG_MODE=true
This enables:
- Verbose configuration logging
- API request/response details
- Model detection logs
- Context window calculations
- Token counting details
- Tag preservation logs
The system uses structured logging with types:
TRANSLATION_START- Translation job startedTRANSLATION_PROGRESS- Progress updatesTRANSLATION_COMPLETE- Job finishedERROR- Error occurredWARNING- Non-fatal issuesDEBUG- Detailed debug info
- Model Detection: Look for "Testing thinking behavior"
- Context Calculation: Context size detection logs
- Chunking: Token count per chunk
- API Calls: Request/response logging
- Error Recovery: Retry attempts and strategies
- Check this guide for common solutions
- Enable debug mode (
DEBUG_MODE=true) for detailed logs - Test with a small file first to isolate issues
- Review console/terminal logs for error messages
- Open an issue: GitHub Issues
- Operating system
- Python version
- LLM provider and model used
- Error message (full traceback if available)
- File type (EPUB, TXT, SRT)
- Relevant
.envsettings (without API keys) - Debug logs if available