From 5bef3f08ababcbec3b7a37f40615478ea2303ff0 Mon Sep 17 00:00:00 2001 From: yuyu5333 <1812107659@qq.com> Date: Fri, 7 Nov 2025 05:13:13 +0000 Subject: [PATCH] add: rl-dpo --- scripts/static/js/script.js | 109 +++++++++++++++++++++++++++++++++++ scripts/templates/index.html | 16 ++++- scripts/train_web_ui.py | 22 +++++-- 3 files changed, 140 insertions(+), 7 deletions(-) diff --git a/scripts/static/js/script.js b/scripts/static/js/script.js index 1502419..ea9bcd7 100644 --- a/scripts/static/js/script.js +++ b/scripts/static/js/script.js @@ -12,6 +12,14 @@ function openTab(evt, tabName) { document.getElementById(tabName).classList.remove("hidden"); evt.currentTarget.classList.add("active"); + // 当切换到其他标签页时,清除所有日志自动更新定时器 + if (tabName !== 'processes') { + for (let processId in logTimers) { + clearInterval(logTimers[processId]); + delete logTimers[processId]; + } + } + // 如果切换到进程页面,刷新进程列表 if (tabName === 'processes') { loadProcesses(); @@ -25,6 +33,8 @@ document.getElementById('train_type').addEventListener('change', function() { const trainType = this.value; const pretrainSftFields = document.querySelectorAll('.pretrain-sft'); const loraFields = document.querySelectorAll('.lora'); + const dpoFields = document.querySelectorAll('.dpo'); + const dpoParamCard = document.querySelector('.parameter-card.dpo'); pretrainSftFields.forEach(field => { field.style.display = (trainType === 'pretrain' || trainType === 'sft') ? 'block' : 'none'; @@ -34,6 +44,14 @@ document.getElementById('train_type').addEventListener('change', function() { field.style.display = trainType === 'lora' ? 'block' : 'none'; }); + dpoFields.forEach(field => { + field.style.display = trainType === 'dpo' ? 'block' : 'none'; + }); + + if (dpoParamCard) { + dpoParamCard.style.display = trainType === 'dpo' ? 'block' : 'none'; + } + // 设置默认值 if (trainType === 'pretrain') { document.getElementById('save_dir').value = '../out'; @@ -65,6 +83,17 @@ document.getElementById('train_type').addEventListener('change', function() { document.getElementById('from_weight').value = 'full_sft'; document.getElementById('log_interval').value = '10'; document.getElementById('save_interval').value = '1'; + } else if (trainType === 'dpo') { + document.getElementById('save_dir').value = '../out'; + document.getElementById('save_weight').value = 'dpo'; + document.getElementById('epochs').value = '1'; + document.getElementById('batch_size').value = '4'; + document.getElementById('learning_rate').value = '4e-8'; + document.getElementById('data_path').value = '../dataset/dpo.jsonl'; + document.getElementById('from_weight').value = 'full_sft'; + document.getElementById('log_interval').value = '100'; + document.getElementById('save_interval').value = '100'; + document.getElementById('beta').value = '0.1'; } }); @@ -100,6 +129,10 @@ function loadProcesses() { statusClass = 'status-completed'; } + // 设置进程数据属性,用于后续检查状态 + processItem.dataset.processId = process.id; + processItem.dataset.processStatus = process.status; + processItem.innerHTML = `