mirror of
https://github.com/NicolasBohn/NexQuant.git
synced 2026-08-09 13:00:56 +00:00
feat: make spec optional (#719)
* feat: Add spec_enabled configuration for data science settings * make spec alternative * change spec logic in exp_gen * remove some general texts * align --------- Co-authored-by: Young <afe.young@gmail.com> Co-authored-by: yuanteli <1957922024@qq.com>
This commit is contained in:
@@ -12,8 +12,12 @@ File structure
|
||||
"""
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
from typing import Dict
|
||||
|
||||
from jinja2 import Environment, StrictUndefined
|
||||
|
||||
from rdagent.app.data_science.conf import DS_RD_SETTING
|
||||
from rdagent.components.coder.CoSTEER import CoSTEER
|
||||
from rdagent.components.coder.CoSTEER.evaluators import (
|
||||
CoSTEERMultiEvaluator,
|
||||
@@ -35,6 +39,8 @@ from rdagent.oai.llm_utils import APIBackend
|
||||
from rdagent.utils.agent.ret import PythonAgentOut
|
||||
from rdagent.utils.agent.tpl import T
|
||||
|
||||
DIRNAME = Path(__file__).absolute().resolve().parent
|
||||
|
||||
|
||||
class EnsembleMultiProcessEvolvingStrategy(MultiProcessEvolvingStrategy):
|
||||
def implement_one_task(
|
||||
@@ -79,8 +85,24 @@ class EnsembleMultiProcessEvolvingStrategy(MultiProcessEvolvingStrategy):
|
||||
all_code=workspace.all_codes,
|
||||
out_spec=PythonAgentOut.get_spec(),
|
||||
)
|
||||
|
||||
if DS_RD_SETTING.spec_enabled:
|
||||
code_spec = workspace.file_dict["spec/ensemble.md"]
|
||||
else:
|
||||
test_code = (
|
||||
Environment(undefined=StrictUndefined)
|
||||
.from_string((DIRNAME / "eval_tests" / "ensemble_test.txt").read_text())
|
||||
.render(
|
||||
model_names=[
|
||||
fn[:-3] for fn in workspace.file_dict.keys() if fn.startswith("model_") and "test" not in fn
|
||||
]
|
||||
)
|
||||
)
|
||||
code_spec = T("scenarios.data_science.share:component_spec.general").r(
|
||||
spec=T("scenarios.data_science.share:component_spec.Ensemble").r(), test_code=test_code
|
||||
)
|
||||
user_prompt = T(".prompts:ensemble_coder.user").r(
|
||||
ensemble_spec=workspace.file_dict["spec/ensemble.md"],
|
||||
code_spec=code_spec,
|
||||
latest_code=workspace.file_dict.get("ensemble.py"),
|
||||
latest_code_feedback=prev_task_feedback,
|
||||
)
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
"""
|
||||
A qualified ensemble implementation should:
|
||||
- Successfully run
|
||||
Tests for `ensemble_workflow` in ensemble.py
|
||||
|
||||
A qualified ensemble_workflow implementation should:
|
||||
- Return predictions
|
||||
- Have correct shapes for inputs and outputs
|
||||
- Use validation data appropriately
|
||||
- Generate a scores.csv file
|
||||
"""
|
||||
|
||||
import numpy as np
|
||||
|
||||
@@ -51,8 +51,8 @@ ensemble_coder:
|
||||
{% endif %}
|
||||
|
||||
user: |-
|
||||
--------- Ensemble Specification ---------
|
||||
{{ ensemble_spec }}
|
||||
--------- Code Specification ---------
|
||||
{{ code_spec }}
|
||||
|
||||
{% if latest_code %}
|
||||
--------- Former code ---------
|
||||
|
||||
Reference in New Issue
Block a user