|
1 | 1 | import os |
| 2 | +from pathlib import Path |
2 | 3 |
|
3 | 4 | from pydantic_settings import SettingsConfigDict |
4 | 5 |
|
5 | | -from rdagent.app.data_science.conf import DS_RD_SETTING |
6 | 6 | from rdagent.core.conf import RD_AGENT_SETTINGS, ExtendedBaseSettings |
7 | 7 |
|
8 | 8 |
|
9 | | -class LLMFinetuneScen(ExtendedBaseSettings): |
| 9 | +class LLMFinetunePropSetting(ExtendedBaseSettings): |
| 10 | + """LLM Fine-tune dedicated property settings. |
| 11 | +
|
| 12 | + - Adjust timeouts and template |
| 13 | + - Use FT_ env prefix for overrides |
| 14 | + """ |
| 15 | + |
10 | 16 | model_config = SettingsConfigDict(env_prefix="FT_", protected_namespaces=()) |
11 | | - scen: str = "rdagent.app.finetune.llm.scen.LLMFinetuneScen" |
| 17 | + |
| 18 | + # Main Components |
| 19 | + scen: str = "rdagent.scenarios.finetune.scen.scenario.LLMFinetuneScen" |
| 20 | + """Scenario class for LLM fine-tuning tasks.""" |
| 21 | + |
| 22 | + hypothesis_gen: str = "rdagent.scenarios.finetune.proposal.proposal.LLMFinetuneExpGen" |
| 23 | + """Hypothesis generation class for LLM fine-tuning tasks.""" |
| 24 | + |
| 25 | + hypothesis2experiment: str = "rdagent.scenarios.finetune.proposal.proposal.FTHypothesis2Experiment" |
| 26 | + """Hypothesis to experiment converter. |
| 27 | + Function: Convert abstract LLM fine-tuning hypotheses into concrete experiment configurations. |
12 | 28 | """ |
13 | | - Scenario class for data science tasks. |
14 | | - - For Kaggle competitions, use: "rdagent.scenarios.data_science.scen.KaggleScen" |
15 | | - - For custom data science scenarios, use: "rdagent.scenarios.data_science.scen.DataScienceScen" |
16 | | - - For LLM finetune scenarios, use: "rdagent.app.finetune.llm.scen.LLMFinetuneScen" |
17 | | - - For Data science finetune scenarios, use: "rdagent.app.finetune.data_science.scen.DSFinetuneScen" |
| 29 | + |
| 30 | + coder: str = "rdagent.components.coder.finetune.LLMFinetuneCoSTEER" |
| 31 | + """Code generator. |
| 32 | + Function: Generate LLM fine-tuning code based on experiment design. |
18 | 33 | """ |
19 | 34 |
|
20 | | - hypothesis_gen: str = "rdagent.app.finetune.llm.proposal.FinetuneExpGen" |
21 | | - """Hypothesis generation class""" |
| 35 | + runner: str = "rdagent.scenarios.finetune.train.runner.LLMFinetuneRunner" # TODO |
| 36 | + """Code runner. |
| 37 | + Function: Execute LLM fine-tuning code in a Docker environment. |
| 38 | + """ |
22 | 39 |
|
| 40 | + summarizer: str = "rdagent.scenarios.finetune.dev.feedback.LLMExperiment2Feedback" |
| 41 | + """Result summarizer - To be implemented. |
| 42 | + Function: Analyze fine-tuning results and generate feedback, including performance metrics and error analysis. |
| 43 | + """ |
| 44 | + |
| 45 | + # Timeouts (longer for LLM training) |
23 | 46 | debug_timeout: int = 36000 |
24 | | - """The timeout limit for running on debugging data""" |
| 47 | + debug_recommend_timeout: int = 36000 |
25 | 48 | full_timeout: int = 360000 |
26 | | - """The timeout limit for running on full data""" |
| 49 | + full_recommend_timeout: int = 360000 |
27 | 50 |
|
| 51 | + # Pipeline behavior |
28 | 52 | coder_on_whole_pipeline: bool = True |
29 | 53 | enable_model_dump: bool = True |
30 | | - app_tpl: str = "app/finetune/llm/tpl" |
| 54 | + app_tpl: str = "scenarios/finetune" |
31 | 55 |
|
| 56 | + # Data paths and processing |
| 57 | + file_path: str | None = None # FT_FILE_PATH/datasets/<dataset>/, FT_FILE_PATH/models/<baseModel>/ |
| 58 | + show_nan_columns: bool = False |
| 59 | + sample_data_by_LLM: bool = True |
32 | 60 |
|
33 | | -def update_settings(competition: str): |
34 | | - """ |
35 | | - Update the RD_AGENT_SETTINGS with the values from LLM_FINETUNE_SETTINGS. |
36 | | - """ |
37 | | - LLM_FINETUNE_SETTINGS = LLMFinetuneScen() |
38 | | - RD_AGENT_SETTINGS.app_tpl = LLM_FINETUNE_SETTINGS.app_tpl |
39 | | - os.environ["DS_CODER_COSTEER_EXTRA_EVALUATOR"] = '["rdagent.app.finetune.share.eval.PrevModelLoadEvaluator"]' |
40 | | - for field_name, new_value in LLM_FINETUNE_SETTINGS.model_dump().items(): |
41 | | - if hasattr(DS_RD_SETTING, field_name): |
42 | | - setattr(DS_RD_SETTING, field_name, new_value) |
43 | | - DS_RD_SETTING.competition = competition |
| 61 | + # LLM-specific fields |
| 62 | + base_model: str | None = None |
| 63 | + dataset: str = "" |
| 64 | + |
| 65 | + # LLaMA Factory |
| 66 | + update_llama_factory: bool = True |
| 67 | + |
| 68 | + # Docker settings |
| 69 | + docker_enable_cache: bool = False |
| 70 | + """Enable Docker cache for training (set via FT_DOCKER_ENABLE_CACHE)""" |
| 71 | + |
| 72 | + @property |
| 73 | + def task(self) -> str: |
| 74 | + """Generate task name from base model and dataset.""" |
| 75 | + if self.base_model and self.dataset: |
| 76 | + return f"{self.base_model}@{self.dataset}".replace("/", "_").replace("\\", "_") |
| 77 | + return "" |
| 78 | + |
| 79 | + |
| 80 | +# Global setting instance for LLM finetuning scenario |
| 81 | +FT_RD_SETTING = LLMFinetunePropSetting() |
0 commit comments