mirror of
https://github.com/NicolasBohn/NexQuant.git
synced 2026-08-09 21:10:56 +00:00
refine core to store experiment results and hypothesis feedback (#55)
* Update proposal.py Completed The HypothesisFeedback Class. * refine the core code --------- Co-authored-by: xuyang1 <xuyang1@microsoft.com>
This commit is contained in:
@@ -4,12 +4,22 @@ from pydantic_settings import BaseSettings
|
||||
class PropSetting(BaseSettings):
|
||||
""""""
|
||||
|
||||
scen: str = "rdagent.scenarios.qlib.experiment.factor_experiment.QlibFactorScenario"
|
||||
hypothesis_gen: str = "rdagent.scenarios.qlib.factor_proposal.QlibFactorHypothesisGen"
|
||||
hypothesis2experiment: str = "rdagent.scenarios.qlib.factor_proposal.QlibFactorHypothesis2Experiment"
|
||||
qlib_factor_scen: str = "rdagent.scenarios.qlib.experiment.factor_experiment.QlibFactorScenario"
|
||||
qlib_factor_hypothesis_gen: str = "rdagent.scenarios.qlib.factor_proposal.QlibFactorHypothesisGen"
|
||||
qlib_factor_hypothesis2experiment: str = "rdagent.scenarios.qlib.factor_proposal.QlibFactorHypothesis2Experiment"
|
||||
qlib_factor_coder: str = "rdagent.scenarios.qlib.factor_task_implementation.QlibFactorCoSTEER"
|
||||
qlib_factor_runner: str = "rdagent.scenarios.qlib.task_generator.data.QlibFactorRunner"
|
||||
qlib_factor_summarizer: str = "rdagent.scenarios.qlib.task_generator.feedback.QlibFactorExperiment2Feedback"
|
||||
qlib_factor_summarizer: str = (
|
||||
"rdagent.scenarios.qlib.task_generator.feedback.QlibFactorHypothesisExperiment2Feedback"
|
||||
)
|
||||
|
||||
# TODO: model part is not finished yet
|
||||
qlib_model_scen: str = ""
|
||||
qlib_model_hypothesis_gen: str = ""
|
||||
qlib_model_hypothesis2experiment: str = ""
|
||||
qlib_model_coder: str = ""
|
||||
qlib_model_runner: str = ""
|
||||
qlib_model_summarizer: str = ""
|
||||
|
||||
evolving_n: int = 10
|
||||
|
||||
|
||||
@@ -6,37 +6,34 @@ from dotenv import load_dotenv
|
||||
|
||||
load_dotenv(override=True)
|
||||
|
||||
# import_from
|
||||
from rdagent.app.qlib_rd_loop.conf import PROP_SETTING
|
||||
from rdagent.core.proposal import (
|
||||
Experiment2Feedback,
|
||||
Hypothesis2Experiment,
|
||||
HypothesisExperiment2Feedback,
|
||||
HypothesisGen,
|
||||
HypothesisSet,
|
||||
Trace,
|
||||
)
|
||||
from rdagent.core.task_generator import TaskGenerator
|
||||
from rdagent.core.utils import import_class
|
||||
|
||||
scen = import_class(PROP_SETTING.scen)()
|
||||
scen = import_class(PROP_SETTING.qlib_factor_scen)()
|
||||
|
||||
hypothesis_gen: HypothesisGen = import_class(PROP_SETTING.hypothesis_gen)(scen)
|
||||
hypothesis_gen: HypothesisGen = import_class(PROP_SETTING.qlib_factor_hypothesis_gen)(scen)
|
||||
|
||||
hypothesis2experiment: Hypothesis2Experiment = import_class(PROP_SETTING.hypothesis2experiment)()
|
||||
hypothesis2experiment: Hypothesis2Experiment = import_class(PROP_SETTING.qlib_factor_hypothesis2experiment)()
|
||||
|
||||
qlib_factor_coder: TaskGenerator = import_class(PROP_SETTING.qlib_factor_coder)(scen)
|
||||
qlib_factor_runner: TaskGenerator = import_class(PROP_SETTING.qlib_factor_runner)(scen)
|
||||
|
||||
qlib_factor_summarizer: Experiment2Feedback = import_class(PROP_SETTING.qlib_factor_summarizer)()
|
||||
qlib_factor_summarizer: HypothesisExperiment2Feedback = import_class(PROP_SETTING.qlib_factor_summarizer)()
|
||||
|
||||
|
||||
trace = Trace(scen=scen)
|
||||
hs = HypothesisSet(trace=trace)
|
||||
for _ in range(PROP_SETTING.evolving_n):
|
||||
hypothesis = hypothesis_gen.gen(trace)
|
||||
exp = hypothesis2experiment.convert(hs)
|
||||
exp = hypothesis2experiment.convert(hypothesis, trace)
|
||||
exp = qlib_factor_coder.generate(exp)
|
||||
exp = qlib_factor_runner.generate(exp)
|
||||
feedback = qlib_factor_summarizer.summarize(exp)
|
||||
feedback = qlib_factor_summarizer.generateFeedback(exp, hypothesis, trace)
|
||||
|
||||
trace.hist.append((hypothesis, exp, feedback))
|
||||
|
||||
@@ -4,39 +4,33 @@ TODO: move the following code to a new class: Model_RD_Agent
|
||||
"""
|
||||
|
||||
# import_from
|
||||
from rdagent.app.model_proposal.conf import MODEL_PROP_SETTING
|
||||
|
||||
from rdagent.app.qlib_rd_loop.conf import PROP_SETTING
|
||||
from rdagent.core.proposal import (
|
||||
Experiment2Feedback,
|
||||
Hypothesis2Experiment,
|
||||
HypothesisSet,
|
||||
HypothesisExperiment2Feedback,
|
||||
Trace,
|
||||
)
|
||||
from rdagent.core.task_generator import TaskGenerator
|
||||
from rdagent.core.utils import import_class
|
||||
|
||||
# load_from_cls_uri
|
||||
scen = import_class(PROP_SETTING.qlib_model_scen)()
|
||||
|
||||
hypothesis_gen = import_class(PROP_SETTING.qlib_model_hypothesis_gen)(scen)
|
||||
|
||||
scen = load_from_cls_uri(MODEL_PROP_SETTING.scen)()
|
||||
hypothesis2experiment: Hypothesis2Experiment = import_class(PROP_SETTING.qlib_model_hypothesis2experiment)()
|
||||
|
||||
hypothesis_gen = load_from_cls_uri(MODEL_PROP_SETTING.hypothesis_gen)(scen)
|
||||
qlib_model_coder: TaskGenerator = import_class(PROP_SETTING.qlib_model_coder)(scen)
|
||||
qlib_model_runner: TaskGenerator = import_class(PROP_SETTING.qlib_model_runner)(scen)
|
||||
|
||||
hypothesis2task: Hypothesis2Experiment = load_from_cls_uri(MODEL_PROP_SETTING.hypothesis2task)()
|
||||
qlib_model_summarizer: HypothesisExperiment2Feedback = import_class(PROP_SETTING.qlib_model_hypothesis2experiment)(scen)
|
||||
|
||||
task_gen: TaskGenerator = load_from_cls_uri(MODEL_PROP_SETTING.task_gen)(scen) # for implementation
|
||||
|
||||
imp2feedback: Experiment2Feedback = load_from_cls_uri(MODEL_PROP_SETTING.imp2feedback)(scen) # for implementation
|
||||
|
||||
|
||||
iter_n = MODEL_PROP_SETTING.iter_n
|
||||
|
||||
trace = Trace()
|
||||
|
||||
hypothesis_set = HypothesisSet()
|
||||
for _ in range(iter_n):
|
||||
trace = Trace(scen=scen)
|
||||
for _ in range(PROP_SETTING.evolving_n):
|
||||
hypothesis = hypothesis_gen.gen(trace)
|
||||
task = hypothesis2task.convert(hypothesis)
|
||||
imp = task_gen.gen(task)
|
||||
imp.execute()
|
||||
feedback = imp2feedback.summarize(imp)
|
||||
trace.hist.append((hypothesis, feedback))
|
||||
exp = hypothesis2experiment.convert(hypothesis, trace)
|
||||
exp = qlib_model_coder.generate(exp)
|
||||
exp = qlib_model_runner.generate(exp)
|
||||
feedback = qlib_model_summarizer.generateFeedback(exp, hypothesis, trace)
|
||||
|
||||
trace.hist.append((hypothesis, exp, feedback))
|
||||
|
||||
Reference in New Issue
Block a user