Repository navigation
Add Hugging Face Opus MT translation converters for datasets and documents - #930
Merged
Merged
Conversation
cristian-tamblay
force-pushed
the
feat/translation-converters
branch
from
October 21, 2026 16:15
6637144 to
ac98521
Compare
cristian-tamblay
force-pushed
the
feat/translation-converters
branch
from
October 21, 2026 17:00
ac98521 to
4885c0e
Compare
cristian-tamblay
approved these changes
Oct 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds translation converters that wrap pretrained Opus MT models from Hugging Face, one converter per model. Each converter has its own download and works on Text columns of datasets and on Text items of documents. Table items are translated cell by cell.
Each converter has an optional Translate by parameter, so a document item that holds a lot of text (for example a whole file loaded as a single item) can be translated in parts:
Line breaks, spacing and lines without letters (such as
-----underlines) are kept exactly as they were. Values that are missing, empty or have no letters never reach the model.In every mode, a part longer than 128 tokens is cut further: first by lines, then by sentences (each translated on its own), and a single sentence that is still too long is cut between words. Without this, Opus MT silently skipped sentences of long inputs while testing (about 250 tokens).
Type of Change
Check all that apply like this [x]:
Changes (by file)
DashAI/back/converters/hugging_face/translation/base.py:TranslationConverterbase. It loads the tokenizer and model on first use, has thesplit_by,batch_sizeanddeviceoptions, and does the splitting, batching (by length, to reduce padding) and reassembly. Generated length is capped relative to the input so a degenerate output cannot run away. Subclasses can overridesource_prefix,prepare_tokenizerandgenerate_optionsfor models that need language tokens.DashAI/back/converters/hugging_face/translation/opus_mt.py: the 10 Opus MT converters:.binweights, the repo also ships safetensors)The last two put the model's
>>id<<target token in front of every input. Display names and descriptions are translated to all UI languages.DashAI/back/converters/hugging_face/translation/__init__.py: exports the converters andTRANSLATION_CONVERTERS.DashAI/back/initial_components.py: registersTRANSLATION_CONVERTERS.tests/back/converters/test_translation_converters.py: tests for the splitting modes, exact reassembly in every mode, the fallback cuts, missing and letterless values, documents (including a table item), target tokens and download metadata.tests/back/test_component_metadata_contract.py: adds the translators to the list of tools offered on documents.tests/back/preprocessing/test_structure_matches_runtime.py: adds the translators to the converters that need a download.Testing (optional)
Notes (optional)