Skip to content

Commit 3f2873d

Browse files
authored
Merge pull request #7 from JavaZeroo/codex/modify-default-keyword-matching
Update default keyword configuration
2 parents 4beca85 + aa11ed3 commit 3f2873d

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323

2424
### 🔍 **强大的数据解析系统**
2525
- **🎨 关键词匹配**(默认模式):智能识别日志中的关键字,自动提取数值
26-
- Loss: `loss` → 自动查找后续数字
27-
- Grad Norm: `global_norm` → 自动提取梯度范数值
26+
- Loss: `loss:` → 自动查找后续数字
27+
- Grad Norm: `norm:` → 自动提取梯度范数值
2828
- **⚙️ 正则表达式模式**:支持复杂的自定义匹配规则
2929
- **🤖 智能推荐**:系统自动分析日志格式并推荐最佳解析方式
3030
- **🔬 多格式支持**:JSON、键值对、数组、科学计数法等多种日志格式
@@ -83,7 +83,7 @@
8383
### 🎯 快速上手
8484
1. **📂 上传文件**: 拖拽训练日志文件到页面任意位置
8585
2. **🔍 选择解析方式**:
86-
- **关键词匹配**(推荐):直接使用 `loss``global_norm` 关键字
86+
- **关键词匹配**(推荐):直接使用 `loss:``norm:` 关键字
8787
- **正则表达式**:自定义复杂的匹配规则
8888
3. **📊 查看图表**: 系统自动解析并生成交互式图表
8989
4. **⚖️ 对比分析**: 上传两个文件时自动启用高级对比功能
@@ -103,21 +103,21 @@
103103
```bash
104104
# 标准格式
105105
loss: 0.1234
106-
global_norm: [1.5678]
106+
norm: [1.5678]
107107

108108
# JSON 格式
109-
{"loss": 0.1234, "global_norm": 1.5678}
109+
{"loss": 0.1234, "norm": 1.5678}
110110

111111
# 数组格式
112112
loss [0.1234]
113-
global_norm: [1.5678]
113+
norm: [1.5678]
114114

115115
# 科学计数法
116116
loss: 1.234e-4
117-
global_norm: 1.5678E+0
117+
norm: 1.5678E+0
118118

119119
# MindFormers 格式
120-
Step 100: loss=0.1234 global_norm=1.5678
120+
Step 100: loss=0.1234 norm=1.5678
121121
```
122122

123123
### ⚙️ 正则表达式模式

src/App.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ function App() {
1414
const [globalParsingConfig, setGlobalParsingConfig] = useState({
1515
loss: {
1616
mode: 'keyword', // 'keyword' | 'regex'
17-
keyword: 'loss',
17+
keyword: 'loss:',
1818
regex: 'loss:\\s*([\\d.eE+-]+)'
1919
},
2020
gradNorm: {
2121
mode: 'keyword', // 'keyword' | 'regex'
22-
keyword: 'global_norm',
22+
keyword: 'norm:',
2323
regex: 'grad[\\s_]norm:\\s*([\\d.eE+-]+)'
2424
}
2525
});

src/components/FileConfigModal.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ export function FileConfigModal({ file, isOpen, onClose, onSave, globalParsingCo
2727
const [config, setConfig] = useState({
2828
loss: {
2929
mode: 'keyword',
30-
keyword: 'loss',
30+
keyword: 'loss:',
3131
regex: 'loss:\\s*([\\d.eE+-]+)'
3232
},
3333
gradNorm: {
3434
mode: 'keyword',
35-
keyword: 'global_norm',
35+
keyword: 'norm:',
3636
regex: 'grad[\\s_]norm:\\s*([\\d.eE+-]+)'
3737
},
3838
dataRange: {
@@ -131,7 +131,7 @@ export function FileConfigModal({ file, isOpen, onClose, onSave, globalParsingCo
131131
value={configItem.keyword}
132132
onChange={(e) => handleConfigChange(type, 'keyword', e.target.value)}
133133
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"
134-
placeholder={type === 'loss' ? 'loss' : 'global_norm'}
134+
placeholder={type === 'loss' ? 'loss:' : 'norm:'}
135135
/>
136136
<p className="text-xs text-gray-500 mt-1">
137137
支持模糊匹配,如 "loss" 可匹配 "training_loss"

src/components/RegexControls.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ export function RegexControls({
373373
value={config.keyword}
374374
onChange={(e) => onConfigChange('keyword', e.target.value)}
375375
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"
376-
placeholder={type === 'loss' ? 'loss' : 'global_norm'}
376+
placeholder={type === 'loss' ? 'loss:' : 'norm:'}
377377
/>
378378
<p className="text-xs text-gray-500 mt-1">
379379
支持模糊匹配,如 "loss" 可匹配 "training_loss"

src/components/__tests__/valueExtractor.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ const sampleContent = `loss: 0.123\nstep2 loss 0.234\n{"loss": 0.345, "global_no
55

66
describe('ValueExtractor', () => {
77
it('extracts values by keyword', () => {
8-
const results = ValueExtractor.extractByKeyword(sampleContent, 'loss');
9-
expect(results.length).toBe(3);
8+
const results = ValueExtractor.extractByKeyword(sampleContent, 'loss:');
9+
expect(results.length).toBe(1);
1010
expect(results[0].value).toBeCloseTo(0.123);
1111
});
1212

0 commit comments

Comments
 (0)