From f28908e4c58ea1147cd0630e562a58dd9f836fbc Mon Sep 17 00:00:00 2001 From: Yizhou Chi Date: Mon, 2 Sep 2024 15:15:53 +0800 Subject: [PATCH] =?UTF-8?q?1.=20role.py=20-=20=E5=A6=82=E6=9E=9C=E5=B7=B2?= =?UTF-8?q?=E7=BB=8F=E6=9C=89plan=EF=BC=8C=E4=BE=BF=E4=B8=8D=E5=86=8D?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E7=94=9F=E6=88=90=202.=20=E4=BF=AE=E6=94=B9p?= =?UTF-8?q?rompt=EF=BC=8C=E8=AE=A9predictions.csv=E7=94=9F=E6=88=90?= =?UTF-8?q?=E7=9A=84=E6=A0=BC=E5=BC=8F=E4=B8=8E=E5=8E=9Fgt=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E4=B8=80=E6=A0=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- expo/MCTS.py | 3 ++- expo/dataset.py | 8 +++++--- expo/experimenter/aug.py | 2 +- expo/experimenter/mcts.py | 4 ++-- metagpt/roles/role.py | 8 ++++---- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/expo/MCTS.py b/expo/MCTS.py index 02e80bb52..5b1cb36dc 100644 --- a/expo/MCTS.py +++ b/expo/MCTS.py @@ -42,6 +42,7 @@ class Node(): value : float = 0 visited : int = 0 children : list = [] + normalized_reward : dict = {"train_score": 0, "dev_score": 0, "test_score": 0} parent = None def __init__(self, parent=None, state = None, action=None, value = 0, max_depth=4, **kwargs): @@ -274,7 +275,7 @@ class MCTS(): if score > best_score: best_score = score best_child = child - best_score, best_child = bfs(child, best_score, best_child) + best_score, best_child = bfs(child, best_score, best_child, split) return best_score, best_child _, best_child = bfs(root, best_score, best_child, "test_score") _, dev_best_child = bfs(root, best_score, best_child, "dev_score") diff --git a/expo/dataset.py b/expo/dataset.py index 9667c0aef..3f59c3367 100644 --- a/expo/dataset.py +++ b/expo/dataset.py @@ -23,9 +23,11 @@ TASK_PROMPT = """\ 3. You should perform transformations on all sets at the same step. ## Saving Dev and Test Predictions -Save the prediction results of BOTH the dev set and test set in `dev_predictions.csv` and `test_predictions.csv` respectively in the output directory. -Both files should contain a single column named `target` with the predicted values. -Make sure the prediction results are in the same format as the target column in the training set. The labels should be transformed back to the original format if any transformation was applied during training. +1. Save the prediction results of BOTH the dev set and test set in `dev_predictions.csv` and `test_predictions.csv` respectively in the output directory. +- Both files should contain a single column named `target` with the predicted values. +2. Make sure the prediction results are in the same format as the target column in the training set. +- The labels should be transformed back to the original format if any transformation was applied during training. +- If the original target column was categorical, the predictions should be in the same format. ## Output Training Set Performance Make sure the performance of the model is printed in python in the last step even if it has been printed in the previous steps. The value should be a float number. diff --git a/expo/experimenter/aug.py b/expo/experimenter/aug.py index 9c6915103..956849717 100644 --- a/expo/experimenter/aug.py +++ b/expo/experimenter/aug.py @@ -46,7 +46,7 @@ class AugExperimenter(Experimenter): "score_dict": score_dict, "aug_mode": self.args.aug_mode, "insights" : exps[i], - "user_requirement": user_requirement, + "user_requirement": requirement, "args": vars(self.args) }) scores = [result["score_dict"]["test_score"] for result in results] diff --git a/expo/experimenter/mcts.py b/expo/experimenter/mcts.py index 3399fcff9..43c5f9868 100644 --- a/expo/experimenter/mcts.py +++ b/expo/experimenter/mcts.py @@ -25,9 +25,9 @@ class MCTSExperimenter(Experimenter): self.save_tree(text) results = { - "best_node": best_node, + "best_node": best_node.id, "best_node_score": best_node.raw_reward, - "dev_best_node": dev_best_node, + "dev_best_node": dev_best_node.id, "dev_best_node_score": dev_best_node.raw_reward, "num_generated_codes": num_generated_codes, "user_requirement": best_node.state["requirement"], diff --git a/metagpt/roles/role.py b/metagpt/roles/role.py index 5ecc7ae33..1e786898c 100644 --- a/metagpt/roles/role.py +++ b/metagpt/roles/role.py @@ -478,10 +478,10 @@ class Role(SerializationMixin, ContextMixin, BaseModel): async def _plan_and_act(self) -> Message: """first plan, then execute an action sequence, i.e. _think (of a plan) -> _act -> _act -> ... Use llm to come up with the plan dynamically.""" - - # create initial plan and update it until confirmation - goal = self.rc.memory.get()[-1].content # retreive latest user requirement - await self.planner.update_plan(goal=goal) + if not self.planner.plan.goal: + # create initial plan and update it until confirmation + goal = self.rc.memory.get()[-1].content # retreive latest user requirement + await self.planner.update_plan(goal=goal) # take on tasks until all finished while self.planner.current_task: