Skip to content

Commit 5e14fa5

Browse files
authored
fix: Add framework handling for task coding failure. (#176)
* Add framework handling for task coding failure. * fix a ci bug
1 parent 16fc6eb commit 5e14fa5

File tree

4 files changed

+28
-2
lines changed

4 files changed

+28
-2
lines changed

rdagent/components/coder/factor_coder/CoSTEER/evaluators.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,10 @@ def evaluate(
671671
]
672672
logger.info(f"Final decisions: {final_decision} True count: {final_decision.count(True)}")
673673

674+
for index in range(len(evo.sub_tasks)):
675+
if final_decision[index]:
676+
evo.sub_tasks[index].factor_implementation = True
677+
674678
return multi_implementation_feedback
675679

676680

rdagent/components/coder/factor_coder/factor.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,30 @@ def __init__(
2626
factor_formulation,
2727
variables: dict = {},
2828
resource: str = None,
29+
factor_implementation: bool = False,
2930
) -> None:
3031
self.factor_name = factor_name
3132
self.factor_description = factor_description
3233
self.factor_formulation = factor_formulation
3334
self.variables = variables
3435
self.factor_resources = resource
36+
self.factor_implementation = factor_implementation
3537

3638
def get_task_information(self):
3739
return f"""factor_name: {self.factor_name}
3840
factor_description: {self.factor_description}
3941
factor_formulation: {self.factor_formulation}
4042
variables: {str(self.variables)}"""
4143

44+
def get_task_information_and_implementation_result(self):
45+
return {
46+
"factor_name": self.factor_name,
47+
"factor_description": self.factor_description,
48+
"factor_formulation": self.factor_formulation,
49+
"variables": str(self.variables),
50+
"factor_implementation": str(self.factor_implementation),
51+
}
52+
4253
@staticmethod
4354
def from_dict(dict):
4455
return FactorTask(**dict)

rdagent/scenarios/qlib/developer/feedback.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def generate_feedback(self, exp: Experiment, hypothesis: Hypothesis, trace: Trac
7272
logger.info("Generating feedback...")
7373
hypothesis_text = hypothesis.hypothesis
7474
current_result = exp.result
75-
tasks_factors = [task.get_task_information() for task in exp.sub_tasks]
75+
tasks_factors = [task.get_task_information_and_implementation_result() for task in exp.sub_tasks]
7676
sota_result = exp.based_experiments[-1].result
7777

7878
# Process the results to filter important metrics

rdagent/scenarios/qlib/prompts.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,18 @@ factor_feedback_generation:
172172
Target hypothesis:
173173
{{ hypothesis_text }}
174174
Tasks and Factors:
175-
{{ task_details }}
175+
{% for task in task_details %}
176+
- {{ task.factor_name }}: {{ task.factor_description }}
177+
- Factor Formulation: {{ task.factor_formulation }}
178+
- Variables: {{ task.variables }}
179+
- Factor Implementation: {{ task.factor_implementation }}
180+
{% if task.factor_implementation == "False" %}
181+
**Note: This factor was not implemented in the current experiment. Only the hypothesis for implemented factors can be verified.**
182+
{% endif %}
183+
{% endfor %}
176184
Combined Results:
177185
{{ combined_result }}
186+
178187
Analyze the combined result in the context of its ability to:
179188
1. Support or refute the hypothesis.
180189
2. Show improvement or deterioration compared to the SOTA experiment.
@@ -197,6 +206,8 @@ factor_feedback_generation:
197206
- If the new results significantly differ from the SOTA, consider exploring a new direction.
198207
- Avoid re-implementing previous factors as those that surpassed SOTA are already included in the factor library and will be used in each run.
199208
209+
Note: Only factors with 'Factor Implementation' as True are implemented and tested in this experiment. If 'Factor Implementation' is False, the hypothesis for that factor cannot be verified in this run.
210+
200211
model_feedback_generation:
201212
system: |-
202213
You are a professional result analysis assistant. You will receive a result and a hypothesis.

0 commit comments

Comments
 (0)