@@ -717,33 +717,33 @@ def hypothesis_rank(
717
717
problem_desc = problem_dict .get ("problem" , "Problem description not provided" ),
718
718
problem_label = problem_dict .get ("label" , "FEEDBACK_PROBLEM" ),
719
719
)
720
-
721
- def hypothesis_select_with_llm (self ,
722
- scenario_desc : str ,
723
- exp_feedback_list_desc : str ,
724
- sota_exp_desc : str ,
725
- hypothesis_candidates :dict ):
726
-
720
+
721
+ def hypothesis_select_with_llm (
722
+ self , scenario_desc : str , exp_feedback_list_desc : str , sota_exp_desc : str , hypothesis_candidates : dict
723
+ ):
724
+
727
725
# time_use_current = 0
728
726
# for exp, feedback in trace.hist:
729
727
# if exp.running_info.running_time is not None:
730
728
# time_use_current += exp.running_info.running_time
731
729
# res_time = 12*3600 - time_use_current
732
730
res_time = RD_Agent_TIMER_wrapper .timer .remain_time ()
733
731
total_time = RD_Agent_TIMER_wrapper .timer .all_duration
734
- use_time = round (total_time .total_seconds (),2 ) - round (res_time .total_seconds (),2 )
735
- use_ratio = 100 * use_time / round (total_time .total_seconds (),2 )
732
+ use_time = round (total_time .total_seconds (), 2 ) - round (res_time .total_seconds (), 2 )
733
+ use_ratio = 100 * use_time / round (total_time .total_seconds (), 2 )
736
734
use_ratio = round (use_ratio , 2 )
737
735
738
736
ensemble_timeout = DS_RD_SETTING .ensemble_timeout
739
- hypothesis_candidates = str (json .dumps (hypothesis_candidates , indent = 2 ))
737
+ hypothesis_candidates = str (json .dumps (hypothesis_candidates , indent = 2 ))
740
738
741
739
sys_prompt = T (".prompts_v2:hypothesis_select.system" ).r (
742
- hypothesis_candidates = hypothesis_candidates ,
743
- res_time = round (res_time .total_seconds (),2 ),
744
- ensemble_timeout = ensemble_timeout ,
745
- use_ratio = use_ratio ,
746
- hypothesis_output_format = T (".prompts_v2:output_format.hypothesis_select_format" ).r (hypothesis_candidates = hypothesis_candidates )
740
+ hypothesis_candidates = hypothesis_candidates ,
741
+ res_time = round (res_time .total_seconds (), 2 ),
742
+ ensemble_timeout = ensemble_timeout ,
743
+ use_ratio = use_ratio ,
744
+ hypothesis_output_format = T (".prompts_v2:output_format.hypothesis_select_format" ).r (
745
+ hypothesis_candidates = hypothesis_candidates
746
+ ),
747
747
)
748
748
749
749
user_prompt = T (".prompts_v2:hypothesis_select.user" ).r (
@@ -755,12 +755,15 @@ def hypothesis_select_with_llm(self,
755
755
response = APIBackend ().build_messages_and_create_chat_completion (
756
756
user_prompt = user_prompt ,
757
757
system_prompt = sys_prompt ,
758
+ response_format = HypothesisList if self .supports_response_schema else {"type" : "json_object" },
759
+ json_target_type = (
760
+ Dict [str , Dict [str , str | Dict [str , str | int ]]] if not self .supports_response_schema else None
761
+ ),
758
762
)
759
763
760
764
response_dict = json .loads (response )
761
765
return response_dict
762
766
763
-
764
767
def task_gen (
765
768
self ,
766
769
component_desc : str ,
@@ -846,7 +849,7 @@ def get_scenario_all_desc(self, trace: DSTrace, eda_output=None) -> str:
846
849
raw_description = trace .scen .raw_description ,
847
850
use_raw_description = DS_RD_SETTING .use_raw_description ,
848
851
time_limit = f"{ DS_RD_SETTING .full_timeout / 60 / 60 : .2f} hours" ,
849
- ensemble_limit = f"{ DS_RD_SETTING .ensemble_timeout / 60 / 60 : .2f} hours" ,
852
+ ensemble_limit = f"{ DS_RD_SETTING .ensemble_timeout / 60 / 60 : .2f} hours" ,
850
853
eda_output = eda_output ,
851
854
)
852
855
@@ -868,7 +871,7 @@ def get_all_hypotheses(self, problem_dict: dict, hypothesis_dict: dict) -> list[
868
871
869
872
def gen (
870
873
self ,
871
- trace : DSTrace ,
874
+ trace : DSTrace ,
872
875
) -> DSExperiment :
873
876
pipeline = DS_RD_SETTING .coder_on_whole_pipeline
874
877
if not pipeline and (draft_exp := draft_exp_in_decomposition (self .scen , trace )):
@@ -973,11 +976,12 @@ def gen(
973
976
# problem_dict= all_problems,
974
977
# )
975
978
976
- response_dict = self .hypothesis_select_with_llm (scenario_desc = scenario_desc ,
977
- exp_feedback_list_desc = exp_feedback_list_desc ,
978
- sota_exp_desc = sota_exp_desc ,
979
- hypothesis_candidates = hypothesis_dict
980
- )
979
+ response_dict = self .hypothesis_select_with_llm (
980
+ scenario_desc = scenario_desc ,
981
+ exp_feedback_list_desc = exp_feedback_list_desc ,
982
+ sota_exp_desc = sota_exp_desc ,
983
+ hypothesis_candidates = hypothesis_dict ,
984
+ )
981
985
component_map = {
982
986
"Model" : HypothesisComponent .Model ,
983
987
"Ensemble" : HypothesisComponent .Ensemble ,
@@ -992,7 +996,7 @@ def gen(
992
996
if comp_str in component_map and hypo_str is not None :
993
997
new_hypothesis = DSHypothesis (component = component_map [comp_str ], hypothesis = hypo_str )
994
998
995
- pickled_problem_name = None
999
+ pickled_problem_name = None
996
1000
# Step 3.5: Update knowledge base with the picked problem
997
1001
if DS_RD_SETTING .enable_knowledge_base :
998
1002
trace .knowledge_base .update_pickled_problem (all_problems , pickled_problem_name )
0 commit comments