Skip to content

Commit 6934454

Browse files
committed
Use <source> tags in translation prompt to prevent copying source language
Made-with: Cursor
1 parent be4dbf8 commit 6934454

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/LiveLingo.Core/Engines/LlamaTranslationEngine.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ public async Task<string> TranslateAsync(
4949
var endpoint = await _host.GetOrStartServerAsync(ct);
5050
var url = $"{endpoint}/completion";
5151

52-
var systemPrompt = $"You are an expert translation engine. Translate the text from {srcName} to {tgtName}.\nRules:\n1. Output ONLY the translated text in {tgtName}.\n2. Do NOT repeat or output the original {srcName} text.\n3. Do NOT add any explanations, notes, or conversational text.\n4. Do NOT use <think> tags or output any thought process.";
53-
var prompt = $"<|im_start|>system\n{systemPrompt}<|im_end|>\n<|im_start|>user\nTranslate this to {tgtName}:\n\n{text}<|im_end|>\n<|im_start|>assistant\n";
52+
var systemPrompt = $"You are an expert translation engine. Your task is to translate the source text from {srcName} to {tgtName}.\n\nRules:\n1. Output ONLY the final {tgtName} translation.\n2. Do NOT output any {srcName} text.\n3. Do NOT output any explanations, conversational text, or notes.\n4. Do NOT use <think> tags or output any thought process.";
53+
var prompt = $"<|im_start|>system\n{systemPrompt}<|im_end|>\n<|im_start|>user\nTranslate the following {srcName} text to {tgtName}:\n\n<source>\n{text}\n</source><|im_end|>\n<|im_start|>assistant\n";
5454

5555
_logger.LogDebug("Translation prompt for {Src}→{Tgt}: {Prompt}", sourceLanguage, targetLanguage, prompt);
5656

0 commit comments

Comments
 (0)