| """ |
| 配置管理 |
| """ |
|
|
| from dataclasses import dataclass, field |
| from typing import Optional |
|
|
| @dataclass |
| class ModelConfig: |
| """模型配置""" |
| |
| model_name: str = "./models/Qwen2.5-VL-3B-Instruct" |
| |
| |
| |
| |
| |
| |
| tta_intermediate_dim: int = 512 |
| |
| |
| belief_aggregation: str = "mean_pool" |
| |
| |
| use_lora: bool = False |
| lora_r: int = 32 |
| lora_alpha: int = 32 |
| lora_dropout: float = 0.1 |
| lora_target_modules: list = field(default_factory=lambda: [ |
| 'q_proj', 'v_proj', 'k_proj', 'o_proj', |
| 'gate_proj', 'up_proj', 'down_proj' |
| ]) |
|
|
| @dataclass |
| class TrainingConfig: |
| """训练配置""" |
| |
| output_dir: str = "./checkpoints/sft" |
| num_epochs: int = 10 |
| batch_size: int = 4 |
| gradient_accumulation_steps: int = 4 |
| learning_rate: float = 2e-5 |
| weight_decay: float = 0.01 |
| warmup_steps: int = 1000 |
| max_grad_norm: float = 1.0 |
| |
| |
| lambda_nll: float = 0.5 |
| |
| |
| curriculum_warmup_ratio: float = 0.3 |
| curriculum_transition_ratio: float = 0.4 |
| |
| |
| save_steps: int = 500 |
| logging_steps: int = 100 |
| eval_steps: int = 500 |
| save_total_limit: int = 3 |
| |
| |
| early_stopping_patience: int = 3 |
| early_stopping_metric: str = "val_mse" |
| |
| |
| fp16: bool = False |
| bf16: bool = True |
| |
| |
| use_deepspeed: bool = False |
| deepspeed_config: Optional[str] = None |
|
|
| @dataclass |
| class DataConfig: |
| """数据配置""" |
| |
| train_data_path: str = "./data/processed/train/" |
| val_data_path: str = "./data/processed/val/" |
| |
| |
| video_window: float = 2.0 |
| video_fps: int = 10 |
| video_height: int = 224 |
| video_width: int = 448 |
| max_frames: int = 20 |
| |
| |
| num_workers: int = 4 |
| pin_memory: bool = True |
| prefetch_factor: int = 2 |
| |
| |
| use_augmentation: bool = True |
| time_jitter: float = 0.2 |
| color_jitter: bool = True |