Problem
Yandex translates web pages in its browser and in translated search. A page is cut into fragments of text or text with HTML tags. A stock LLM translator hallucinates on tags, which were rare in its training data. It drops tags, translates tag names, or invents tags and attributes, and after the first slip often invents text too. One broken tag means the page does not render, so the translation is unusable. At the start, only 36.5% of tags survived.
Example from the article: in an old translation of Wikipedia pages, tags were restored in the wrong places. Plain text became links or bold, and real links became plain text.
Solution in brief
Replace HTML tags with paired brackets, so each tag is one token, and train SFT on parallel HTML. Then rebuild the alignment data with synthetic tags placed by two models, plus augmentations for forgotten and extra tags, so alignment keeps the SFT gain. Tag Accuracy reaches 99% with BLEURT almost unchanged.
Questions this case answers
- How to keep embedded markup intact when an LLM translates structured text, by replacing markup with a notation that costs few tokens
- How to stop a final preference-alignment stage from undoing structure learned in earlier fine-tuning of a generative model
- How to make an LLM translator keep HTML tags intact
- How to stop alignment (preference tuning) from destroying structure that SFT taught the model
Tools and methods
- Bracket tag representation — tags as
{ }/[ ], one token per tag - SFT on parallel HTML — corpus of aligned fragments with markup
- CPO alignment — triplets of source, good and bad translation
- Tag-insertion and tag-transfer models — add natural-looking tags to the alignment corpus
- Augmentations for tag errors — delete paired tags from originals, positives or negatives
- BLEURT, Tag Accuracy, side-by-side and pointwise assessments — quality checks
Google or a one-time email code. No password.
