File size: 6,574 Bytes
f50dc54 |
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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
"""
TestTime RLVR Configuration
AZR ๊ธฐ๋ฐ TestTime RLVR์ ์ํ ์ค์ ํด๋์ค
"""
from dataclasses import dataclass
from typing import Optional, List, Dict, Any
import torch
@dataclass
class TestTimeConfig:
"""TestTime RLVR ์ ์ฉ ์ค์ """
# ============================================================================
# ๊ธฐ๋ณธ ๋ชจ๋ธ ์ค์ (AZR ๊ธฐ๋ฐ)
# ============================================================================
model_name: str = "Qwen/Qwen2.5-7B"
device: str = "auto"
torch_dtype: torch.dtype = torch.bfloat16
use_flash_attention: bool = True
enable_gradient_checkpointing: bool = True
# ============================================================================
# TestTime ํ์ต ์ค์
# ============================================================================
max_adaptation_steps: int = 10 # AZR ๋๋น ์งง์ ์ ์ ํ์ต
adaptation_batch_size: int = 1 # ์๊ท๋ชจ ๋ฐฐ์น
gradient_accumulation_steps: int = 4
learning_rate: float = 1e-6 # AZR๊ณผ ๋์ผ
# ============================================================================
# ๋ฐ๋ณต ์ ์ด ์ค์
# ============================================================================
max_cycles: int = 3 # ์ต๋ ๋ฐ๋ณต ํ์
min_improvement_threshold: float = 0.05 # ์ต์ ๊ฐ์ ์๊ณ๊ฐ
early_stopping_patience: int = 2 # Early stopping
# ============================================================================
# IPO ์ถ์ถ ์ค์
# ============================================================================
max_ipo_triples: int = 10 # ์ถ์ถํ ์ต๋ ํธ๋ฆฌํ ์
python_executor_timeout: int = 5 # AZR๋ณด๋ค ์งง์ ํ์์์
validate_triples: bool = True # ํธ๋ฆฌํ ๊ฒ์ฆ ์ฌ๋ถ
# ============================================================================
# ๋ค์ค ํ๋ก๊ทธ๋จ ์์ฑ ์ค์
# ============================================================================
num_program_variations: int = 4 # ์์ฑํ ๋ค์ํ ํ๋ก๊ทธ๋จ ์
baseline_evaluation_rounds: int = 5 # ๋ฒ ์ด์ค๋ผ์ธ ์ฑ๋ฅ ์ธก์ ํ์
diverse_generation_temperature: float = 0.7 # ๋ค์ํ ํ๋ก๊ทธ๋จ ์์ฑ์ฉ temperature
baseline_generation_temperature: float = 0.05 # ๋ฒ ์ด์ค๋ผ์ธ ์ธก์ ์ฉ temperature
# ============================================================================
# ํ์คํฌ ์์ฑ ์ค์
# ============================================================================
task_distribution: Dict[str, float] = None # induction:deduction:abduction ๋น์จ
max_tasks_per_type: int = 5 # ํ์
๋ณ ์ต๋ ํ์คํฌ ์
use_azr_templates: bool = True # AZR ํ
ํ๋ฆฟ ์ฌ์ฉ
skip_task_evaluation: bool = True # Task evaluation(4๋จ๊ณ) ์คํต ์ฌ๋ถ (VeRL์์ ์ํ)
# ============================================================================
# ๋ณด์ ์ค์ (AZR ๊ธฐ๋ฐ)
# ============================================================================
use_accuracy_reward: bool = True
use_improvement_reward: bool = True # TestTime ์ ์ฉ ๊ฐ์ ๋ ๋ณด์
use_complexity_reward: bool = True
accuracy_weight: float = 1.0
improvement_weight: float = 0.5 # ๊ฐ์ ๋ ๊ฐ์ค์น
complexity_weight: float = 0.1
# ============================================================================
# ๋ก๊น
์ค์
# ============================================================================
log_level: str = "INFO"
save_intermediate_results: bool = True
log_ipo_details: bool = True
log_task_details: bool = True
log_training_metrics: bool = True
# ============================================================================
# ๋ฉ๋ชจ๋ฆฌ ์ต์ ํ ์ค์ (AZR ๊ธฐ๋ฐ)
# ============================================================================
gpu_memory_utilization: float = 0.4
max_workers: int = 2 # Python executor workers
use_memory_efficient_attention: bool = True
def __post_init__(self):
"""์ค์ ํ์ฒ๋ฆฌ"""
if self.task_distribution is None:
# ๊ธฐ๋ณธ ํ์คํฌ ๋ถํฌ: ๊ท ๋ฑ ๋ถ๋ฐฐ
self.task_distribution = {
"induction": 0.33,
"deduction": 0.33,
"abduction": 0.34
}
# device ์๋ ์ค์
if self.device == "auto":
self.device = "cuda" if torch.cuda.is_available() else "cpu"
# dtype ์ค์
if self.device == "cpu":
self.torch_dtype = torch.float32
def to_dict(self) -> Dict[str, Any]:
"""์ค์ ์ ๋์
๋๋ฆฌ๋ก ๋ณํ"""
return {
"model_name": self.model_name,
"device": self.device,
"torch_dtype": str(self.torch_dtype),
"max_adaptation_steps": self.max_adaptation_steps,
"max_cycles": self.max_cycles,
"learning_rate": self.learning_rate,
"task_distribution": self.task_distribution,
"reward_weights": {
"accuracy": self.accuracy_weight,
"improvement": self.improvement_weight,
"complexity": self.complexity_weight
}
}
@classmethod
def from_dict(cls, config_dict: Dict[str, Any]) -> 'TestTimeConfig':
"""๋์
๋๋ฆฌ์์ ์ค์ ๋ก๋"""
return cls(**config_dict)
@dataclass
class BenchmarkConfig:
"""๋ฒค์น๋งํฌ๋ณ ์ค์ """
name: str # "humaneval", "mbpp", "livecodebase"
data_path: str
problem_prefix: str # "HumanEval", "Mbpp"
start_index: int = 0 # MBPP๋ 2๋ถํฐ ์์
max_problems: int = 5 # ํ
์คํธํ ๋ฌธ์ ์
# ๋ฒค์น๋งํฌ๋ณ ํนํ ์ค์
test_timeout: int = 10
use_plus_version: bool = True # HumanEval+, MBPP+ ์ฌ์ฉ
@classmethod
def get_humaneval_config(cls) -> 'BenchmarkConfig':
return cls(
name="humaneval",
data_path="evaluation/code_eval/data/HumanEvalPlus.jsonl",
problem_prefix="HumanEval",
start_index=0,
max_problems=5
)
@classmethod
def get_mbpp_config(cls) -> 'BenchmarkConfig':
return cls(
name="mbpp",
data_path="evaluation/code_eval/data/MbppPlus.jsonl",
problem_prefix="Mbpp",
start_index=2, # MBPP๋ 2๋ฒ๋ถํฐ
max_problems=5
) |