Skip to content

Translating XML documents with a protected domain vocabulary

The translator workflow. Tool: atrium-translator.

Purpose

Archival collections hold text inside XML: structured metadata records such as those of the Archaeological Map of the Czech Republic (AMČR), and OCR transcriptions in ALTO XML. This workflow translates that text — into English by default — and writes it back into the same document, so that tags, namespaces, attributes and, for ALTO, the position of every word survive, and the result stays valid against its schema. In the AMČR pilot it turns the free-text fields of an AMČR record into English, the fields named by a list AMČR sends with each job; ALTO translation is for research and batch use. Domain terms can be held to their established translations from a controlled vocabulary, so that an archaeological term is rendered the same way in every document.

At a glance

In any well-formed XML with the list of the fields to translate (XPaths), which comes with each job (there is no default list, and a metadata run without one is refused); for research and batch use, ALTO XML pages; the two told apart by their root element unless a mode is named; files, folders or lists of URLs; optionally a vocabulary (CSV)
Out the translated document (same format); a translation log pairing source and target text (CSV); a paradata log (JSON); the ATRIUM document record (JSON), only when one is given, handed back unchanged. The service returns the log on request (include_log), and the record when one is sent
Runs as a command-line tool (main.py); a container image; an HTTP service image (POST /translate); an Agent Skill
Compute CPU; a GPU only for a self-hosted translation model (Qwen3.8-27B was measured on one 96 GB GPU)
Network the LINDAT translation service (the default backend) and the LINDAT UDPipe service (vocabulary matching), or the server of a language-model backend; the Hugging Face Hub for the language-identification model on first use, from a checkout (the published images carry it); GitHub when the vocabulary is fetched from keyword-extract's release
Code licence MIT
Component licences a default run uses CUBBITT through the LINDAT service (a CC BY-NC-SA 4.0 model, under LINDAT's terms of use) and, when the source language is detected, FastText (CC BY-NC 4.0); a run with only permissive components can be assembled (see below). No licence of an output is computed: Licences and paradata
Records SSH Open Marketplace tool CizIUW and workflow 13eHAZ

Steps

# Step What happens In → out Activity
1 Prepare a domain vocabulary (optional) Czech–English term pairs from the AMČR vocabularies and the TEATER thesaurus, each pointing back to the concept it came from. The project keeps one curated list, which keyword-extract publishes with each release: load_vocab.py --from-release builds the CSV from that asset, checked against its .sha256, and adds the concept's description where there is one. The bundled harvester collects pairs from the live sources instead (AMČR over OAI-PMH, TEATER over GraphQL). The shipped data_samples/vocabulary.csv is keyword-extract's v1.3.0-beta list: 4,715 pairs, 1,961 with a description. A vocabulary of one's own in the same CSV form works as well. → CSV Collecting
2 Choose the mode and the fields For metadata records, the fields to translate are listed as XPaths; namespaces and OAI-PMH envelopes are handled by the tool. ALTO transcriptions, for research and batch use, are translated in ALTO mode, which works on the words of each text line. The file's root element decides the mode (an <alto> root is ALTO, any other is metadata) unless one is named: --alto, --xpaths or --formats on the command line, is_alto in the service. The field list comes with each job (--xpaths FILE, or the service's xpaths field): there is no default list, and a metadata run or request without one is refused. AMČR passes its own list; the tool's amcr-fields.example.txt is a template of one, not that list. ALTO, XML —
3 Identify the source language A language-identification model detects the language of each text block (ALTO) or field (metadata), so a record that mixes languages is handled piece by piece. A guess is used only when it is confident and names a language the backend translates; otherwise the element's own label, the document's language, then a configured default decide. A confident guess of a language the backend cannot translate is reported for review. Naming the source language skips detection. Before anything is translated, the named language, or the default, is checked against the backend: a pair it cannot translate is refused (exit 1 on the command line, 422 unsupported_language_pair from the service) and is never rerouted. — —
4 Protect domain terms (optional) Vocabulary terms found in the text are replaced by placeholders before translation and restored as their agreed translations afterwards; multi-word terms are matched first, single words by lemma. Language-model backends receive the matching terms as a glossary in the prompt instead; the OpenAI-compatible backend can add each term's description as context (off by default). The command line takes the vocabulary with --vocabulary; the service applies one only when VOCABULARY_PATH names it. CSV Lemmatizing
5 Translate The text goes to the chosen backend: the LINDAT translation service (CUBBITT, the default), an OpenAI-compatible language-model API (such as Qwen3.8-27B on one's own vLLM server), or a self-hosted CTranslate2 model. Long texts are split at sentence boundaries first. Every reply is checked against its source: one that is empty, runaway, cut short, looping, or mixes Latin and Cyrillic letters in a word is requested again and re-run at the end of the document if it still fails. A reply that never recovers fails the document; it is never written. — Translating
6 Rebuild and validate the document ALTO: each text block is translated as a whole and line by line; the fluent whole-block translation is then divided among the original lines and written into the original word elements — replacing their text, or added beside it as an alternative. Metadata: the translation replaces the source text, or is added beside it with language labels. Metadata output can be validated against an XSD schema, such as the AMČR schema, which accepts replaced records and not appended ones: --xsd on the command line, XSD_PATH in the service. → ALTO, XML —
7 Review and record provenance A translation log beside each output pairs source and target text line by line or field by field, with a status saying whether each was translated normally, recovered by a re-run, placed approximately, or translated from a fallback language because the backend cannot translate the detected one. The paradata log records what was run, with each component's licence, and names the field list, the backend and the model, never the fields' text; nothing is written into the document record. → CSV, JSON —

Which backend. LINDAT stays the default. The recommended self-hosted alternative is openai_compatible with Qwen3.8-27B (Apache-2.0) on one's own vLLM server: in the bake-off it kept numbers and vocabulary terms about as well as LINDAT (terms 0.978 against 0.987) and failed no segment. ct2 with EuroLLM is no longer recommended, because it drops short segments (see Limits). The bake-off compares the backends without reference translations. Its script is eval/bakeoff.py, its results are in eval/results/issue4_bakeoff_2610/, and the decision is in the tool's docs/decisions/backend-choice.md.

The vocabulary step is its own workflow on Pipelines — W7, vocabulary harvesting and review.

What you get

  • The same document in another language — <name>_<target language>.<extension>, every tag and namespace in place; for ALTO, every line where it was.
  • A review log — <name>_log.csv, with the source and the translated text side by side, and a status per line that points a reviewer at what was recovered, approximated or translated from a fallback language.
  • Consistent terminology — every protected term carries its agreed translation, and the paradata counts the protected terms per document.
  • A provenance record — the paradata log of the run, with each component's licence. A document record given with a file is handed back with nothing added.

The translator's output is an end product: no later stage reads it. In the AMČR pilot it is metadata-en, the English copy of a record's metadata, made by a record-level job when the record is archived and served under the same access rules as metadata. Until the terms of LINDAT's services are settled (atrium-project#78), AMČR does not publish outputs made through them: the linguistic layer, the entities, the TEITOK file and the English metadata.

Limits

  • Word positions in translated ALTO are approximate. Line boundaries are exact; how the words of a line are spread over its word elements is constructed, because a translation has a different number of words. From 2.0.2-beta (on test), a line that cannot be placed exactly fails the file (exit 3; 422), unless --fast-align asks for placement by word count.
  • Schema validation applies to metadata output. ALTO output keeps the structure of its input — and is valid ALTO in either mode — but is not validated by the tool. The command line takes a schema file or URL (--xsd); the service only a local file its deployment names (XSD_PATH), and answers xsd_valid. With --xsd-strict or xsd_strict, an invalid translation fails the document and nothing of it is kept.
  • The field list is checked first. An XPath that does not compile, or uses a prefix other than amcr: or oai:, is refused before anything is translated (exit 1; 422 invalid_xpaths).
  • A failed input fails the run. A URL that cannot be downloaded, or (from 2.0.2-beta) that AMČR answers with an OAI-PMH error, counts as a failed file (exit 3), and a vocabulary that cannot be read in full is refused, by the command line and when the service starts. From 2.0.2-beta, source_lang=auto without the language-identification model is refused before anything is translated (exit 1; 501).
  • Appended AMČR records are not valid AMČR. The AMČR schema allows neither a language label on the translated fields nor a second copy of them; a record that must validate is translated in replace mode.
  • Language coverage is the backend's. Into English, LINDAT translates from Czech, German, French, Polish, Russian and Ukrainian. A pair the backend has no model for is refused, not routed through Czech; other pairs need another backend.
  • Placeholders protect terms only for the LINDAT backend. Language-model backends get a glossary instead, and the self-hosted neural translation models receive no vocabulary.
  • EuroLLM on ct2 drops short segments. In the bake-off EuroLLM-9B ran on past the source in 96 of 1,230 segments, almost all a number or a single word. Such a segment fails the document.

Provenance and licence

Each run writes <run_id>-<8 hex>_translator.json, the paradata log; the service returns the same provenance, with the same keys, in its response instead of writing a file. The paradata lists the components the run actually used, each with its licence or terms, as declared in the tool's para_config.txt:

Component Licence Used when
language-identification model, FastText (fasttext) CC BY-NC 4.0 the source language is detected, not given
LINDAT translation, CUBBITT (lindat_cubbitt) CC BY-NC-SA 4.0 the default backend, lindat, is used
UDPipe 2 engine / models (udpipe2_engine, udpipe2_models) MPL 2.0 / CC BY-NC-SA 4.0 LINDAT applies a vocabulary (terms matched by lemma)
AMČR vocabularies, TEATER thesaurus (amcr_vocab, teater_data) CC0 a vocabulary is applied
OpenAI-compatible language-model API (llm_api) LLM provider ToS openai_compatible is used without LLM_LICENSE_COMPONENT
Qwen3.8-27B or -FP8, self-hosted (qwen3_8) Apache-2.0 openai_compatible with LLM_LICENSE_COMPONENT=qwen3_8
CTranslate2 engine (ctranslate2) MIT the ct2 backend is used
EuroLLM, MADLAD-400 (eurollm, madlad400) Apache-2.0 a ct2 model of these families
NLLB-200 (nllb200) CC BY-NC 4.0 a ct2 NLLB-200 model
Opus-MT (opus_mt) CC BY 4.0 a ct2 Opus-MT model

A hosted language-model API is recorded with its provider's terms of service (LLM provider ToS). Each run lists the components it used, each with its own licence or terms. No licence of an output is computed: the rights in an output follow the source document (Licences and paradata).

A run with only permissive components needs both: a self-hosted model under a permissive licence and the source language named explicitly. The recommended model is Qwen3.8-27B through openai_compatible, recorded with LLM_LICENSE_COMPONENT=qwen3_8; a ct2 model of the EuroLLM, MADLAD-400 or Opus-MT family also qualifies. The AMČR and TEATER vocabularies are CC0 and do not stand in its way. What a run lists is on Reference → Licence.

The tool writes nothing into the document record: a record sent with a file is handed back unchanged, and translations and entities[].translation_en stay reserved. The run is described by the paradata of metadata-en, which names metadata and metadata-en by SHA-512 and the field list used, with no field text.

Where it sits

  • A record-level job of the AMČR pilot. When a record is archived, its metadata is translated into metadata-en, with the field list AMČR sends; AMČR's pipeline adds the job type (ARUP-CAS/aiscr-docs-pipeline#13). It is not a stage of the document chain.
  • Automated translations step of the AMČR text workflow 0xSpVP, where it translates AMČR metadata records.
  • Also used in W4 (as a service), W5 (from a coding agent) and W7 (the vocabulary).
  • ALTO mode, which translates the full text of OCR pages, stays for research and batch use. It is not part of the pipeline, and the end-to-end test does not run it.

On other platforms

SSH Open Marketplace. Tool record CizIUW; workflow record 13eHAZ, to be rebuilt with the seven steps above. Related records: LINDAT Translation, UDPipe.

Galaxy sheet. The Galaxy wrappers were handed to DARIAH for testing; further Galaxy work is parked during the AMČR pilot. The sheet describes the wrapper as the hub's galaxy/ folder holds it, at 2.0.1-beta+galaxy0.

Workflow inputs a collection of documents — xml (ALTO pages included); for metadata mode, the list of fields — txt, and optionally an XML schema — xml; optionally the vocabulary — csv, and a document record — json
Parameters the kind of document (a metadata record, the default, or an ALTO page); the target language (English by default); the source language, or detection with a language to fall back on; replace or append; the vocabulary (the AMČR and TEATER one in the image, one's own, or none); for metadata, whether a result the schema rejects fails the job
Workflow outputs translated documents — xml; translation logs — csv; paradata — json; the document record — json, only when one was sent
Container ghcr.io/ufal/atrium-translator:<version> — the batch image (main.py), one document per job; it runs the job script Galaxy hands it. It carries the vocabulary (data_samples/vocabulary.csv) but no field list: the XPath list is an input of the job. It validates against a schema with --xsd; the service image ghcr.io/ufal/atrium-translator-api is not used. Neither image includes the ct2 dependencies
Galaxy tool atrium_translator 2.0.1-beta+galaxy0, LINDAT backend only, in the hub's galaxy/ folder with the workflows ATRIUM translation of XML records and ATRIUM scanned pages: classify, OCR, translate; for DARIAH's test Galaxy (https://galaxy.acdh-dev.oeaw.ac.at/galaxy/)
Compute CPU
Network the LINDAT translation and UDPipe services (the image carries the language-identification model) — or a self-hosted model
Credentials an API key only for a hosted language-model API (LLM_API_KEY; a local server may need none), passed through Galaxy's credentials mechanism
Test data the tool's test fixtures tests/fixtures/sample_amcr.xml and sample.alto.xml (in the wrapper's test-data/); data_samples/ in the tool repository — three invented AMČR-shaped records and a synthetic ALTO page, with their replace translations, logs and paradata
Credit the authors in the tool's CITATION.cff, with their ORCIDs; licence MIT
Closest Galaxy tools none translates; the language-model tools (llm_hub, chatgpt_openai_api) and the xpath tool are the nearest, and DARIAH's gate-cloud-client shows the pattern for a tool that calls a remote service

Sources

Read from ufal/atrium-translator at release v2.0.1-beta (tagged 2 December 2026), from its last pull request, on 2026-12-02; what is marked "from 2.0.2-beta" was read from its test of 3 December 2026 (the v2-beta-d13 pull request). Earlier readings were of test carrying release 2.0.0-beta (2026-11-21), at release v1.7.0-beta (2026-10-29), with this site's translator section, and at v1.6.1-beta (2026-10-28; the code of v1.6.0-beta, whose images were published without a release) and v1.5.0-beta (2026-10-19). The licence table follows the para_config.txt of that release. This table records provenance, not a build instruction. The field list, the record and the place in the pilot (2026-11-16) follow the translator's test branch and ARÚP's output contract of 12 November 2026. The Galaxy sheet (2026-12-02) follows 2.0.1-beta+galaxy0 and the hub's galaxy/ folder.

Source What was taken from it
README.md §§ Features, Usage (with Harvesting the Vocabulary and Output mode), Logic Overview, Source-language identification, ALTO Dual-Pass Reconstruction, Translation CSV Logs, Paradata JSON Logs, License & Citation purpose, the step order, the outputs, the permissive recipe
service/README.md §§ Request fields, Response, Errors, Configuration, Known limits; docs/usage.md § The command line and the service the service's vocabulary, provenance and 422 refusal; the limits
docs/translation-backends.md §§ Recommendation, The bake-off, The result the backend decision
main.py, utils.py (xml_kind), service/api.py; processors/backend.py, translator.py, llm_translator.py, ct2_translator.py, language.py, identifier.py, quality.py; load_vocab.py the steps, the backends, the language-pair check, vocabulary protection
para_config.txt the licence components
.env.example, Dockerfile, .dockerignore, requirements.txt, requirements-llm.txt the images, VOCABULARY_PATH, LLM_LICENSE_COMPONENT, LLM_API_KEY; no model weights inside
eval/bakeoff.py, eval/results/issue4_bakeoff_2610/bakeoff_summary.csv the bake-off and its result
data_samples/README.md, data_samples/vocabulary.csv test data; the shipped vocabulary
CITATION.cff credit, the release date
CONTRIBUTING.md (release rows v1.2.2-beta to v1.6.1-beta; Branches & Environments), .github/workflows/release.yml, docker.yml what changed since v1.2.1-beta; the release branch
the tool's docs/ (until 2026-10-25 a section of this site), docs_site/pipelines.md § W7 outputs, design limits, the vocabulary workflow
SSH Open Marketplace CizIUW, 13eHAZ record identifiers
usegalaxy-eu/usegalaxy-eu-tools; bgruening/galaxytools; DARIAH-ERIC/atrium-galaxy-tools the Galaxy analogues and conventions