mirror of
https://github.com/NicolasBohn/NexQuant.git
synced 2026-08-08 20:47:44 +00:00
feat: Added QlibFactorFromReportScenario and improved the report-factor loop. (#161)
* Optimize factor hypothesis prompt * Optimize the factor feedback prompt. * Improve the prompts in feedback(factor). * change some prompts * Added QlibFactorFromReportScenario and improved the report-factor loop. * reformat * reformat * reformat * reformat
This commit is contained in:
@@ -35,11 +35,17 @@ class FactorBasePropSetting(BasePropSetting):
|
||||
# 2) sub task specific:
|
||||
origin_report_path: str = "data/report_origin"
|
||||
local_report_path: str = "data/report"
|
||||
report_result_json_file_path: str = "git_ignore_folder/report_list.json"
|
||||
report_result_json_file_path: str = "git_ignore_folder/report_list_new.json"
|
||||
progress_file_path: str = "git_ignore_folder/progress.pkl"
|
||||
report_extract_result: str = "git_ignore_folder/hypo_exp_cache.pkl"
|
||||
max_factor_per_report: int = 10000
|
||||
|
||||
|
||||
class FactorFromReportPropSetting(FactorBasePropSetting):
|
||||
# Override the scen attribute
|
||||
scen: str = "rdagent.scenarios.qlib.experiment.factor_from_report_experiment.QlibFactorFromReportScenario"
|
||||
|
||||
|
||||
FACTOR_PROP_SETTING = FactorBasePropSetting()
|
||||
FACTOR_FROM_REPORT_PROP_SETTING = FactorFromReportPropSetting()
|
||||
MODEL_PROP_SETTING = ModelBasePropSetting()
|
||||
|
||||
@@ -6,7 +6,7 @@ from typing import Any, Tuple
|
||||
import fire
|
||||
from jinja2 import Environment, StrictUndefined
|
||||
|
||||
from rdagent.app.qlib_rd_loop.conf import FACTOR_PROP_SETTING
|
||||
from rdagent.app.qlib_rd_loop.conf import FACTOR_FROM_REPORT_PROP_SETTING
|
||||
from rdagent.components.document_reader.document_reader import (
|
||||
extract_first_page_screenshot_from_pdf,
|
||||
load_and_process_pdfs_by_langchain,
|
||||
@@ -20,9 +20,9 @@ from rdagent.core.scenario import Scenario
|
||||
from rdagent.core.utils import import_class
|
||||
from rdagent.log import rdagent_logger as logger
|
||||
from rdagent.oai.llm_utils import APIBackend
|
||||
from rdagent.scenarios.qlib.experiment.factor_experiment import (
|
||||
QlibFactorExperiment,
|
||||
QlibFactorScenario,
|
||||
from rdagent.scenarios.qlib.experiment.factor_experiment import QlibFactorExperiment
|
||||
from rdagent.scenarios.qlib.experiment.factor_from_report_experiment import (
|
||||
QlibFactorFromReportScenario,
|
||||
)
|
||||
from rdagent.scenarios.qlib.factor_experiment_loader.pdf_loader import (
|
||||
FactorExperimentLoaderFromPDFfiles,
|
||||
@@ -62,7 +62,7 @@ def generate_hypothesis(factor_result: dict, report_content: str) -> str:
|
||||
|
||||
|
||||
def extract_hypothesis_and_exp_from_reports(report_file_path: str) -> Tuple[QlibFactorExperiment, Hypothesis]:
|
||||
scenario = QlibFactorScenario()
|
||||
scenario = QlibFactorFromReportScenario()
|
||||
|
||||
with logger.tag("extract_factors_and_implement"):
|
||||
with logger.tag("load_factor_tasks"):
|
||||
@@ -104,7 +104,7 @@ class FactorReportLoop(LoopBase, metaclass=LoopMeta):
|
||||
self.summarizer: HypothesisExperiment2Feedback = import_class(PROP_SETTING.summarizer)(scen)
|
||||
self.trace = Trace(scen=scen)
|
||||
|
||||
self.judge_pdf_data_items = json.load(open(FACTOR_PROP_SETTING.report_result_json_file_path, "r"))
|
||||
self.judge_pdf_data_items = json.load(open(FACTOR_FROM_REPORT_PROP_SETTING.report_result_json_file_path, "r"))
|
||||
self.pdf_file_index = 0
|
||||
super().__init__()
|
||||
|
||||
@@ -120,8 +120,8 @@ class FactorReportLoop(LoopBase, metaclass=LoopMeta):
|
||||
if exp is None:
|
||||
continue
|
||||
exp.based_experiments = [QlibFactorExperiment(sub_tasks=[])] + [t[1] for t in self.trace.hist if t[2]]
|
||||
exp.sub_workspace_list = exp.sub_workspace_list[: FACTOR_PROP_SETTING.max_factor_per_report]
|
||||
exp.sub_tasks = exp.sub_tasks[: FACTOR_PROP_SETTING.max_factor_per_report]
|
||||
exp.sub_workspace_list = exp.sub_workspace_list[: FACTOR_FROM_REPORT_PROP_SETTING.max_factor_per_report]
|
||||
exp.sub_tasks = exp.sub_tasks[: FACTOR_FROM_REPORT_PROP_SETTING.max_factor_per_report]
|
||||
logger.log_object(hypothesis, tag="hypothesis generation")
|
||||
logger.log_object(exp.sub_tasks, tag="experiment generation")
|
||||
return hypothesis, exp
|
||||
@@ -158,7 +158,7 @@ def main(path=None, step_n=None):
|
||||
|
||||
"""
|
||||
if path is None:
|
||||
model_loop = FactorReportLoop(FACTOR_PROP_SETTING)
|
||||
model_loop = FactorReportLoop(FACTOR_FROM_REPORT_PROP_SETTING)
|
||||
else:
|
||||
model_loop = FactorReportLoop.load(path)
|
||||
model_loop.run(step_n=step_n)
|
||||
|
||||
Reference in New Issue
Block a user