From 373f5244e5ad018b6d434b214f2be386c1db3ae1 Mon Sep 17 00:00:00 2001 From: leokaka1 Date: Mon, 19 Jan 2026 14:31:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86lora=E5=BE=AE?= =?UTF-8?q?=E8=B0=83=E5=92=8C=E5=85=A8=E5=8F=82=E5=BE=AE=E8=B0=83=E7=9A=84?= =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/pages/dataset-create.html | 22 +- web/pages/fine-tune-create.html | 352 ++++++++++++++++++++++++++--- web/pages/model-manage-create.html | 22 +- 3 files changed, 363 insertions(+), 33 deletions(-) diff --git a/web/pages/dataset-create.html b/web/pages/dataset-create.html index 88a9f22..216e824 100644 --- a/web/pages/dataset-create.html +++ b/web/pages/dataset-create.html @@ -136,7 +136,7 @@
- + 上一步 @@ -159,7 +159,7 @@
- 数据集管理 + 数据集管理 / 上传数据集
@@ -289,8 +289,21 @@ }; const API_BASE = getApiBase(); + // 返回页面 + let backUrl = 'main.html?page=dataset-manage'; + // 页面加载完成后初始化 document.addEventListener('DOMContentLoaded', function() { + // 根据URL参数设置返回页面 + const urlParams = new URLSearchParams(window.location.search); + const from = urlParams.get('from'); + const breadcrumbParent = document.getElementById('breadcrumbParent'); + if (from === 'fine-tune') { + backUrl = 'fine-tune-create.html'; + if (breadcrumbParent) { + breadcrumbParent.textContent = '创建训练任务'; + } + } // 文件上传区域拖拽逻辑 const uploadArea = document.getElementById('upload-area'); const fileUpload = document.getElementById('file-upload'); @@ -417,6 +430,11 @@ alert('创建失败: ' + error.message); } } + + // 返回上一页 + function goBack() { + window.location.href = backUrl; + } diff --git a/web/pages/fine-tune-create.html b/web/pages/fine-tune-create.html index c24fb68..2d59d15 100644 --- a/web/pages/fine-tune-create.html +++ b/web/pages/fine-tune-create.html @@ -224,25 +224,16 @@
-
- - -
-
- + + +
@@ -250,26 +241,230 @@
-
+ + +
+
+
+
+ + +
+
+ + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
参数名称参数值取值范围参数说明
+ batch_size + * + + + + [1, 64] + 单步训练样本数量,数值越大训练速度越快,但显存占用越高
+ learning_rate + * + + + + [0.000001, 1] + 模型参数更新步长,过大可能导致训练不稳定,过小收敛速度慢
+ n_epochs + * + + + + [1, 100] + 完整遍历训练数据集的次数,建议设置在1-10之间
+ eval_steps + * + + + + [10, 10000] + 每训练多少步进行一次模型评估,建议设置为100的倍数
+ lr_scheduler_type + + + + 3种可选 + 学习率变化策略,cosine为余弦退火,linear为线性下降,constant为保持不变
+ max_length + * + + + + [64, 4096] + 单条训练数据的最大token数,超出部分将被截断
+ warmup_ratio + + + + [0, 1] + 学习率预热步数占总步数的比例,设置为0则不预热
+ weight_decay + + + + [0, 1] + 防止过拟合的正则化技术,值越大对模型参数约束越强
+
+
+

数据配置

+
- -
- + +
+ + +
@@ -292,8 +487,16 @@ % 作为验证集
@@ -380,6 +583,12 @@ // 加载数据集列表 loadDatasets(); + // 加载模型列表 + loadModels(); + + // 初始化训练方法参数显示 + toggleTrainMethod(); + // 绑定导航点击事件 document.querySelectorAll('.nav-link').forEach(link => { link.addEventListener('click', function(e) { @@ -405,6 +614,64 @@ } } + // 切换训练方法 - 显示/隐藏LoRA参数 + function toggleTrainMethod() { + const trainMethod = document.querySelector('input[name="train_method"]:checked').value; + const loraParamsBody = document.getElementById('loraParamsBody'); + if (trainMethod === 'lora') { + loraParamsBody.classList.remove('hidden'); + } else { + loraParamsBody.classList.add('hidden'); + } + } + + // 切换参数配置展开/收起 + function toggleParamsCollapse() { + const content = document.getElementById('paramsContent'); + const toggleText = document.getElementById('paramsToggleText'); + const toggleIcon = document.getElementById('paramsToggleIcon'); + + if (content.classList.contains('hidden')) { + content.classList.remove('hidden'); + toggleText.textContent = '收起'; + toggleIcon.className = 'fa fa-chevron-up ml-1 text-xs'; + } else { + content.classList.add('hidden'); + toggleText.textContent = '展开'; + toggleIcon.className = 'fa fa-chevron-down ml-1 text-xs'; + } + } + + // 重置参数为默认值 + function resetParams() { + const defaults = { + 'batch_size': 1, + 'learning_rate': 0.0001, + 'n_epochs': 1, + 'eval_steps': 100, + 'lr_scheduler_type': 'cosine', + 'max_length': 512, + 'warmup_ratio': 0.05, + 'weight_decay': 0.01, + 'lora_alpha': '32', + 'lora_dropout': 0.1, + 'lora_rank': '8' + }; + + for (const [name, value] of Object.entries(defaults)) { + const input = document.querySelector(`input[name="${name}"]`); + if (input) { + if (input.type === 'number') { + input.value = value; + } else if (input.type === 'select-one') { + input.value = value; + } + } + const select = document.querySelector(`select[name="${name}"]`); + if (select) select.value = value; + } + } + // 渲染数据集单选列表 function renderDatasetRadio(datasets, containerId, name, selectedId) { const container = document.getElementById(containerId); @@ -426,14 +693,41 @@ const response = await fetch(`${API_BASE}/dataset-manage`); const result = await response.json(); if (result.code === 0) { - renderDatasetRadio(result.data, 'trainDatasetList', 'train_dataset_id', null); - renderDatasetRadio(result.data, 'validDatasetList', 'valid_dataset_id', null); + // 更新训练集下拉框 + const trainSelect = document.getElementById('trainDatasetSelect'); + if (trainSelect) { + trainSelect.innerHTML = '' + + result.data.map(d => ``).join(''); + } + // 更新验证集下拉框 + const validSelect = document.getElementById('validDatasetSelect'); + if (validSelect) { + validSelect.innerHTML = '' + + result.data.map(d => ``).join(''); + } } } catch (e) { console.error('加载数据集失败:', e); } } + // 加载模型列表 + async function loadModels() { + try { + const response = await fetch(`${API_BASE}/model-manage`); + const result = await response.json(); + if (result.code === 0) { + const modelSelect = document.getElementById('baseModelSelect'); + if (modelSelect) { + modelSelect.innerHTML = '' + + result.data.map(m => ``).join(''); + } + } + } catch (e) { + console.error('加载模型失败:', e); + } + } + // 提交表单 async function submitForm() { const form = document.getElementById('createForm'); diff --git a/web/pages/model-manage-create.html b/web/pages/model-manage-create.html index 8ca4db5..4e8a879 100644 --- a/web/pages/model-manage-create.html +++ b/web/pages/model-manage-create.html @@ -129,7 +129,7 @@
- + 上一步 @@ -152,7 +152,7 @@
- 资源管理 + 模型管理 / 添加模型
@@ -288,8 +288,21 @@ }; const API_BASE = getApiBase(); + // 返回页面 + let backUrl = 'main.html?page=model-manage'; + // 页面加载完成后初始化 document.addEventListener('DOMContentLoaded', function() { + // 根据URL参数设置返回页面 + const urlParams = new URLSearchParams(window.location.search); + const from = urlParams.get('from'); + const breadcrumbParent = document.getElementById('breadcrumbParent'); + if (from === 'fine-tune') { + backUrl = 'fine-tune-create.html'; + if (breadcrumbParent) { + breadcrumbParent.textContent = '创建训练任务'; + } + } // 描述字数统计 const descInput = document.querySelector('textarea[name="description"]'); if (descInput) { @@ -430,6 +443,11 @@ if (onConfirm) onConfirm(); }; } + + // 返回上一页 + function goBack() { + window.location.href = backUrl; + }