| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| """Training configuration dataclass. |
| |
| Defines ``TrainingConfig``, a dataclass that holds all hyperparameters and paths |
| for training. Loaded from a JSON config file via ``TrainingConfig.from_json()`` |
| in ``omnivoice.cli.train``. |
| """ |
|
|
| import json |
| from dataclasses import asdict, dataclass, field |
| from typing import List, Optional, Tuple |
|
|
|
|
| @dataclass |
| class TrainingConfig: |
| |
| output_dir: Optional[str] = None |
| data_config: Optional[str] = None |
|
|
| |
| llm_name_or_path: str = "Qwen/Qwen3-0.6B" |
| audio_vocab_size: int = 1025 |
| audio_mask_id: int = 1024 |
| num_audio_codebook: int = 8 |
|
|
| |
| audio_codebook_weights: List[float | int] = field( |
| default_factory=lambda: [8, 8, 6, 6, 4, 4, 2, 2] |
| ) |
| drop_cond_ratio: float = 0.1 |
| prompt_ratio_range: Tuple[float, float] = field(default_factory=lambda: (0.0, 0.3)) |
| mask_ratio_range: Tuple[float, float] = field(default_factory=lambda: (0.0, 1.0)) |
| language_ratio: float = 0.8 |
| use_pinyin_ratio: float = 0.3 |
| instruct_ratio: float = 1.0 |
| only_instruct_ratio: float = 0.5 |
|
|
| |
| resume_from_checkpoint: Optional[str] = None |
| init_from_checkpoint: Optional[str] = None |
|
|
| |
| learning_rate: float = 1e-4 |
| weight_decay: float = 0.01 |
| max_grad_norm: float = 1.0 |
| steps: int = 300000 |
| seed: int = 42 |
| lr_scheduler_type: str = "cosine" |
| warmup_type: str = "ratio" |
| warmup_ratio: float = 0.03 |
| warmup_steps: int = 2000 |
|
|
| |
| batch_tokens: int = 8192 |
| gradient_accumulation_steps: int = 1 |
| num_workers: int = 8 |
|
|
| |
| mixed_precision: str = "bf16" |
| allow_tf32: bool = True |
| use_deepspeed: bool = False |
| deepspeed_config: Optional[str] = None |
| attn_implementation: str = "flex_attention" |
|
|
| |
| max_sample_tokens: int = 2000 |
| min_sample_tokens: int = 50 |
| max_batch_size: int = 64 |
|
|
| |
| logging_steps: int = 100 |
| eval_steps: int = 1000 |
| save_steps: int = 10000 |
| keep_last_n_checkpoints: int = -1 |
|
|
| @classmethod |
| def from_json(cls, json_path: str): |
| with open(json_path, "r") as f: |
| cfg_dict = json.load(f) |
| valid_keys = cls.__annotations__.keys() |
| filtered_dict = {k: v for k, v in cfg_dict.items() if k in valid_keys} |
| instance = cls(**filtered_dict) |
| return instance |
|
|
| def save_to_json(self, json_path: str): |
| data = asdict(self) |
| with open(json_path, "w") as f: |
| json.dump(data, f, indent=4) |
|
|