mirror of
https://github.com/NicolasBohn/NexQuant.git
synced 2026-08-07 20:17:45 +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:
@@ -10,7 +10,6 @@ from rdagent.core.proposal import (
|
||||
Hypothesis,
|
||||
Hypothesis2Experiment,
|
||||
HypothesisGen,
|
||||
HypothesisSet,
|
||||
Scenario,
|
||||
Trace,
|
||||
)
|
||||
@@ -28,12 +27,10 @@ class FactorHypothesisGen(HypothesisGen):
|
||||
|
||||
# The following methods are scenario related so they should be implemented in the subclass
|
||||
@abstractmethod
|
||||
def prepare_context(self, trace: Trace) -> Tuple[dict, bool]:
|
||||
...
|
||||
def prepare_context(self, trace: Trace) -> Tuple[dict, bool]: ...
|
||||
|
||||
@abstractmethod
|
||||
def convert_response(self, response: str) -> FactorHypothesis:
|
||||
...
|
||||
def convert_response(self, response: str) -> FactorHypothesis: ...
|
||||
|
||||
def gen(self, trace: Trace) -> FactorHypothesis:
|
||||
context_dict, json_flag = self.prepare_context(trace)
|
||||
@@ -67,20 +64,18 @@ class FactorHypothesis2Experiment(Hypothesis2Experiment[FactorExperiment]):
|
||||
super().__init__()
|
||||
|
||||
@abstractmethod
|
||||
def prepare_context(self, hs: HypothesisSet) -> Tuple[dict, bool]:
|
||||
...
|
||||
def prepare_context(self, hypothesis: Hypothesis, trace: Trace) -> Tuple[dict, bool]: ...
|
||||
|
||||
@abstractmethod
|
||||
def convert_response(self, response: str) -> FactorExperiment:
|
||||
...
|
||||
def convert_response(self, response: str, trace: Trace) -> FactorExperiment: ...
|
||||
|
||||
def convert(self, hs: HypothesisSet) -> FactorExperiment:
|
||||
context, json_flag = self.prepare_context(hs)
|
||||
def convert(self, hypothesis: Hypothesis, trace: Trace) -> FactorExperiment:
|
||||
context, json_flag = self.prepare_context(hypothesis, trace)
|
||||
system_prompt = (
|
||||
Environment(undefined=StrictUndefined)
|
||||
.from_string(prompt_dict["factor_hypothesis2experiment"]["system_prompt"])
|
||||
.render(
|
||||
scenario=hs.trace.scen.get_scenario_all_desc(),
|
||||
scenario=trace.scen.get_scenario_all_desc(),
|
||||
experiment_output_format=context["experiment_output_format"],
|
||||
)
|
||||
)
|
||||
@@ -88,6 +83,7 @@ class FactorHypothesis2Experiment(Hypothesis2Experiment[FactorExperiment]):
|
||||
Environment(undefined=StrictUndefined)
|
||||
.from_string(prompt_dict["factor_hypothesis2experiment"]["user_prompt"])
|
||||
.render(
|
||||
target_hypothesis=context["target_hypothesis"],
|
||||
hypothesis_and_feedback=context["hypothesis_and_feedback"],
|
||||
factor_list=context["factor_list"],
|
||||
RAG=context["RAG"],
|
||||
@@ -96,4 +92,4 @@ class FactorHypothesis2Experiment(Hypothesis2Experiment[FactorExperiment]):
|
||||
|
||||
resp = APIBackend().build_messages_and_create_chat_completion(user_prompt, system_prompt, json_mode=json_flag)
|
||||
|
||||
return self.convert_response(resp)
|
||||
return self.convert_response(resp, trace)
|
||||
|
||||
@@ -21,14 +21,17 @@ factor_hypothesis2experiment:
|
||||
The factors are used in certain scenario, the scenario is as follows:
|
||||
{{ scenario }}
|
||||
The user will use the factors generated to do some experiments. The user will provide this information to you:
|
||||
1. The hypothesis generated in the previous steps and their corresponding feedbacks.
|
||||
2. Former proposed factors on similar hypothesis.
|
||||
3. Some additional information to help you generate new factors.
|
||||
1. The target hypothesis you are targeting to generate factors for.
|
||||
2. The hypothesis generated in the previous steps and their corresponding feedbacks.
|
||||
3. Former proposed factors on similar hypothesis.
|
||||
4. Some additional information to help you generate new factors.
|
||||
Please generate the output following the format below:
|
||||
{{ experiment_output_format }}
|
||||
|
||||
user_prompt: |-
|
||||
The user has made several hypothesis on this scenario and did several evaluation on them.
|
||||
The target hypothesis you are targeting to generate factors for is as follows:
|
||||
{{ target_hypothesis }}
|
||||
The former hypothesis and the corresponding feedbacks are as follows:
|
||||
{{ hypothesis_and_feedback }}
|
||||
The former proposed factors on similar hypothesis are as follows:
|
||||
|
||||
Reference in New Issue
Block a user