From aa11ed32b50b83e84ac8e96387fe2c8625b5375d Mon Sep 17 00:00:00 2001 From: JavaZero <71128095+JavaZeroo@users.noreply.github.com> Date: Tue, 22 Jul 2025 09:21:29 +0800 Subject: [PATCH] Update default keywords to use loss: and norm: --- README.md | 16 ++++++++-------- src/App.jsx | 4 ++-- src/components/FileConfigModal.jsx | 6 +++--- src/components/RegexControls.jsx | 2 +- src/components/__tests__/valueExtractor.test.js | 4 ++-- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 6b6f453..1af44f6 100644 --- a/README.md +++ b/README.md @@ -23,8 +23,8 @@ ### 🔍 **强大的数据解析系统** - **🎨 关键词匹配**(默认模式):智能识别日志中的关键字,自动提取数值 - - Loss: `loss` → 自动查找后续数字 - - Grad Norm: `global_norm` → 自动提取梯度范数值 + - Loss: `loss:` → 自动查找后续数字 + - Grad Norm: `norm:` → 自动提取梯度范数值 - **⚙️ 正则表达式模式**:支持复杂的自定义匹配规则 - **🤖 智能推荐**:系统自动分析日志格式并推荐最佳解析方式 - **🔬 多格式支持**:JSON、键值对、数组、科学计数法等多种日志格式 @@ -83,7 +83,7 @@ ### 🎯 快速上手 1. **📂 上传文件**: 拖拽训练日志文件到页面任意位置 2. **🔍 选择解析方式**: - - **关键词匹配**(推荐):直接使用 `loss` 和 `global_norm` 关键字 + - **关键词匹配**(推荐):直接使用 `loss:` 和 `norm:` 关键字 - **正则表达式**:自定义复杂的匹配规则 3. **📊 查看图表**: 系统自动解析并生成交互式图表 4. **⚖️ 对比分析**: 上传两个文件时自动启用高级对比功能 @@ -103,21 +103,21 @@ ```bash # 标准格式 loss: 0.1234 -global_norm: [1.5678] +norm: [1.5678] # JSON 格式 -{"loss": 0.1234, "global_norm": 1.5678} +{"loss": 0.1234, "norm": 1.5678} # 数组格式 loss [0.1234] -global_norm: [1.5678] +norm: [1.5678] # 科学计数法 loss: 1.234e-4 -global_norm: 1.5678E+0 +norm: 1.5678E+0 # MindFormers 格式 -Step 100: loss=0.1234 global_norm=1.5678 +Step 100: loss=0.1234 norm=1.5678 ``` ### ⚙️ 正则表达式模式 diff --git a/src/App.jsx b/src/App.jsx index dc2f341..c7ba568 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -14,12 +14,12 @@ function App() { const [globalParsingConfig, setGlobalParsingConfig] = useState({ loss: { mode: 'keyword', // 'keyword' | 'regex' - keyword: 'loss', + keyword: 'loss:', regex: 'loss:\\s*([\\d.eE+-]+)' }, gradNorm: { mode: 'keyword', // 'keyword' | 'regex' - keyword: 'global_norm', + keyword: 'norm:', regex: 'grad[\\s_]norm:\\s*([\\d.eE+-]+)' } }); diff --git a/src/components/FileConfigModal.jsx b/src/components/FileConfigModal.jsx index 176bd4a..ad3d850 100644 --- a/src/components/FileConfigModal.jsx +++ b/src/components/FileConfigModal.jsx @@ -27,12 +27,12 @@ export function FileConfigModal({ file, isOpen, onClose, onSave, globalParsingCo const [config, setConfig] = useState({ loss: { mode: 'keyword', - keyword: 'loss', + keyword: 'loss:', regex: 'loss:\\s*([\\d.eE+-]+)' }, gradNorm: { mode: 'keyword', - keyword: 'global_norm', + keyword: 'norm:', regex: 'grad[\\s_]norm:\\s*([\\d.eE+-]+)' }, dataRange: { @@ -131,7 +131,7 @@ export function FileConfigModal({ file, isOpen, onClose, onSave, globalParsingCo value={configItem.keyword} onChange={(e) => handleConfigChange(type, 'keyword', e.target.value)} className="w-full px-2 py-1 text-sm border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 focus:outline-none" - placeholder={type === 'loss' ? 'loss' : 'global_norm'} + placeholder={type === 'loss' ? 'loss:' : 'norm:'} />
支持模糊匹配,如 "loss" 可匹配 "training_loss" diff --git a/src/components/RegexControls.jsx b/src/components/RegexControls.jsx index 46ea981..7a5a911 100644 --- a/src/components/RegexControls.jsx +++ b/src/components/RegexControls.jsx @@ -373,7 +373,7 @@ export function RegexControls({ value={config.keyword} onChange={(e) => onConfigChange('keyword', e.target.value)} className="w-full px-2 py-1 text-sm border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 focus:outline-none" - placeholder={type === 'loss' ? 'loss' : 'global_norm'} + placeholder={type === 'loss' ? 'loss:' : 'norm:'} />
支持模糊匹配,如 "loss" 可匹配 "training_loss" diff --git a/src/components/__tests__/valueExtractor.test.js b/src/components/__tests__/valueExtractor.test.js index 78a3d18..db286dd 100644 --- a/src/components/__tests__/valueExtractor.test.js +++ b/src/components/__tests__/valueExtractor.test.js @@ -5,8 +5,8 @@ const sampleContent = `loss: 0.123\nstep2 loss 0.234\n{"loss": 0.345, "global_no describe('ValueExtractor', () => { it('extracts values by keyword', () => { - const results = ValueExtractor.extractByKeyword(sampleContent, 'loss'); - expect(results.length).toBe(3); + const results = ValueExtractor.extractByKeyword(sampleContent, 'loss:'); + expect(results.length).toBe(1); expect(results[0].value).toBeCloseTo(0.123); });