mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-05-01 20:03:28 +02:00
Update AFlow
This commit is contained in:
parent
040a7324eb
commit
eae351466f
89 changed files with 2350 additions and 395730 deletions
39
optimize.py
39
optimize.py
|
|
@ -3,15 +3,23 @@
|
|||
# @Author : didi
|
||||
# @Desc : Experiment of graph optimization
|
||||
|
||||
from examples.ags.scripts.optimizer import Optimizer
|
||||
from examples.aflow.scripts.optimizer import Optimizer
|
||||
from metagpt.configs.models_config import ModelsConfig
|
||||
from typing import Literal
|
||||
|
||||
# DatasetType, QuestionType, and OptimizerType definitions
|
||||
DatasetType = Literal["HumanEval", "MBPP", "GSM8K", "MATH", "HotpotQa", "DROP"]
|
||||
QuestionType = Literal["math", "code", "quiz"]
|
||||
OptimizerType = Literal["Graph", "Test"]
|
||||
|
||||
# Crucial Parameters
|
||||
dataset = "HumanEval" # DatasetType
|
||||
sample = 4 # Sample Count, which means how many workflows will be resampled from generated workflows
|
||||
question_type = "code" # Question Type
|
||||
optimized_path = "examples/ags/scripts/optimized" # Optimized Result Save Path
|
||||
dataset: DatasetType = "GSM8K" # Ensure the type is consistent with DatasetType
|
||||
sample: int = 4 # Sample Count, which means how many workflows will be resampled from generated workflows
|
||||
question_type: QuestionType = "math" # Ensure the type is consistent with QuestionType
|
||||
optimized_path: str = "examples/aflow/scripts/optimized" # Optimized Result Save Path
|
||||
initial_round: int = 1 # Corrected the case from Initial_round to initial_round
|
||||
max_rounds: int = 20
|
||||
check_convergence: bool = True
|
||||
|
||||
# Initialize LLM Model
|
||||
four_o_llm_config = ModelsConfig.default().get("gpt-4o")
|
||||
|
|
@ -21,25 +29,24 @@ claude_llm_config = ModelsConfig.default().get("claude-3-5-sonnet-20240620")
|
|||
|
||||
# Initialize Operators List
|
||||
operators = [
|
||||
"Custom",
|
||||
"CustomCodeGenerate",
|
||||
"ScEnsemble",
|
||||
"Test",
|
||||
"Custom"
|
||||
]
|
||||
|
||||
# Create an optimizer instance
|
||||
optimizer = Optimizer(
|
||||
dataset=dataset,
|
||||
question_type=question_type,
|
||||
opt_llm_config=claude_llm_config,
|
||||
exec_llm_config=four_o_llm_config,
|
||||
exec_llm_config=mini_llm_config,
|
||||
check_convergence=check_convergence,
|
||||
operators=operators,
|
||||
optimized_path=optimized_path,
|
||||
sample=sample,
|
||||
question_type=question_type,
|
||||
initial_round=initial_round,
|
||||
max_rounds=max_rounds
|
||||
)
|
||||
|
||||
# Run the optimizer
|
||||
# optimizer.optimize("Graph", 30)
|
||||
optimizer.optimize("Test")
|
||||
# optimizer.optimize("Operator")
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Run the optimizer
|
||||
optimizer.optimize("Graph")
|
||||
# optimizer.optimize("Test")
|
||||
Loading…
Add table
Add a link
Reference in a new issue