improve eval prompt

This commit is contained in:
Julian Freeman
2026-02-25 12:14:33 -04:00
parent 8294c12d17
commit f20a9bb851
2 changed files with 9 additions and 13 deletions

View File

@@ -239,20 +239,20 @@ const evaluateTranslation = async () => {
}
}
const evaluationPrompt = settings.evaluationPromptTemplate
const evaluationSystemPrompt = settings.evaluationPromptTemplate
.replace(/{SOURCE_LANG}/g, sourceLang.value.englishName)
.replace(/{TARGET_LANG}/g, targetLang.value.englishName)
.replace(/{SPEAKER_IDENTITY}/g, settings.speakerIdentity)
.replace(/{TONE_REGISTER}/g, settings.toneRegister)
.replace(/{CONTEXT}/g, context.value || 'None')
.replace(/{SOURCE_TEXT}/g, sourceText.value)
.replace(/{TRANSLATED_TEXT}/g, targetText.value);
.replace(/{CONTEXT}/g, context.value || 'None');
const evaluationUserPrompt = `[Source Text]\n${sourceText.value}\n\n[Translated Text]\n${targetText.value}`;
const requestBody = {
model: modelName,
messages: [
{ role: "system", content: "You are a professional translation auditor. You must respond in valid JSON format." },
{ role: "user", content: evaluationPrompt }
{ role: "system", content: evaluationSystemPrompt },
{ role: "user", content: evaluationUserPrompt }
],
stream: false // Non-streaming for evaluation to parse JSON
};
@@ -881,7 +881,7 @@ const translate = async () => {
<div class="bg-slate-200/20 dark:bg-slate-900 rounded-xl shadow-sm/5 border dark:border-slate-800 p-6 space-y-6">
<div class="space-y-2">
<div class="flex items-center justify-between">
<label class="text-sm font-medium text-slate-700 dark:text-slate-300">系统提示词模板 (翻译)</label>
<label class="text-sm font-medium text-slate-700 dark:text-slate-300">翻译系统提示词模板</label>
<button @click="settings.systemPromptTemplate = DEFAULT_TEMPLATE" class="text-xs text-blue-600 dark:text-blue-400 hover:underline">恢复默认值</button>
</div>
<textarea
@@ -896,7 +896,7 @@ const translate = async () => {
<div class="space-y-2 border-t dark:border-slate-800 pt-6">
<div class="flex items-center justify-between">
<label class="text-sm font-medium text-slate-700 dark:text-slate-300">审计提示词模板 (评估)</label>
<label class="text-sm font-medium text-slate-700 dark:text-slate-300">审计系统提示词模板</label>
<button @click="settings.evaluationPromptTemplate = DEFAULT_EVALUATION_TEMPLATE" class="text-xs text-blue-600 dark:text-blue-400 hover:underline">恢复默认值</button>
</div>
<textarea
@@ -905,7 +905,7 @@ const translate = async () => {
class="w-full px-4 py-3 border dark:border-slate-700 rounded-lg bg-transparent focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500 outline-none transition-all font-mono text-xs leading-relaxed text-slate-900 dark:text-slate-100"
></textarea>
<div class="flex flex-wrap gap-2 mt-2">
<span v-for="tag in ['{SOURCE_LANG}', '{TARGET_LANG}', '{SPEAKER_IDENTITY}', '{TONE_REGISTER}', '{CONTEXT}', '{SOURCE_TEXT}', '{TRANSLATED_TEXT}']" :key="tag" class="px-2 py-1 bg-slate-100 dark:bg-slate-800 text-[10px] font-mono rounded border dark:border-slate-700 text-slate-600 dark:text-slate-400">{{ tag }}</span>
<span v-for="tag in ['{SOURCE_LANG}', '{TARGET_LANG}', '{SPEAKER_IDENTITY}', '{TONE_REGISTER}', '{CONTEXT}']" :key="tag" class="px-2 py-1 bg-slate-100 dark:bg-slate-800 text-[10px] font-mono rounded border dark:border-slate-700 text-slate-600 dark:text-slate-400">{{ tag }}</span>
</div>
</div>

View File

@@ -61,10 +61,6 @@ You are an **Objective Translation Auditor**. Your task is to evaluate translati
- **Intended Tone/Register**: {TONE_REGISTER}
- **Context**: {CONTEXT}
# Input
- **Source Text**: {SOURCE_TEXT}
- **Translated Text**: {TRANSLATED_TEXT}
# Audit Criteria
Only penalize and provide improvements if the translation meets one of these criteria:
1. **Semantic Error**: Objective misalignment with the source meaning or complete hallucinations.