Building a Document Translation and Proofreading Agent Workflow
This article explains how to build a two-stage AI agent workflow for translating and proofreading technical documents. It covers the limitations of single-pass translation, a six-step architecture with structured data contracts, prompt design for the translation and review agents, automated quality gates, batch processing support, metrics for iteration, and common pitfalls to avoid.
1. Background: Why Single-Pass Translation Falls Short
In scenarios like enterprise knowledge management, technical documentation localization, and cross-border collaboration, translating English documents into Chinese is a frequent need. Sending an entire document to a model for a single translation pass typically exposes three types of problems. First, terminology is inconsistent across the document, with the same technical term rendered in multiple ways in different sections. Second, long documents exceed the context window, causing cross-section references to be lost. Third, there is no quality verification step, making omissions, mistranslations, and broken formatting hard to detect.
The core idea of a two-stage pipeline is to decouple generation from review. The first stage focuses on faithful conversion, while the second focuses on standards and consistency. The benefits are clear: single responsibility, shorter prompts, easier issue localization, and the ability to insert glossaries, style guides, and automated checks in between.
2. Overall Architecture: Two Stages in Series and the Data Contract
A practical pipeline usually consists of six stages: document parsing, segmentation and chunking, translation agent, proofreading agent, quality gate, and human-in-the-loop.
Document input -> Parse & clean -> Smart chunking -> Translation Agent|Glossary / Context summaryvProofreading Agent -> Quality gate -> Human review -> Write back & archive
The key is to define a clear data contract and avoid passing plain text through a black box. Intermediate outputs should use a structured format, for example:
{"chunk_id": "sec-3-2","source": "The API gateway enforces rate limits per tenant.","draft": "API 网关按租户执行速率限制。","terms": [{"en": "rate limit", "zh": "速率限制"}],"status": "pending_review","issues": []}
Retaining chunk_id alongside the source text is the foundation for later diff comparison, regression testing, and issue localization.
3. Stage One: Prompt Design for the Translation Agent
The translation prompt should emphasize being faithful, complete, and non-explanatory. It is recommended to split the constraints into four blocks: role and goal, terminology constraints, formatting constraints, and exception handling.
You are a technical document translator. Requirements:1. Stay faithful to the source; do not add or remove information or insert explanatory content;2. Strictly use the translations provided in the glossary;3. Preserve Markdown structure, code blocks, placeholders, and variable names without translating them;4. When encountering an uncertain proper noun, keep the original and mark it with [?] at the end.
Two additional engineering practices: first, inject the glossary per section using retrieval augmentation rather than stuffing the entire glossary into the prompt, to control context length; second, maintain a rolling summary for long documents and pass it along as chunking progresses to mitigate broken cross-section references.
4. Stage Two: The Proofreading Agent’s Checklist
The proofreading stage is no longer “take another look” but a systematic item-by-item check that outputs a structured issue list rather than directly rewriting the full text. This preserves traceability and makes it easy to track defect distribution.
You are a translation reviewer. Output only the issue list; do not output a full rewrite.Checklist:- Omissions/additions: whether sentence count and information points match the source- Terminology consistency: whether it deviates from the glossary- Whether numbers, units, dates, and code identifiers were altered- Whether the Chinese is fluent and free of translationese- Whether formatting is intact (heading levels, lists, tables, link placeholders)Output format: {"chunk_id": "...", "issues":[{"type":"term","detail":"..."}]}
In practice, the proofreading agent should only make judgments and suggestions, while deterministic programs perform the replacements, preventing the model from introducing new deviations during rewriting.
5. Quality Gates and Automated Validation
Setting quantifiable gate rules between and after the two stages is key to pipeline stability. These can be implemented with a general rule engine or scripts, without relying on any specific product:
- Structure validation: Markdown heading count, code block pairing, consistent table column counts;
- Placeholder validation: variable, tag, and anchor counts strictly equal to the source;
- Terminology hit rate: reject if the compliant usage ratio of glossary terms falls below a threshold;
- Length anomaly: trigger an alert if the translation-to-source length ratio falls outside a reasonable range;
- Number consistency: extract numbers and units and compare as sets.
Only chunks that pass all checks enter the human queue, where reviewers handle only high-risk segments, significantly reducing review costs.
6. Batch Processing and Runtime Support
For enterprise-scale batch scenarios, general cloud capabilities can support the runtime: object storage holds source documents and outputs, a message queue handles peak shaving and retries for chunking tasks, a container platform hosts stateless executors, and logging and monitoring services provide observability. Baidu AI Cloud offers corresponding capabilities in these general categories and can be integrated following existing architectural conventions to avoid fragmentation with current systems.
Concurrency and idempotency are equally important: design an idempotency key for each chunk so that failed retries do not cause duplicate billing or duplicate writes; set timeouts and fallback strategies for model calls so that timed-out requests go to the human queue instead of retrying indefinitely.
7. Measuring Results and Continuous Iteration
It is recommended to establish four metrics: terminology consistency rate, omission rate, human modification rate, and average time per document. Keep a fixed regression set for each iteration and compare metric changes before and after prompt or glossary updates, avoiding “tuning by feel.”
The iteration loop is: cluster production issues -> attribute them to the translation or proofreading stage -> update prompts/glossary/gate thresholds -> regression validation -> gradual rollout.
8. Common Pitfalls
- Letting the proofreading stage rewrite the full text, causing loss of traceability and re-introduction of defects;
- Injecting the entire glossary, crowding out context and diluting attention;
- Lacking placeholder and code block protection, breaking technical content;
- Having no human-in-the-loop, automatically archiving high-risk documents;
- Missing metrics, making the optimization process unfalsifiable.
9. Summary
The value of a two-stage translation and proofreading pipeline lies not in “running a model once” but in breaking translation into an engineering process that is constrainable, verifiable, and measurable. By combining structured data contracts, layered prompts, deterministic validation, and a human-in-the-loop, you can ensure terminology consistency and formatting integrity while concentrating human effort where judgment is truly needed.
