diff --git a/rdagent/components/coder/model_coder/model.py b/rdagent/components/coder/model_coder/model.py index 75a7c66e..eeff3d7c 100644 --- a/rdagent/components/coder/model_coder/model.py +++ b/rdagent/components/coder/model_coder/model.py @@ -16,13 +16,14 @@ from rdagent.utils import get_module_by_module_path class ModelTask(Task): def __init__( - self, name: str, description: str, formulation: str, architecture: str, variables: Dict[str, str], model_type: Optional[str] = None + self, name: str, description: str, formulation: str, architecture: str, variables: Dict[str, str], hyperparameters: Dict[str, str], model_type: Optional[str] = None ) -> None: self.name: str = name self.description: str = description self.formulation: str = formulation self.architecture: str = architecture self.variables: str = variables + self.hyperparameters: str = hyperparameters self.model_type: str = model_type # Tabular for tabular model, TimesSeries for time series model, Graph for graph model def get_task_information(self): @@ -31,6 +32,7 @@ description: {self.description} formulation: {self.formulation} architecture: {self.architecture} variables: {self.variables} +hyperparameters: {self.hyperparameters} model_type: {self.model_type} """ diff --git a/rdagent/components/coder/model_coder/prompts.yaml b/rdagent/components/coder/model_coder/prompts.yaml index 107c4189..b5f069a7 100644 --- a/rdagent/components/coder/model_coder/prompts.yaml +++ b/rdagent/components/coder/model_coder/prompts.yaml @@ -1,23 +1,41 @@ extract_model_formulation_system: |- offer description of the proposed model in this paper, write a latex formula with variable as well as the architecture of the model. the format should be like - "Model Name (replace with a reasonable model type)": { - "description": "", - "formulation": "", - "architecture": "", + { + "model_name (The name of the model)": { + "description": "A detailed description of the model", + "formulation": "A LaTeX formula representing the model's formulation", + "architecture": "A detailed description of the model's architecture, e.g., neural network layers or tree structures", "variables": { - "\\hat{y}_u": "The predicted output for node u", - }" - "model_type":"Tabular", "TimeSeries", or "Graph", (depending on which type of the model it is) - } + "\\hat{y}_u": "The predicted output for node u", + "variable_name_2": "Description of variable 2", + "variable_name_3": "Description of variable 3" + }, + "hyperparameters": { + "hyperparameter_name_1": "value of hyperparameter 1", + "hyperparameter_name_2": "value of hyperparameter 2", + "hyperparameter_name_3": "value of hyperparameter 3" + }, + "model_type": "Tabular or TimeSeries or Graph" # Should be one of "Tabular", "TimeSeries", or "Graph" + } + } Eg. - "ABC Model":{ - "description": "", - "formulation": "", - "architecture": "", + { + "ABC Model": { + "description": "A detailed description of the model", + "formulation": "A LaTeX formula representing the model's formulation", + "architecture": "A detailed description of the model's architecture, e.g., neural network layers or tree structures", "variables": { - "\\hat{y}_u": "The predicted output for node u", - }" - "model_type":"Tabular", + "\\hat{y}_u": "The predicted output for node u", + "variable_name_2": "Description of variable 2", + "variable_name_3": "Description of variable 3" + }, + "hyperparameters": { + "hyperparameter_name_1": "value of hyperparameter 1", + "hyperparameter_name_2": "value of hyperparameter 2", + "hyperparameter_name_3": "value of hyperparameter 3" + }, + "model_type": "Tabular or TimeSeries or Graph" # Should be one of "Tabular", "TimeSeries", or "Graph" + } } such format content should be begin with ```json and end with ``` and the content should be in json format. diff --git a/rdagent/core/proposal.py b/rdagent/core/proposal.py index 5f32efc0..878903c5 100644 --- a/rdagent/core/proposal.py +++ b/rdagent/core/proposal.py @@ -22,9 +22,10 @@ class Hypothesis: - Belief """ - def __init__(self, hypothesis: str, reason: str) -> None: + def __init__(self, hypothesis: str, reason: str, concise_reason = str) -> None: self.hypothesis: str = hypothesis self.reason: str = reason + self.concise_reason: str = concise_reason def __str__(self) -> str: return f"""Hypothesis: {self.hypothesis} diff --git a/rdagent/scenarios/qlib/prompts.yaml b/rdagent/scenarios/qlib/prompts.yaml index 24e8fc6d..8b88c5e2 100644 --- a/rdagent/scenarios/qlib/prompts.yaml +++ b/rdagent/scenarios/qlib/prompts.yaml @@ -12,7 +12,8 @@ hypothesis_output_format: |- The output should follow JSON format. The schema is as follows: { "hypothesis": "The new hypothesis generated based on the information provided.", - "reason": "The reason why you generate this hypothesis." + "reason": "The reason why you generate this hypothesis.", + "concise_reason": One line summary that focuses on the justification for the change that leads to the hypothesis (like a part of a knowledge that we are building), } model_hypothesis_specification: |- @@ -85,13 +86,19 @@ model_experiment_output_format: |- { "model_name (The name of the model)": { "description": "A detailed description of the model", + "formulation": "A LaTeX formula representing the model's formulation", "architecture": "A detailed description of the model's architecture, e.g., neural network layers or tree structures", + "variables": { + "\\hat{y}_u": "The predicted output for node u", + "variable_name_2": "Description of variable 2", + "variable_name_3": "Description of variable 3" + }, "hyperparameters": { "hyperparameter_name_1": "value of hyperparameter 1", "hyperparameter_name_2": "value of hyperparameter 2", "hyperparameter_name_3": "value of hyperparameter 3" }, - "model_type": "Tabular or TimeSeries" # Should be one of "Tabular" or "TimeSeries" + "model_type": "Tabular or TimeSeries # Should be one of "Tabular" or "TimeSeries" } } Usually a larger model works better than a smaller one. Hence, the parameters should be larger. diff --git a/rdagent/scenarios/qlib/proposal/model_proposal.py b/rdagent/scenarios/qlib/proposal/model_proposal.py index 1eac990c..fb2bcefa 100644 --- a/rdagent/scenarios/qlib/proposal/model_proposal.py +++ b/rdagent/scenarios/qlib/proposal/model_proposal.py @@ -39,7 +39,7 @@ class QlibModelHypothesisGen(ModelHypothesisGen): def convert_response(self, response: str) -> ModelHypothesis: response_dict = json.loads(response) - hypothesis = QlibModelHypothesis(hypothesis=response_dict["hypothesis"], reason=response_dict["reason"]) + hypothesis = QlibModelHypothesis(hypothesis=response_dict["hypothesis"], reason=response_dict["reason"], concise_reason=response_dict["concise_reason"]) return hypothesis @@ -74,10 +74,12 @@ class QlibModelHypothesis2Experiment(ModelHypothesis2Experiment): tasks = [] for model_name in response_dict: description = response_dict[model_name]["description"] + formulation = response_dict[model_name]["formulation"] architecture = response_dict[model_name]["architecture"] + variables = response_dict[model_name]["variables"] hyperparameters = response_dict[model_name]["hyperparameters"] model_type = response_dict[model_name]["model_type"] - tasks.append(ModelTask(model_name, description, architecture, hyperparameters, model_type)) + tasks.append(ModelTask(model_name, description, formulation, architecture, variables, hyperparameters, model_type)) exp = QlibModelExperiment(tasks) exp.based_experiments = [t[1] for t in trace.hist if t[2]] return exp