${method.name}
${method.desc}
@@ -455,27 +488,36 @@
`).join('');
- // 绑定评估方式radio点击事件
- container.querySelectorAll('.radio-option').forEach(option => {
- option.addEventListener('click', function() {
- selectEvalMethod(this);
- // 更新默认 Prompt
- const method = this.dataset.method;
- const promptEditor = document.getElementById('evalPromptEditor');
- if (promptEditor && EVAL_METHOD_PROMPTS.hasOwnProperty(method)) {
- promptEditor.innerText = EVAL_METHOD_PROMPTS[method];
- updateMarkdownHighlight();
- syncEditorContent();
+ // 绑定评估方式checkbox点击事件
+ container.querySelectorAll('.checkbox-option').forEach(option => {
+ option.addEventListener('click', function(e) {
+ const checkbox = this.querySelector('input[type="checkbox"]');
+ // 不手动切换状态,让浏览器自动处理,只更新样式
+ this.classList.toggle('selected', checkbox.checked);
+ // 更新默认 Prompt(仅大模型评估需要)
+ if (!isTextSimilarity) {
+ const selectedCheckbox = this.querySelector('input[type="checkbox"]:checked');
+ if (selectedCheckbox) {
+ const method = selectedCheckbox.value;
+ const promptEditor = document.getElementById('evalPromptEditor');
+ if (promptEditor && EVAL_METHOD_PROMPTS.hasOwnProperty(method)) {
+ promptEditor.innerText = EVAL_METHOD_PROMPTS[method];
+ updateMarkdownHighlight();
+ syncEditorContent();
+ }
+ }
}
});
});
- // 初始化默认 Prompt
- const promptEditor = document.getElementById('evalPromptEditor');
- if (promptEditor && EVAL_METHOD_PROMPTS.hasOwnProperty(firstMethod)) {
- promptEditor.innerText = EVAL_METHOD_PROMPTS[firstMethod];
- updateMarkdownHighlight();
- syncEditorContent();
+ // 初始化默认 Prompt(仅大模型评估需要)
+ if (!isTextSimilarity) {
+ const promptEditor = document.getElementById('evalPromptEditor');
+ if (promptEditor && EVAL_METHOD_PROMPTS.hasOwnProperty(firstMethod)) {
+ promptEditor.innerText = EVAL_METHOD_PROMPTS[firstMethod];
+ updateMarkdownHighlight();
+ syncEditorContent();
+ }
}
}
@@ -484,10 +526,32 @@
const type = document.getElementById('dimensionType').value;
const configSection = document.getElementById('evalConfigSection');
const scoreSection = document.getElementById('scoreConfigSection');
+ const evalModelSection = document.getElementById('evalModelSection');
+ const evalPromptSection = document.getElementById('evalPromptSection');
+
if (type === 'classification' || type === 'metric') {
configSection.style.display = 'block';
// 指标型才显示评分范围和通过阈值
scoreSection.style.display = (type === 'metric') ? 'block' : 'none';
+ // 显示评估模型和 Prompt
+ if (evalModelSection) evalModelSection.style.display = 'block';
+ if (evalPromptSection) evalPromptSection.style.display = 'block';
+ // 隐藏规则评估特有配置
+ const textSimConfig = document.getElementById('textSimilarityConfig');
+ if (textSimConfig) textSimConfig.style.display = 'none';
+ // 动态渲染评估方式
+ renderEvalMethods(type);
+ } else if (type === 'text_similarity') {
+ configSection.style.display = 'block';
+ // 规则评估不显示评分范围配置
+ scoreSection.style.display = 'none';
+ // 隐藏评估模型选择(规则评估不需要大模型)
+ if (evalModelSection) evalModelSection.style.display = 'none';
+ // 隐藏评估 Prompt(规则评估不需要 Prompt)
+ if (evalPromptSection) evalPromptSection.style.display = 'none';
+ // 显示规则评估特有配置
+ const textSimConfig = document.getElementById('textSimilarityConfig');
+ if (textSimConfig) textSimConfig.style.display = 'block';
// 动态渲染评估方式
renderEvalMethods(type);
} else {
@@ -495,19 +559,10 @@
}
}
- // 选择评估方式
- function selectEvalMethod(element) {
- document.querySelectorAll('.radio-option').forEach(opt => {
- opt.classList.remove('selected');
- });
- element.classList.add('selected');
- element.querySelector('input').checked = true;
- }
-
// 恢复默认评估 Prompt
function resetEvalPrompt() {
const promptEditor = document.getElementById('evalPromptEditor');
- const selectedMethod = document.querySelector('.radio-option.selected input[name="eval_method"]');
+ const selectedMethod = document.querySelector('.checkbox-option.selected input[name="eval_method"]:checked, .radio-option.selected input[name="eval_method"]:checked');
const method = selectedMethod ? selectedMethod.value : 'standard';
if (promptEditor && EVAL_METHOD_PROMPTS.hasOwnProperty(method)) {
promptEditor.innerText = EVAL_METHOD_PROMPTS[method];
@@ -869,6 +924,13 @@
{ value: 'metric_standard', name: '综合评测', desc: '根据预设标准评分' },
{ value: 'semantic', name: '语义相似度', desc: '计算语义相似程度' },
{ value: 'custom', name: '自定义评分器', desc: '自定义评估规则' }
+ ],
+ text_similarity: [
+ { value: 'bleu_4', name: 'BLEU-4', desc: 'N-gram 精确度评估' },
+ { value: 'cosine', name: 'Cosine', desc: '余弦相似度' },
+ { value: 'rouge_1', name: 'ROUGE-1', desc: 'unigram 重叠评估' },
+ { value: 'rouge_2', name: 'ROUGE-2', desc: 'bigram 重叠评估' },
+ { value: 'rouge_4', name: 'ROUGE-4', desc: '4-gram 重叠评估' }
]
};
@@ -1038,20 +1100,45 @@
alert('请输入评估 Prompt');
return;
}
+ if (!evalMethod) {
+ alert('请选择评估方式');
+ return;
+ }
+ } else if (type === 'text_similarity') {
+ // 规则评估:获取所有选中的评估方式
+ const checkedMethods = Array.from(document.querySelectorAll('input[name="eval_method"]:checked')).map(cb => cb.value);
+ if (checkedMethods.length === 0) {
+ alert('请至少选择一个评估方式');
+ return;
+ }
+ }
+
+ // 获取评估方式(支持多选)
+ let evalMethod;
+ if (type === 'text_similarity') {
+ evalMethod = Array.from(document.querySelectorAll('input[name="eval_method"]:checked')).map(cb => cb.value);
+ } else {
+ evalMethod = formData.get('eval_method');
}
const data = {
name: name,
type: type,
description: formData.get('description').trim(),
- eval_model: formData.get('eval_model'),
- eval_method: formData.get('eval_method'),
- eval_prompt: formData.get('eval_prompt').trim(),
+ eval_model: type === 'text_similarity' ? null : formData.get('eval_model'),
+ eval_method: evalMethod,
+ eval_prompt: type === 'text_similarity' ? null : formData.get('eval_prompt').trim(),
is_active: formData.get('is_active') === 'on',
is_default: formData.get('is_default') === 'on',
create_time: new Date().toLocaleString('zh-CN', { hour12: false }).replace(/\//g, '-')
};
+ // 规则评估特有配置
+ if (type === 'text_similarity') {
+ data.bleu_n = formData.get('bleu_n');
+ data.output_precision = parseInt(formData.get('output_precision') || '3');
+ }
+
// 指标型添加评分范围和通过阈值
if (type === 'metric') {
data.score_min = parseFloat(formData.get('score_min')) || 0;