From 4d74cc38ce508a97b44ebf507d6bf4403ef1ad77 Mon Sep 17 00:00:00 2001 From: Xu Yang Date: Wed, 22 Jan 2025 12:15:20 +0800 Subject: [PATCH] add former task to exp_gen (#527) --- rdagent/scenarios/data_science/proposal/exp_gen.py | 8 ++++++++ rdagent/scenarios/data_science/proposal/prompts.yaml | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/rdagent/scenarios/data_science/proposal/exp_gen.py b/rdagent/scenarios/data_science/proposal/exp_gen.py index 59d9c4d6..2c1e09df 100644 --- a/rdagent/scenarios/data_science/proposal/exp_gen.py +++ b/rdagent/scenarios/data_science/proposal/exp_gen.py @@ -150,6 +150,7 @@ class DSExpGen(ExpGen): spec: str = None, hypothesis: Hypothesis | None = None, exp_and_feedback_desc: str | None = None, + former_task: str | None = None, ) -> dict: system_prompt = T(".prompts:task_gen.system").r( targets=targets, @@ -163,6 +164,7 @@ class DSExpGen(ExpGen): hypothesis=hypothesis, workspace_code=workspace_code, exp_and_feedback_desc=exp_and_feedback_desc, + former_task_desc=former_task, ) resp_dict = json.loads( @@ -192,11 +194,17 @@ class DSExpGen(ExpGen): last_successful_exp: Last successful experiment or None spec_file: Path to specification file if needed """ + former_task_desc = ( + trace.hist[-1][0].pending_tasks_list[0][0].get_task_information() + if len(trace.hist) > 0 and trace.hist[-1] is not last_successful_exp + else None + ) resp_dict = self._init_task_gen( targets=component, scenario_desc=scenario_desc, spec=last_successful_exp.experiment_workspace.file_dict[spec_file] if spec_file else None, task_output_format=T(f".prompts:output_format.{component_prompt_key or component.lower()}").r(), + former_task=former_task_desc, ) # Create task instance diff --git a/rdagent/scenarios/data_science/proposal/prompts.yaml b/rdagent/scenarios/data_science/proposal/prompts.yaml index 03989e6d..d89f74a4 100644 --- a/rdagent/scenarios/data_science/proposal/prompts.yaml +++ b/rdagent/scenarios/data_science/proposal/prompts.yaml @@ -101,6 +101,12 @@ task_gen: # It is deprecated now, please refer to direct_exp_gen {{workspace_code}} {% endif %} + {% if former_task_desc is not none %} + The user has made several task on this scenario but didn't get the expected result due to wrong implementation or just bad luck. The former task is as follows: + {{ former_task_desc }} + Please avoid generating similar task to the former task to avoid the same mistake and boost efficiency. + {% endif %} + {% if hypothesis is not none %} The user has made several hypothesis on this scenario and did several evaluation on them. The target hypothesis you are targeting to generate {{ targets }} for is as follows: