Skip to content

Commit

Permalink
Merge branch 'feat_math_sovler' of https://github.com/didiforgithub/M…
Browse files Browse the repository at this point in the history
…etaGPT into feat_math_sovler
  • Loading branch information
MoshiQAQ committed Apr 10, 2024
2 parents 19c809d + e76d760 commit 74be5d2
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
21 changes: 19 additions & 2 deletions math_ai/codebase/math_resovler.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,22 @@ def __init__(self):
self.role = "You're the most powerful math Olympiad in the world."
self.llm.set_role(self.role)

def run(problem:Dict, types:Dict):
"""
problem: Dict
types: {"strategy":"", "decompose":""}
"""
return {"current_trajectory": "current_trajectory"}

async def single_run(self, problem: Dict, types: Dict) -> Dict:
"""
Math Resolver resolve the problem based on the strategy from Gate Controller.
First, math resolver need to develop a plan which contains basic phase (di for compute; logic validate for judge solution) to solve the problem.
Then, math resolver need to ? <It's Complex Stage>
Finally, math resolver need to return the solution without refine.
"""
strategy = types["strategy"]
strategy_name = types["strategy"]
strategy = ""

# 1. 直接要求他解决数学问题,思考这个过程。 zero shot 让他先去对这个题目给出一个计划。
# 2. 得到这个过程之后,让他结合我们的strategy 跟 Prompt,重新构建phase
Expand All @@ -50,9 +58,16 @@ async def single_run(self, problem: Dict, types: Dict) -> Dict:
current_trajectory += self.logic_validate(problem, current_trajectory, subgoal=phase["plan"]["desc"])

# TODO 在这里result validate
if self.result_validate(problem, current_trajectory):
pass
else:


return {"current_trajectory": current_trajectory}

async def multi_run(self):
pass

async def di_run(self, problem, current_trajectory, subgoal):
# TODO 黄毅把获取的结果放到这里,我来写协程
return "Hello world"
Expand All @@ -66,4 +81,6 @@ def logic_validate(self, problem, current_trajectory, subgoal):

def result_validate(self, problem, current_trajectory):
validate_result = self.llm.llm_response(prompt=result_validate_prompt.format(problem=problem, trajectoty=current_trajectory),json_mode=True)
return validate_result
return validate_result

def inference_final(self, )
22 changes: 21 additions & 1 deletion math_ai/codebase/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,27 @@
"""

inference_prompt = """
正常推理
你是全球最杰出的数学竞赛选手,你已经掌握了足够多的数学知识,你对此数学解题有着非常丰富的经验,你无需纠结于解题的过程,你可以直接给出解题的结果。
你现在要解决的任务是{problem_desc}
你的合作者已经完成了上游的一些推理,或许其中有一些能辅助到你对当前任务进行推理的内容{trajectory}
现在,你需要基于你的问题,结合你的经验,给出这个问题的推理和解答。
最终结果,请你使用JSON格式进行返回,一个可以参考的格式如下:
{{
"inference": <"inference,指的是你得到答案的思维过程,">,
"answer": <"answer,对于{problem_desc}中所描述的问题的直接答案">
}}
"""

logic_validate_prompt = """
对当前结果与题目进行逻辑验证
"""

merge_inference_prompt = """
重览当前轨迹,重新思考当前结果,并进行合并
"""

result_validate_prompt = """
"""

logic_validate_prompt = """
Expand Down

0 comments on commit 74be5d2

Please sign in to comment.