231 lines
15 KiB
TypeScript
231 lines
15 KiB
TypeScript
|
|
/**
|
||
|
|
* 全量 Mock 数据
|
||
|
|
* 为前端开发提供不依赖后端的模拟数据
|
||
|
|
*/
|
||
|
|
|
||
|
|
import type {
|
||
|
|
FineTuneTask,
|
||
|
|
ModelItem,
|
||
|
|
TrainedModel,
|
||
|
|
DatasetItem,
|
||
|
|
CompareTask,
|
||
|
|
EvalTask,
|
||
|
|
Dimension,
|
||
|
|
SystemInfo,
|
||
|
|
HealthMetrics,
|
||
|
|
LogFile,
|
||
|
|
TrainingLogFile,
|
||
|
|
LogContent,
|
||
|
|
} from '@/types'
|
||
|
|
|
||
|
|
// ============ 认证 ============
|
||
|
|
export const mockLoginOk = { code: 0, message: 'ok', data: { token: 'mock-token' } }
|
||
|
|
|
||
|
|
// ============ 系统监控 ============
|
||
|
|
export const mockHealth: HealthMetrics = {
|
||
|
|
cpu_percent: 32,
|
||
|
|
memory_percent: 58,
|
||
|
|
disk_percent: 45,
|
||
|
|
}
|
||
|
|
|
||
|
|
export const mockSystemInfo: SystemInfo = {
|
||
|
|
cpu: {
|
||
|
|
percent: 32,
|
||
|
|
cores: 8,
|
||
|
|
percents: [25, 38, 42, 30, 28, 36, 40, 18],
|
||
|
|
},
|
||
|
|
memory: {
|
||
|
|
used_gb: 9.2,
|
||
|
|
total_gb: 16,
|
||
|
|
percent: 58,
|
||
|
|
available_gb: 6.8,
|
||
|
|
cached_gb: 2.3,
|
||
|
|
},
|
||
|
|
disk: {
|
||
|
|
used_gb: 230,
|
||
|
|
total_gb: 512,
|
||
|
|
percent: 45,
|
||
|
|
},
|
||
|
|
gpu: [
|
||
|
|
{ name: 'NVIDIA A800', gpu_percent: 0, memory_used_gb: 0.0, memory_total_gb: 80, temperature: 32, power_w: 38, fan_speed: 0, clock_mhz: 1410, driver_version: '535.86.10' },
|
||
|
|
{ name: 'NVIDIA A800', gpu_percent: 28, memory_used_gb: 22.5, memory_total_gb: 80, temperature: 52, power_w: 165, fan_speed: 32, clock_mhz: 1410, driver_version: '535.86.10' },
|
||
|
|
{ name: 'NVIDIA A800', gpu_percent: 73, memory_used_gb: 58.7, memory_total_gb: 80, temperature: 68, power_w: 320, fan_speed: 58, clock_mhz: 1410, driver_version: '535.86.10' },
|
||
|
|
{ name: 'NVIDIA A800', gpu_percent: 0, memory_used_gb: 0.0, memory_total_gb: 80, temperature: 34, power_w: 42, fan_speed: 0, clock_mhz: 1410, driver_version: '535.86.10' },
|
||
|
|
{ name: 'NVIDIA A800', gpu_percent: 46, memory_used_gb: 36.8, memory_total_gb: 80, temperature: 60, power_w: 210, fan_speed: 42, clock_mhz: 1410, driver_version: '535.86.10' },
|
||
|
|
{ name: 'NVIDIA A800', gpu_percent: 0, memory_used_gb: 0.0, memory_total_gb: 80, temperature: 33, power_w: 40, fan_speed: 0, clock_mhz: 1410, driver_version: '535.86.10' },
|
||
|
|
{ name: 'NVIDIA A800', gpu_percent: 85, memory_used_gb: 68.2, memory_total_gb: 80, temperature: 73, power_w: 365, fan_speed: 62, clock_mhz: 1410, driver_version: '535.86.10' },
|
||
|
|
{ name: 'NVIDIA A800', gpu_percent: 15, memory_used_gb: 12.0, memory_total_gb: 80, temperature: 45, power_w: 95, fan_speed: 22, clock_mhz: 1410, driver_version: '535.86.10' },
|
||
|
|
],
|
||
|
|
network: {
|
||
|
|
download_mb: 1024,
|
||
|
|
upload_mb: 256,
|
||
|
|
},
|
||
|
|
system: {
|
||
|
|
uptime_seconds: 86400 * 3 + 3600 * 7 + 1800,
|
||
|
|
process_count: 256,
|
||
|
|
os: 'Ubuntu 22.04 LTS',
|
||
|
|
},
|
||
|
|
}
|
||
|
|
|
||
|
|
// ============ 模型管理 ============
|
||
|
|
export const mockModels: ModelItem[] = [
|
||
|
|
{ id: 1, name: 'Qwen2.5-7B-Instruct', type: 'LLM', purpose: 'training', model_source: 'local', description: 'Qwen2.5 7B 指令微调基座', path: '/data/models/qwen2.5-7b', create_time: '2025-12-10T08:30:00Z' },
|
||
|
|
{ id: 2, name: 'Qwen2.5-14B-Instruct', type: 'LLM', purpose: 'training', model_source: 'local', description: 'Qwen2.5 14B 指令微调基座', path: '/data/models/qwen2.5-14b', create_time: '2025-12-12T10:15:00Z' },
|
||
|
|
{ id: 3, name: 'Llama3-8B-Instruct', type: 'LLM', purpose: 'inference', model_source: 'local', description: 'Llama3 8B 推理模型', path: '/data/models/llama3-8b', create_time: '2025-12-15T14:20:00Z' },
|
||
|
|
{ id: 4, name: 'DeepSeek-V2-Lite', type: 'LLM', purpose: 'inference', model_source: 'local', description: 'DeepSeek V2 Lite', path: '/data/models/deepseek-v2-lite', create_time: '2026-01-05T09:00:00Z' },
|
||
|
|
{ id: 5, name: 'GPT-4o', type: 'LLM', purpose: 'evaluation', model_source: 'api', description: 'OpenAI GPT-4o 在线模型', api_url: 'https://api.openai.com/v1', api_key: 'sk-***', online_model_name: 'gpt-4o', create_time: '2026-01-08T11:30:00Z' },
|
||
|
|
{ id: 6, name: 'Claude-3.5-Sonnet', type: 'LLM', purpose: 'evaluation', model_source: 'api', description: 'Anthropic Claude 3.5 Sonnet', api_url: 'https://api.anthropic.com', api_key: 'sk-***', online_model_name: 'claude-3-5-sonnet-20241022', create_time: '2026-01-10T16:45:00Z' },
|
||
|
|
{ id: 7, name: 'BGE-large-zh', type: 'Embedding', purpose: 'inference', model_source: 'local', description: '中文 embedding 模型', path: '/data/models/bge-large-zh', create_time: '2026-01-12T13:00:00Z' },
|
||
|
|
]
|
||
|
|
|
||
|
|
export const mockTrainedModels: { models: TrainedModel[] } = {
|
||
|
|
models: [
|
||
|
|
{ id: 1, name: 'qwen-ft-finance-001', train_methods: [{ name: 'lora' }], base_model_path: '/data/models/qwen2.5-7b', merged: true, merging: false, merged_path: '/data/saves/qwen-ft-finance-001-merged', create_time: '2026-01-15T10:30:00Z' },
|
||
|
|
{ id: 2, name: 'qwen-ft-legal-002', train_methods: [{ name: 'lora' }], base_model_path: '/data/models/qwen2.5-7b', merged: false, merging: true, create_time: '2026-01-18T14:20:00Z' },
|
||
|
|
{ id: 3, name: 'llama3-ft-customer-service', train_methods: [{ name: 'qlora' }], base_model_path: '/data/models/llama3-8b', merged: true, merging: false, merged_path: '/data/saves/llama3-ft-customer-service-merged', create_time: '2026-01-22T09:45:00Z' },
|
||
|
|
{ id: 4, name: 'qwen-ft-medical-003', train_methods: [{ name: 'lora' }], base_model_path: '/data/models/qwen2.5-14b', merged: false, merging: false, create_time: '2026-02-01T16:10:00Z' },
|
||
|
|
],
|
||
|
|
}
|
||
|
|
|
||
|
|
export const mockLocalModels = {
|
||
|
|
models: [
|
||
|
|
{ path: '/data/models/qwen2.5-7b', name: 'Qwen2.5-7B-Instruct' },
|
||
|
|
{ path: '/data/models/qwen2.5-14b', name: 'Qwen2.5-14B-Instruct' },
|
||
|
|
{ path: '/data/models/llama3-8b', name: 'Llama3-8B-Instruct' },
|
||
|
|
{ path: '/data/models/deepseek-v2-lite', name: 'DeepSeek-V2-Lite' },
|
||
|
|
{ path: '/data/models/bge-large-zh', name: 'BGE-large-zh' },
|
||
|
|
],
|
||
|
|
}
|
||
|
|
|
||
|
|
// ============ 数据集 ============
|
||
|
|
export const mockDatasets: DatasetItem[] = [
|
||
|
|
{ id: 1, name: '金融问答-训练集', type: 'train', storage_type: 'local', size: '128 MB', count: 8560, description: '金融领域问答对', create_time: '2025-12-20T08:00:00Z' },
|
||
|
|
{ id: 2, name: '法律文书-训练集', type: 'train', storage_type: 'local', size: '256 MB', count: 15230, description: '法律文书数据集', create_time: '2025-12-25T10:30:00Z' },
|
||
|
|
{ id: 3, name: '客服对话-训练集', type: 'train', storage_type: 'minio', size: '512 MB', count: 24500, description: '客服对话记录', create_time: '2026-01-05T14:20:00Z' },
|
||
|
|
{ id: 4, name: '金融评测集', type: 'eval', storage_type: 'local', size: '32 MB', count: 1200, description: '金融领域评测', create_time: '2026-01-10T09:15:00Z' },
|
||
|
|
{ id: 5, name: '通用能力评测', type: 'eval', storage_type: 'local', size: '64 MB', count: 3500, description: '通用能力评测数据集', create_time: '2026-01-12T11:30:00Z' },
|
||
|
|
{ id: 6, name: '医疗问答-训练集', type: 'train', storage_type: 'local', size: '180 MB', count: 9800, description: '医疗问答对', create_time: '2026-02-01T15:00:00Z' },
|
||
|
|
]
|
||
|
|
|
||
|
|
// ============ 训练任务 ============
|
||
|
|
export const mockFineTuneList: FineTuneTask[] = [
|
||
|
|
{ id: 1, name: 'finance-sft-001', description: '金融领域 SFT 训练', status: 'completed', train_type: 'SFT', train_method: 'lora', template: 'qwen', base_model: 1, train_dataset_id: 1, gpus: [0], progress: 100, train_duration: '2小时18分钟', create_time: '2026-01-15T08:00:00Z' },
|
||
|
|
{ id: 2, name: 'legal-sft-002', description: '法律文书 SFT', status: 'completed', train_type: 'SFT', train_method: 'lora', template: 'qwen', base_model: 1, train_dataset_id: 2, gpus: [1], progress: 100, train_duration: '1小时46分钟', create_time: '2026-01-18T10:00:00Z' },
|
||
|
|
{ id: 3, name: 'medical-cpt-001', description: '医疗领域继续预训练', status: 'running', train_type: 'CPT', train_method: 'lora', template: 'qwen2_5', base_model: 2, train_dataset_id: 6, gpus: [0, 1], progress: 64, train_duration: '36分钟', create_time: '2026-02-05T09:00:00Z' },
|
||
|
|
{ id: 4, name: 'service-dpo-001', description: '客服对话偏好训练', status: 'pending', train_type: 'DPO', train_method: 'lora', template: 'qwen', base_model: 1, train_dataset_id: 3, gpus: [2], progress: 0, train_duration: '-', create_time: '2026-02-08T14:00:00Z' },
|
||
|
|
{ id: 5, name: 'finance-sft-002', description: '金融领域二轮微调', status: 'failed', train_type: 'SFT', train_method: 'lora', template: 'qwen', base_model: 1, train_dataset_id: 1, gpus: [3], progress: 32, train_duration: '18分钟', create_time: '2026-02-10T11:00:00Z' },
|
||
|
|
{ id: 6, name: 'general-sft-001', description: '通用能力微调', status: 'completed', train_type: 'SFT', train_method: 'full', template: 'llama3', base_model: 3, train_dataset_id: 3, gpus: [0, 2], progress: 100, train_duration: '3小时05分钟', create_time: '2026-02-12T13:00:00Z' },
|
||
|
|
]
|
||
|
|
|
||
|
|
// ============ 模型推理/对比 ============
|
||
|
|
export const mockCompareList: CompareTask[] = [
|
||
|
|
{
|
||
|
|
id: 1,
|
||
|
|
name: '金融问答对比',
|
||
|
|
model_name: '金融问答对比',
|
||
|
|
description: '对比基座模型与微调模型',
|
||
|
|
status: 'loaded',
|
||
|
|
models: JSON.stringify([
|
||
|
|
{ model_id: 1, model_name: 'Qwen2.5-7B-Instruct', model_path: '/data/models/qwen2.5-7b', gpu_id: 0, source: 'database', port: 18001 },
|
||
|
|
{ model_id: 101, model_name: 'qwen-ft-finance-001', model_path: '/data/saves/qwen-ft-finance-001-merged', gpu_id: 1, source: 'trained', port: 18002 },
|
||
|
|
]),
|
||
|
|
load_status: JSON.stringify({
|
||
|
|
loaded_models: [
|
||
|
|
{ model_id: 1, model_name: 'Qwen2.5-7B-Instruct', status: 'ready', pid: 12345, port: 18001 },
|
||
|
|
{ model_id: 101, model_name: 'qwen-ft-finance-001', status: 'ready', pid: 12346, port: 18002 },
|
||
|
|
],
|
||
|
|
}),
|
||
|
|
create_time: '2026-02-15T10:00:00Z',
|
||
|
|
},
|
||
|
|
{
|
||
|
|
id: 2,
|
||
|
|
name: '客服场景推理',
|
||
|
|
model_name: '客服场景推理',
|
||
|
|
description: '客服对话推理测试',
|
||
|
|
status: 'pending',
|
||
|
|
models: JSON.stringify([{ model_id: 3, model_name: 'Llama3-8B-Instruct', model_path: '/data/models/llama3-8b', gpu_id: 2, source: 'database' }]),
|
||
|
|
load_status: JSON.stringify({ loaded_models: [] }),
|
||
|
|
create_time: '2026-02-18T11:00:00Z',
|
||
|
|
},
|
||
|
|
{
|
||
|
|
id: 3,
|
||
|
|
name: '法律文书推理',
|
||
|
|
model_name: '法律文书推理',
|
||
|
|
description: '法律文书推理测试',
|
||
|
|
status: 'loaded',
|
||
|
|
models: JSON.stringify([{ model_id: 102, model_name: 'qwen-ft-legal-002', model_path: '/data/saves/qwen-ft-legal-002-merged', gpu_id: 3, source: 'trained' }]),
|
||
|
|
load_status: JSON.stringify({
|
||
|
|
loaded_models: [
|
||
|
|
{ model_id: 102, model_name: 'qwen-ft-legal-002', status: 'ready', pid: 12350, port: 18003 },
|
||
|
|
],
|
||
|
|
}),
|
||
|
|
create_time: '2026-02-20T14:00:00Z',
|
||
|
|
},
|
||
|
|
]
|
||
|
|
|
||
|
|
// ============ 模型评测 ============
|
||
|
|
export const mockEvalList: EvalTask[] = [
|
||
|
|
{ id: 1, eval_task_name: '金融模型评测-v1', model_name: 'qwen-ft-finance-001', dataset: '金融评测集', metric: 'accuracy', score: 87.5, status: 'completed', create_time: '2026-02-01T10:00:00Z' },
|
||
|
|
{ id: 2, eval_task_name: '客服模型评测-v1', model_name: 'llama3-ft-customer-service', dataset: '通用能力评测', metric: 'rouge-1', score: 0.82, status: 'completed', create_time: '2026-02-05T11:00:00Z' },
|
||
|
|
{ id: 3, eval_task_name: '基线对比评测', model_name: 'Qwen2.5-7B-Instruct', dataset: '金融评测集', metric: 'accuracy', score: 72.3, status: 'running', create_time: '2026-02-10T09:00:00Z' },
|
||
|
|
]
|
||
|
|
|
||
|
|
export const mockDimensions: Dimension[] = [
|
||
|
|
{ id: 1, name: '回答准确性', type: 'classification', description: '评估模型回答是否准确', eval_model: 'GPT-4o', eval_method: 'standard', eval_prompt: '# 角色\n你是专业的评估专家...', is_active: true, is_default: true, create_time: '2025-12-01T08:00:00Z' },
|
||
|
|
{ id: 2, name: '综合评分', type: 'metric', description: '0-5 分综合评分', eval_model: 'Claude-3.5-Sonnet', eval_method: 'metric_standard', eval_prompt: '# 角色\n你是专业评分专家...', is_active: true, is_default: false, score_min: 0, score_max: 5, pass_threshold: 3.5, create_time: '2025-12-05T09:00:00Z' },
|
||
|
|
{ id: 3, name: '语义相似度', type: 'metric', description: '生成文本与参考答案的语义相似度', eval_model: 'GPT-4o', eval_method: 'semantic', eval_prompt: '# 角色\n你是语义相似度评估专家...', is_active: true, is_default: false, score_min: 0, score_max: 1, pass_threshold: 0.7, create_time: '2025-12-08T10:00:00Z' },
|
||
|
|
{ id: 4, name: 'BLEU-4 相似度', type: 'text_similarity', description: '使用 BLEU-4 评估文本相似度', is_active: true, is_default: false, eval_method: ['bleu_4'], bleu_n: 4, output_precision: 3, create_time: '2025-12-10T11:00:00Z' },
|
||
|
|
{ id: 5, name: 'ROUGE 多指标', type: 'text_similarity', description: 'ROUGE-1/2/4 多指标评估', is_active: false, is_default: false, eval_method: ['rouge_1', 'rouge_2', 'rouge_4'], bleu_n: 1, output_precision: 3, create_time: '2025-12-12T13:00:00Z' },
|
||
|
|
]
|
||
|
|
|
||
|
|
// ============ 日志 ============
|
||
|
|
export const mockLogFiles: LogFile[] = [
|
||
|
|
{ file: 'system-2026-02-15.log', name: '系统日志-2026-02-15', size: '2.3 MB' },
|
||
|
|
{ file: 'error-2026-02-15.log', name: '错误日志-2026-02-15', size: '156 KB' },
|
||
|
|
{ file: 'system-2026-02-14.log', name: '系统日志-2026-02-14', size: '3.1 MB' },
|
||
|
|
]
|
||
|
|
|
||
|
|
export const mockTrainingLogFiles: TrainingLogFile[] = [
|
||
|
|
{ file: 'qwen-ft-finance-001_pid12345.log', name: 'finance-sft-001', size: '4.5 MB', pid: 12345, date: '2026-02-15' },
|
||
|
|
{ file: 'llama3-ft-customer-service_pid12346.log', name: 'service-dpo-001', size: '2.1 MB', pid: 12346, date: '2026-02-18' },
|
||
|
|
{ file: 'qwen-ft-legal-002_pid12350.log', name: 'legal-sft-002', size: '5.8 MB', pid: 12350, date: '2026-02-20' },
|
||
|
|
]
|
||
|
|
|
||
|
|
const fakeLogLines = [
|
||
|
|
"[2026-02-15 08:30:12] INFO: Loading model from /data/models/qwen2.5-7b",
|
||
|
|
"[2026-02-15 08:30:13] INFO: Loading dataset finance-train-001 (8560 samples)",
|
||
|
|
"[2026-02-15 08:30:15] INFO: Training started with batch_size=8, learning_rate=2e-5",
|
||
|
|
"[2026-02-15 08:32:45] INFO: {'loss': 2.341, 'grad_norm': 1.234, 'learning_rate': 1.95e-05, 'epoch': 0.05}",
|
||
|
|
"[2026-02-15 08:34:15] INFO: {'loss': 1.892, 'grad_norm': 0.987, 'learning_rate': 1.88e-05, 'epoch': 0.10}",
|
||
|
|
"[2026-02-15 08:35:42] INFO: {'loss': 1.543, 'grad_norm': 0.876, 'learning_rate': 1.79e-05, 'epoch': 0.15}",
|
||
|
|
"[2026-02-15 08:37:10] INFO: {'loss': 1.287, 'grad_norm': 0.765, 'learning_rate': 1.70e-05, 'epoch': 0.20}",
|
||
|
|
"[2026-02-15 08:38:55] INFO: {'loss': 1.056, 'grad_norm': 0.654, 'learning_rate': 1.60e-05, 'epoch': 0.25}",
|
||
|
|
"[2026-02-15 08:40:30] WARN: Gradient norm exceeds threshold (0.654 > 0.5)",
|
||
|
|
"[2026-02-15 08:42:00] INFO: {'loss': 0.892, 'grad_norm': 0.543, 'learning_rate': 1.50e-05, 'epoch': 0.30}",
|
||
|
|
"[2026-02-15 08:45:15] INFO: Saved checkpoint to /data/checkpoints/finance-sft-001-step-100",
|
||
|
|
"[2026-02-15 08:46:30] INFO: {'loss': 0.754, 'grad_norm': 0.432, 'learning_rate': 1.40e-05, 'epoch': 0.35}",
|
||
|
|
"[2026-02-15 08:48:00] INFO: {'loss': 0.623, 'grad_norm': 0.398, 'learning_rate': 1.30e-05, 'epoch': 0.40}",
|
||
|
|
"[2026-02-15 08:50:15] INFO: {'loss': 0.512, 'grad_norm': 0.345, 'learning_rate': 1.20e-05, 'epoch': 0.45}",
|
||
|
|
"[2026-02-15 08:52:30] ERROR: Failed to save model: No space left on device",
|
||
|
|
"[2026-02-15 08:52:31] INFO: Retrying save with compressed format...",
|
||
|
|
"[2026-02-15 08:53:00] INFO: Model saved successfully (size: 14.2 GB)",
|
||
|
|
"[2026-02-15 08:55:00] INFO: {'loss': 0.421, 'grad_norm': 0.298, 'learning_rate': 1.10e-05, 'epoch': 0.50}",
|
||
|
|
"[2026-02-15 08:57:30] INFO: {'loss': 0.356, 'grad_norm': 0.256, 'learning_rate': 1.00e-05, 'epoch': 0.55}",
|
||
|
|
"[2026-02-15 09:00:00] INFO: Training completed successfully",
|
||
|
|
"",
|
||
|
|
"***** train metrics *****",
|
||
|
|
" epoch = 1.0",
|
||
|
|
" total_flos = 1234567890",
|
||
|
|
" train_loss = 0.342",
|
||
|
|
" train_runtime = 1785.2",
|
||
|
|
" train_samples_per_second = 4.79",
|
||
|
|
" train_steps_per_second = 0.60",
|
||
|
|
"***** train metrics end *****",
|
||
|
|
]
|
||
|
|
|
||
|
|
export const mockLogContent: LogContent = {
|
||
|
|
file: 'system-2026-02-15.log',
|
||
|
|
size: '2.3 MB',
|
||
|
|
content: fakeLogLines.join('\n'),
|
||
|
|
}
|