Download guac_coder/config.py from npc-worldwide/guac-coder: direct link, hf CLI and curl.
- Browser
- Download file 3.18 kB
-
https://huggingface.co/npc-worldwide/guac-coder/resolve/main/guac_coder/config.py
- Command line
-
hf download hf://npc-worldwide/guac-coder/guac_coder/config.py
-
curl -L -o config.py https://huggingface.co/npc-worldwide/guac-coder/resolve/main/guac_coder/config.py
3.18 kB
| """Configuration dataclasses for guac-coder training.""" | |
| from dataclasses import dataclass, field | |
| from typing import List, Optional | |
| class RewardConfig: | |
| """Configuration for the 12-rule code reward function.""" | |
| # Punishments (negative rewards) | |
| seaborn_penalty: float = -0.3 | |
| grid_penalty: float = -0.2 | |
| title_penalty: float = -0.15 | |
| bargraph_penalty: float = -0.25 | |
| narrative_comment_penalty: float = -0.15 | |
| tryexcept_penalty: float = -0.2 | |
| class_penalty: float = -0.15 | |
| print_penalty: float = -0.2 | |
| batch_write_penalty: float = -0.15 | |
| non_resumable_penalty: float = -0.25 | |
| bare_script_penalty: float = -0.3 | |
| # Rewards (positive) | |
| chroptiks_reward: float = 0.3 | |
| dataframe_csv_reward: float = 0.2 | |
| logging_reward: float = 0.2 | |
| checkpoint_reward: float = 0.2 | |
| function_def_reward: float = 0.15 | |
| # Rater selection: "static" (13-rule regex/AST), "decision" (Ollama | |
| # System-One decision model such as clef), or "llm" (generative | |
| # LLM-as-judge, legacy rewards.py path). | |
| rater: str = "static" | |
| # LLM judge config (rater="llm") | |
| judge_model: str = "gpt-4o" | |
| judge_temperature: float = 0.0 | |
| judge_max_tokens: int = 2048 | |
| # Decision-model config (rater="decision") | |
| decision_model: str = "clef" | |
| decision_base_url: str = "http://localhost:11434" | |
| decision_timeout: float = 120.0 | |
| decision_threshold: float = 0.5 | |
| decision_on_error: str = "static" | |
| decision_cache: bool = True | |
| def decision_judge_config(self): | |
| """Build the DecisionJudgeConfig implied by these settings.""" | |
| from guac_coder.decision_judge import DecisionJudgeConfig | |
| return DecisionJudgeConfig( | |
| model=self.decision_model, | |
| base_url=self.decision_base_url, | |
| timeout=self.decision_timeout, | |
| threshold=self.decision_threshold, | |
| on_error=self.decision_on_error, | |
| cache=self.decision_cache, | |
| ) | |
| class GRPOConfig: | |
| """Configuration for GRPO training.""" | |
| model_name: str = "Qwen/Qwen2.5-Coder-7B" | |
| output_dir: str = "./grpo_output" | |
| # Generation params for group sampling | |
| group_size: int = 8 | |
| temperature: float = 0.8 | |
| max_new_tokens: int = 2048 | |
| # Training params | |
| num_iterations: int = 100 | |
| learning_rate: float = 1e-5 | |
| batch_size: int = 1 | |
| gradient_accumulation_steps: int = 4 | |
| # RL params | |
| epsilon: float = 0.2 | |
| beta: float = 0.01 | |
| # Checkpointing | |
| checkpoint_interval: int = 10 | |
| resume_from_checkpoint: Optional[str] = None | |
| # Backend: auto (prefer mlx), mlx, or torch | |
| backend: str = "auto" | |
| # Data | |
| train_data_path: Optional[str] = None | |
| eval_data_path: Optional[str] = None | |
| # Logging | |
| log_interval: int = 1 | |
| eval_interval: int = 10 | |
| class DataConfig: | |
| """Configuration for training data preparation.""" | |
| source_repos: List[str] = field(default_factory=list) | |
| output_path: str = "./training_data.jsonl" | |
| min_code_lines: int = 10 | |
| max_code_lines: int = 500 | |
| include_docstrings: bool = True | |
| filter_by_extension: List[str] = field(default_factory=lambda: [".py"]) | |