File size: 792 Bytes
af9853e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import os

class Config:
    # 路径配置
    ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    DATA_DIR = os.path.join(ROOT_DIR, 'data')
    CHECKPOINT_DIR = os.path.join(ROOT_DIR, 'checkpoints')
    RESULTS_DIR = os.path.join(ROOT_DIR, 'results')
    OUTPUT_DIR = CHECKPOINT_DIR # Alias for compatibility
    
    # 模型配置
    BASE_MODEL = "google-bert/bert-base-chinese"
    NUM_LABELS = 3
    MAX_LENGTH = 128
    
    # 训练配置
    BATCH_SIZE = 32
    LEARNING_RATE = 2e-5
    NUM_EPOCHS = 3
    WARMUP_RATIO = 0.1
    WEIGHT_DECAY = 0.01
    LOGGING_STEPS = 100
    SAVE_STEPS = 500
    EVAL_STEPS = 500
    
    # 标签映射
    LABEL2ID = {'negative': 0, 'neutral': 1, 'positive': 2}
    ID2LABEL = {0: 'negative', 1: 'neutral', 2: 'positive'}