FEAT: Improve TranslationConverter prompt for faithful translation#2082
Open
romanlutz wants to merge 2 commits into
Open
FEAT: Improve TranslationConverter prompt for faithful translation#2082romanlutz wants to merge 2 commits into
romanlutz wants to merge 2 commits into
Conversation
Enhance the LLM-based TranslationConverter to produce more faithful translations by: - Adding explicit role as a literal word-for-word translation engine - Adding critical rules for preserving code blocks, URLs, special chars - Adding rules against paraphrasing and synonym substitution - Adding examples for code preservation and structural markers - Changing markers to [TRANSLATE_START]/[TRANSLATE_END] for clarity - Fixing parameter name from 'languages' to 'language' (singular) Testing on 15 diverse prompts with round-trip translation (EN→DE→EN) shows improvement from 0.900 to 0.948 average similarity (+5.3%), with particular gains in code preservation and structural fidelity. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The PR changed the user prompt markers from '=== begin ==='/ '=== end ===' to '[TRANSLATE_START]'/'[TRANSLATE_END]', but the byte-for-byte regression test still asserted the old format. Update the expected string to match the new template and remove the now-unused dedent import. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Description
The LLM-based TranslationConverter sometimes paraphrases content, uses synonyms, or fails to preserve code blocks and special formatting during translation. This is problematic for AI safety research where preserving exact prompt structure is critical.
This PR enhances the TranslationConverter system prompt to produce more faithful, literal translations by:
Testing results: Evaluation on 15 diverse test cases with round-trip translation (EN -> German -> EN) shows average similarity improved from 0.900 to 0.948 (+5.3%), with the improved version winning on 5 tests, the original on 2, and ties on 8. The biggest gains were in code preservation and structural fidelity.
Tests and Documentation