How fzp0424/self_correct_mt works
TEaR is an LLM-based machine-translation self-correction application. Its main workflow accepts source text, generates an initial translation, estimates translation errors, and conditionally refines the result; file mode additionally reads paired datasets and persists segment results. The shared library builds prompts and dispatches requests to supported model providers. Evaluation is a separate capability. The workflow edges are grounded in the shown callers and library; dataset and prompt details not sampled are represented only where those callers explicitly reference them.
Main entry points: run_file.py File input · ter_lib.py Translate · run_cmd.py Command input · demo.py Demo workflow
Components 17
User entry points
- Command input
run_cmd.py - File input
run_file.py - Demo workflow
demo.py
Translation workflow
- Translate
ter_lib.py - Estimate errors
ter_lib.py - Refine translation
ter_lib.py - Model dispatch
ter_lib.py
Prompts and data
- Prompt templates
prompts - Few-shot examples
prompts/data-shots - Language pairs
language_pair.json - Translation datasets
dataset/mt - Result JSON
Evaluation
- Evaluation runner
eval/evaluation.py - Evaluation samples
eval/zh-en
Other components
- User
- LLM providers
- Metric models
Connections 26
- User → Command input: enters text
run_cmd.py - User → File input: starts run
run_file.py - User → Demo workflow: runs example
README.md - Command input → Translate: calls
run_cmd.py - Command input → Estimate errors: calls
run_cmd.py - Command input → Refine translation: calls conditionally
run_cmd.py - File input → Translate: calls
run_file.py - File input → Estimate errors: calls
run_file.py - File input → Refine translation: calls conditionally
run_file.py - Demo workflow → Translate: calls
demo.py - Demo workflow → Estimate errors: calls
demo.py - Demo workflow → Refine translation: calls conditionally
demo.py - Translate → Model dispatch: requests completion
run_cmd.py - Estimate errors → Model dispatch: requests assessment
run_cmd.py - Refine translation → Model dispatch: requests correction
run_cmd.py - Model dispatch → LLM providers: invokes provider
ter_lib.py - Translate → Prompt templates: loads template
ter_lib.py - Estimate errors → Prompt templates: loads template
ter_lib.py - Refine translation → Prompt templates: loads template
ter_lib.py - Translate → Few-shot examples: loads examples
ter_lib.py - Command input → Language pairs: checks pair
run_cmd.py - File input → Language pairs: selects pair
run_file.py - File input → Translation datasets: reads segments
run_file.py - File input → Result JSON: appends results
run_file.py - Evaluation runner → Evaluation samples: reads samples
eval/evaluation.py - Evaluation runner → Metric models: scores translations
eval/evaluation.py