Skip to content

Commit b771201

Browse files
authored
add former task to exp_gen (microsoft#527)
1 parent 845b675 commit b771201

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

rdagent/scenarios/data_science/proposal/exp_gen.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ def _init_task_gen(
150150
spec: str = None,
151151
hypothesis: Hypothesis | None = None,
152152
exp_and_feedback_desc: str | None = None,
153+
former_task: str | None = None,
153154
) -> dict:
154155
system_prompt = T(".prompts:task_gen.system").r(
155156
targets=targets,
@@ -163,6 +164,7 @@ def _init_task_gen(
163164
hypothesis=hypothesis,
164165
workspace_code=workspace_code,
165166
exp_and_feedback_desc=exp_and_feedback_desc,
167+
former_task_desc=former_task,
166168
)
167169

168170
resp_dict = json.loads(
@@ -192,11 +194,17 @@ def _handle_missing_component(
192194
last_successful_exp: Last successful experiment or None
193195
spec_file: Path to specification file if needed
194196
"""
197+
former_task_desc = (
198+
trace.hist[-1][0].pending_tasks_list[0][0].get_task_information()
199+
if len(trace.hist) > 0 and trace.hist[-1] is not last_successful_exp
200+
else None
201+
)
195202
resp_dict = self._init_task_gen(
196203
targets=component,
197204
scenario_desc=scenario_desc,
198205
spec=last_successful_exp.experiment_workspace.file_dict[spec_file] if spec_file else None,
199206
task_output_format=T(f".prompts:output_format.{component_prompt_key or component.lower()}").r(),
207+
former_task=former_task_desc,
200208
)
201209

202210
# Create task instance

rdagent/scenarios/data_science/proposal/prompts.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ task_gen: # It is deprecated now, please refer to direct_exp_gen
101101
{{workspace_code}}
102102
{% endif %}
103103
104+
{% if former_task_desc is not none %}
105+
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:
106+
{{ former_task_desc }}
107+
Please avoid generating similar task to the former task to avoid the same mistake and boost efficiency.
108+
{% endif %}
109+
104110
{% if hypothesis is not none %}
105111
The user has made several hypothesis on this scenario and did several evaluation on them.
106112
The target hypothesis you are targeting to generate {{ targets }} for is as follows:

0 commit comments

Comments
 (0)