Building a Machine Translation Pipeline for Long-Form Manga and Web Novel Localization

    This article walks through the engineering practices for building a machine translation pipeline that handles long-running serialized content such as manga scripts and web novels. It covers a five-layer architecture, cleaning and segmentation strategies, three-tier context design, terminology consistency, content-hash caching with resumable execution, multi-dimensional quality evaluation, publishing and cost control, and a checklist of common pitfalls. Readers will learn how to keep output reproducible, resumable, verifiable, and maintainable as volume grows.

    1. Problem Background and Goals

    The hard part of long serialized text is not translating a single passage, but handling scale and consistency. Such material typically has three traits: the volume is large, with a single work reaching hundreds of chapters; proper nouns are dense, with character names, place names, and setting terms recurring constantly; and context dependency is strong, with many pronouns and omitted subjects that become ambiguous when read in isolation.

    The pipeline goals should therefore be explicit: reproducible (the same input yields the same output), resumable (no full recomputation after an interruption), verifiable (quality measured by quantitative metrics), and maintainable (terminology and style managed in one place).

    2. Layered Architecture

    Split the system into five layers, decoupled by files or messages so that a single point of failure does not force a full-chain rerun.

    1. Ingestion -> Cleaning & Segmentation -> Translation Execution -> Quality Evaluation -> Publishing & Archiving
    2. | |
    3. Terminology base Cache / checkpoint store

    The key payoff of layering: changing a cleaning rule does not trigger retranslation; updating the terminology base only requires rerunning affected segments; the evaluation layer can swap strategies independently.

    3. Cleaning and Segmentation: The Step That Sets the Ceiling

    Cleaning quality determines the ceiling for every downstream step. Issues to handle include mixed full-width and half-width characters, abnormal line breaks, duplicated empty paragraphs, missing quotation marks in dialogue, and footer or navigation noise.

    For segmentation, use a dual rule of “structure first, length as fallback”: split by chapter and scene first, then split overlong paragraphs a second time at sentence boundaries, never cutting mid-word.

    1. def split_paragraph(text, max_chars=400):
    2. if len(text) <= max_chars:
    3. return [text]
    4. sentences, buf = [], ""
    5. for s in text.replace("。", "。\n").split("\n"):
    6. if len(buf) + len(s) > max_chars and buf:
    7. sentences.append(buf)
    8. buf = s
    9. else:
    10. buf += s
    11. if buf:
    12. sentences.append(buf)
    13. return sentences

    Note that shorter segments are not automatically better. Too short loses context and causes pronoun resolution errors; too long raises truncation risk and cost volatility. Run a small comparison test against the language characteristics of the source, then fix the parameters.

    4. Context Window and Terminology Consistency

    Context design is the core of long-form translation. A three-tier context is recommended: a chapter summary (global), the previous few source paragraphs (local), and a glossary (constraint). Maintain the chapter summary in a rolling fashion, updating it after each completed chapter so the context does not grow without bound.

    Terminology consistency is achieved with a “terminology base + validator”. The base stores, as key-value entries, the source form, the preferred rendering, forbidden renderings, and notes; the validator scans the output after translation and sends any segment back for retranslation when a forbidden rendering is hit.

    1. {
    2. "term": "学園一の美少女",
    3. "preferred": "全校第一的美少女",
    4. "forbidden": ["第一美少女", "校花"],
    5. "note": "首次出现保留完整表述"
    6. }

    5. Caching, Concurrency, and Resumable Execution

    Assume batch jobs will fail. Use a content hash as the cache key, and include the model identifier, prompt version, and terminology base version in that key so any change invalidates it naturally. This avoids the hidden problem of “the prompt changed but an old cache entry was hit”.

    1. import hashlib
    2. def cache_key(text, prompt_ver, term_ver, model_tag):
    3. h = hashlib.sha256()
    4. h.update(text.encode("utf-8"))
    5. h.update(f"{prompt_ver}|{term_ver}|{model_tag}".encode())
    6. return h.hexdigest()

    For concurrency, use a bounded queue with exponential backoff retries. Failed segments go to a separate queue while the main flow keeps advancing, and are rerun together at the end, so overall throughput is not blocked by individual segments.

    6. Quality Evaluation and Manual Sampling

    Evaluation should be multi-dimensional rather than a single score: terminology hit rate, count of forbidden-rendering hits, length ratio (an abnormal source-to-target ratio hints at omission or addition), fidelity of numbers and proper nouns, and duplicate segment detection.

    Manual sampling uses stratified sampling: draw a random percentage, plus targeted checks on “low-confidence segments”, “terminology-dense segments”, and “overlong segments”. Sampling results flow back as input for improving the terminology base and prompts, closing the loop.

    7. Publishing, Archiving, and Cost Control

    The publishing layer should keep a triple of source text, translation, and metadata, where metadata records version, timestamp, terminology base version, and evaluation scores for traceability and diff comparison. Incremental publishing pushes only changed chapters, reducing useless writes.

    Cost control measures include reusing cache first, applying a lighter strategy to low-information segments, batching requests, and capping retry counts when evaluation fails, to prevent wasted loops.

    8. Common Pitfalls

    • Inconsistent encoding produces garbled text; enforce a single encoding at the entry point.
    • Segmentation that breaks sentence integrity; always split at sentence boundaries.
    • Prompt and terminology versions missing from the cache key, which scrambles results.
    • No checkpoint records, so an interrupted job reruns everything.
    • Evaluating single sentences only, while ignoring cross-chapter referential consistency.

    9. Summary

    Processing long serialized text is fundamentally an engineering problem, not a single-point algorithm problem. Make cleaning, segmentation, context, terminology, caching, and evaluation into replaceable modules, and link them with versioned metadata; only then do results stay stable and costs stay controlled as volume grows. For further elastic scaling, the execution layer can move to a container platform with a message queue and object storage, decoupling tasks and archiving artifacts. The same approach applies to general cloud-native architecture practices on Baidu AI Cloud.