2024-06-21 16:41:34 +08:00
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
|
|
DIRNAME = Path(__file__).absolute().resolve().parent
|
|
|
|
|
|
2024-06-30 23:31:00 +08:00
|
|
|
from rdagent.components.task_implementation.model_implementation.benchmark.eval import ModelImpValEval
|
|
|
|
|
from rdagent.components.task_implementation.model_implementation.one_shot import ModelTaskGen
|
|
|
|
|
from rdagent.components.task_implementation.model_implementation.task import ModelImpLoader, ModelTaskLoderJson
|
2024-06-21 16:41:34 +08:00
|
|
|
|
2024-06-30 23:31:00 +08:00
|
|
|
|
|
|
|
|
bench_folder = DIRNAME.parent.parent / "components" / "task_implementation" / "model_implementation" / "benchmark"
|
|
|
|
|
mtl = ModelTaskLoderJson(str(bench_folder / "model_dict.json"))
|
2024-06-21 16:41:34 +08:00
|
|
|
|
|
|
|
|
task_l = mtl.load()
|
|
|
|
|
|
2024-06-30 23:31:00 +08:00
|
|
|
task_l = [t for t in task_l if t.key == "A-DGN"] # FIXME: other models does not work well
|
|
|
|
|
|
2024-06-21 16:41:34 +08:00
|
|
|
mtg = ModelTaskGen()
|
|
|
|
|
|
|
|
|
|
impl_l = mtg.generate(task_l)
|
|
|
|
|
|
|
|
|
|
# TODO: Align it with the benchmark framework after @wenjun's refine the evaluation part.
|
|
|
|
|
# Currently, we just handcraft a workflow for fast evaluation.
|
|
|
|
|
|
2024-06-30 23:31:00 +08:00
|
|
|
mil = ModelImpLoader(bench_folder / "gt_code")
|
2024-06-21 16:41:34 +08:00
|
|
|
|
|
|
|
|
mie = ModelImpValEval()
|
|
|
|
|
# Evaluation:
|
|
|
|
|
eval_l = []
|
|
|
|
|
for impl in impl_l:
|
2024-06-30 23:31:00 +08:00
|
|
|
print(impl.target_task)
|
2024-06-21 16:41:34 +08:00
|
|
|
gt_impl = mil.load(impl.target_task)
|
|
|
|
|
eval_l.append(mie.evaluate(gt_impl, impl))
|
|
|
|
|
|
|
|
|
|
print(eval_l)
|