-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix: add spec for hyperparameters in task design and coder #995
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 17 commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
da36f43
init commit
979640a
remove the 5-fold spec from prompts
2c87022
refine the hyperparameter specification
ccdb471
do not sample data
84bf563
a small spelling issue
TPLin22 13be390
refine prompt to avoid submission cheating
TPLin22 4ca0411
do not sample data
c122816
simplify code
ffec796
refine the coder evaluator prompt
ffe70ca
refine wording
RolandMinrui b1f03f2
remove runtime from proposal
771e7e8
refine wording
55d8d03
refine prompt
3619c95
add gpu info in runtime_info.py
3f487fe
Merge branch 'main' of https://github.com/microsoft/RD-Agent into min…
6ec2080
modify the spec
7d27e09
add router and add refinement exp gen
b669365
fix prompt bug
bbb8bcf
Merge branch 'main' of https://github.com/microsoft/RD-Agent into min…
49d9686
use rule-based logic for router
43255d6
complete the prompt
1995f6a
Merge branch 'main' of https://github.com/microsoft/RD-Agent into min…
8944273
fix circular import bug
81d284a
fix bug
a18e454
make refine_decision optional
408e7ab
update pipeline prompts: (1) add scenary: in an iterative cooding loo…
Hoder-zyf beb3bf8
fix a small bug
peteryang1 93a3acd
fix a small bug
peteryang1 3a15f5c
Merge branch 'main' into minrui/fix_hyperparameter_problems
peteryangms 6d9607a
rdagent/scenarios/data_science/loop.py back to the original version
Hoder-zyf 8312380
refactor: replace _get_exp_gen with default_exp_gen for exp generation
you-n-g ed984eb
import
you-n-g ceb6335
refactor: make the __init__ back to main
Hoder-zyf 833be8f
fix small bugs
Hoder-zyf 2e6d190
fix bugs for proposal_version
Hoder-zyf 71e68c6
move refine into runner
peteryangms 2b8a2ed
Merge branch 'xuyang1/help_minrui_hyppp' into minrui/fix_hyperparamet…
peteryangms e56ebfd
check early stop
peteryangms 7caad02
Merge branch 'main' into minrui/fix_hyperparameter_problems
peteryangms eb9ec5d
EDA improvement & coder classes number
peteryangms 2ebcc35
fix CI
peteryangms 65deb7d
slightly refine the prompt
1edf3a9
remove rule_base_eval and remove useless prompt
peteryangms File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hoder-zyf marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
130 changes: 128 additions & 2 deletions
130
rdagent/scenarios/data_science/proposal/exp_gen/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,129 @@ | ||
| from rdagent.scenarios.data_science.proposal.exp_gen.base import DSTrace | ||
| from typing import Any, Dict, List, Optional, Tuple | ||
|
|
||
| __all__ = ["DSTrace"] | ||
| from pydantic import BaseModel, Field | ||
|
|
||
| from rdagent.app.data_science.conf import DS_RD_SETTING | ||
Hoder-zyf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| from rdagent.components.coder.data_science.ensemble.exp import EnsembleTask | ||
| from rdagent.components.coder.data_science.feature.exp import FeatureTask | ||
| from rdagent.components.coder.data_science.model.exp import ModelTask | ||
| from rdagent.components.coder.data_science.pipeline.exp import PipelineTask | ||
| from rdagent.components.coder.data_science.raw_data_loader.exp import DataLoaderTask | ||
| from rdagent.components.coder.data_science.workflow.exp import WorkflowTask | ||
| from rdagent.core.proposal import ExpGen | ||
| from rdagent.core.scenario import Scenario | ||
| from rdagent.log import rdagent_logger as logger | ||
| from rdagent.oai.llm_utils import APIBackend, md5_hash | ||
| from rdagent.scenarios.data_science.experiment.experiment import DSExperiment | ||
| from rdagent.scenarios.data_science.proposal.exp_gen.base import DSHypothesis, DSTrace | ||
| from rdagent.scenarios.data_science.proposal.exp_gen.draft import DSDraftExpGen | ||
| from rdagent.scenarios.data_science.proposal.exp_gen.proposal import ( | ||
| DSProposalV1ExpGen, | ||
| DSProposalV2ExpGen, | ||
| ) | ||
| from rdagent.scenarios.data_science.proposal.exp_gen.refine import DSRefineExpGen | ||
| from rdagent.scenarios.data_science.scen import DataScienceScen | ||
| from rdagent.utils.agent.tpl import T | ||
|
|
||
| _COMPONENT_META: Dict[str, Dict[str, Any]] = { | ||
| "DataLoadSpec": { | ||
| "target_name": "Data loader and specification generation", | ||
| "spec_file": "spec/data_loader.md", | ||
| "output_format_key": ".prompts:output_format.data_loader", | ||
| "task_class": DataLoaderTask, | ||
| }, | ||
| "FeatureEng": { | ||
| "target_name": "Feature engineering", | ||
| "spec_file": "spec/feature.md", | ||
| "output_format_key": ".prompts:output_format.feature", | ||
| "task_class": FeatureTask, | ||
| }, | ||
| "Model": { | ||
| "target_name": "Model", | ||
| "spec_file": "spec/model.md", | ||
| "output_format_key": ".prompts:output_format.model", | ||
| "task_class": ModelTask, | ||
| }, | ||
| "Ensemble": { | ||
| "target_name": "Ensemble", | ||
| "spec_file": "spec/ensemble.md", | ||
| "output_format_key": ".prompts:output_format.ensemble", | ||
| "task_class": EnsembleTask, | ||
| }, | ||
| "Workflow": { | ||
| "target_name": "Workflow", | ||
| "spec_file": "spec/workflow.md", | ||
| "output_format_key": ".prompts:output_format.workflow", | ||
| "task_class": WorkflowTask, | ||
| }, | ||
| "Pipeline": { | ||
| "target_name": "Pipeline", | ||
| "spec_file": None, | ||
| "output_format_key": ".prompts:output_format.pipeline", | ||
| "task_class": PipelineTask, | ||
| }, | ||
| } | ||
|
|
||
|
|
||
| def get_component(name: str) -> Dict[str, Any]: | ||
| meta = _COMPONENT_META.get(name) | ||
| if meta is None: | ||
| raise KeyError(f"Unknown component: {name!r}") | ||
|
|
||
| return { | ||
| "target_name": meta["target_name"], | ||
| "spec_file": meta["spec_file"], | ||
| "task_output_format": T(meta["output_format_key"]).r(), | ||
| "task_class": meta["task_class"], | ||
| } | ||
|
|
||
|
|
||
| class CodingSketch(BaseModel): | ||
| current_state: str = Field( | ||
| description="A summary of the current `main.py` script that serves as the baseline for the planned changes. Focusing on parts that are related to the hypothesis. If `main.py` does not yet exist (i.e., it will be created from scratch based on this sketch), use the string 'N/A'." | ||
| ) | ||
| modifications: List[str] = Field( | ||
| description="A list of specific, targeted changes to be applied to the existing code identified in `current_state`. Each string in the list should concisely describe (in 3-4 sentences): " | ||
| "(a) the specific part of the code to be altered (e.g., a function name, a class, or a logical block); " | ||
| "(b) the nature of the modification (e.g., bug fix, feature addition, refactoring of a small section, performance optimization, deletion); and " | ||
| "(c) a brief explanation or high-level sketch of the new logic or change. " | ||
| "If no direct modifications to existing code are planned (e.g., if creating an entirely new `main.py` as detailed in `structure`), this list should be empty." | ||
| ) | ||
| structure: List[str] = Field( | ||
| description="An outline of the new high-level architectural components (primarily functions and classes) if a new `main.py` script is being created from scratch, or if the existing `main.py` is undergoing a major refactor that fundamentally alters or replaces its core structure. " | ||
| "Each string in the list should define a planned function or class, detailing its name, primary responsibility, key parameters (if applicable), return values (if applicable), and core functionality in 2-3 sentences. " | ||
| "This field is typically used when `current_state` is 'N/A' or when the scope of change requires a new architectural blueprint rather than just targeted `modifications`. " | ||
| "Leave empty if the plan only involves direct `modifications` to the existing structure in `current_state`." | ||
| ) | ||
| sketch: str = Field( | ||
| description="A detailed, step-by-step narrative that elaborates on how to implement the planned code. " | ||
| "This section should synthesize the information from `modifications` (if any) and/or `structure` (if any) into a comprehensive and actionable coding plan for `main.py`. " | ||
| "The content **must** be formatted using Markdown, with logical sections, key decision points, or implementation steps clearly organized by level-3 headings (i.e., `###`). " | ||
| "This field should provide sufficient detail for a developer to understand the implementation flow, algorithms, data handling, and key logic points without ambiguity." | ||
| ) | ||
|
|
||
|
|
||
| class DSExpGen(ExpGen): | ||
| """ | ||
| Data Science Task Generator. | ||
| This is a experiment router generator; | ||
| """ | ||
|
|
||
| def __init__(self, *args, **kwargs): | ||
| super().__init__(*args, **kwargs) | ||
|
|
||
| def gen(self, trace: DSTrace) -> DSExperiment: | ||
| pipeline = DS_RD_SETTING.coder_on_whole_pipeline | ||
|
|
||
| # Draft | ||
| # TODO: draft here | ||
|
|
||
| # Refine | ||
| last_exp_fb = trace.last_exp_fb() | ||
| if last_exp_fb.decision and last_exp_fb.refine_decision and pipeline: | ||
| return DSRefineExpGen(scen=self.scen).gen(trace=trace) | ||
|
|
||
| # Propose | ||
| if DS_RD_SETTING.proposal_version == "v1": | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hope to remove proposal_version in this version. |
||
| return DSProposalV1ExpGen(scen=self.scen).gen(trace=trace) | ||
| if DS_RD_SETTING.proposal_version == "v2": | ||
| return DSProposalV2ExpGen(scen=self.scen).gen(trace=trace) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.