Rename insight generate to instruction generator

This commit is contained in:
Yizhou Chi 2024-09-02 09:59:47 +08:00
parent ae6a195750
commit 16d1bf0da0
4 changed files with 13 additions and 13 deletions

View file

@ -3,7 +3,7 @@ import math
import os
import pandas as pd
from expo.research_assistant import ResearchAssistant
from expo.insights.InsightGenerate import InsightGenerator
from exp_optimizer.expo.insights.instruction_generator import InstructionGenerator
from expo.dataset import get_split_dataset_path, generate_task_requirement
from expo.evaluation.evaluation import evaluate_score
from expo.utils import mcts_logger, load_execute_notebook, get_exp_pool_path

View file

@ -2,7 +2,7 @@ from experimenter import Experimenter
from expo.MCTS import create_initial_state
from expo.dataset import generate_task_requirement
from expo.utils import mcts_logger, load_execute_notebook, get_exp_pool_path
from expo.insights.InsightGenerate import InsightGenerator
from exp_optimizer.expo.insights.instruction_generator import InstructionGenerator
from expo.research_assistant import ResearchAssistant
EXPS_PROMPT = """
@ -21,12 +21,12 @@ class AugExperimenter(Experimenter):
state = create_initial_state(self.args.task, start_task_id=1, data_config=self.data_config, low_is_better=self.args.low_is_better, name="")
user_requirement = state["requirement"]
exp_pool_path = get_exp_pool_path(self.args.task, self.data_config, pool_name="ds_analysis_pool")
exp_pool = InsightGenerator.load_analysis_pool(exp_pool_path)
exp_pool = InstructionGenerator.load_analysis_pool(exp_pool_path)
if self.args.aug_mode == "single":
exps = InsightGenerator._random_sample(exp_pool, self.args.num_experiments)
exps = InstructionGenerator._random_sample(exp_pool, self.args.num_experiments)
exps = [exp["Analysis"] for exp in exps]
elif self.args.aug_mode == "set":
exp_set = InsightGenerator.sample_instruction_set(exp_pool)
exp_set = InstructionGenerator.sample_instruction_set(exp_pool)
exp_set_text = "\n".join([f"{exp['task_id']}: {exp['Analysis']}" for exp in exp_set])
exps = [exp_set_text] * self.args.num_experiments
else:

View file

@ -27,7 +27,7 @@ from expo.utils import load_data_config, mcts_logger, clean_json_from_rsp
DATA_CONFIG = load_data_config()
class InsightGenerator:
class InstructionGenerator:
data_config = DATA_CONFIG
@staticmethod
@ -68,7 +68,7 @@ class InsightGenerator:
@staticmethod
def load_analysis_pool(file_path, task_id=None):
data = InsightGenerator.load_json_data(file_path)
data = InstructionGenerator.load_json_data(file_path)
for item in data:
if "task_id" not in item:
raise ValueError("task_id is not found in the analysis pool")
@ -79,14 +79,14 @@ class InsightGenerator:
@staticmethod
async def generate_new_instructions(task_id, original_instruction, max_num, file_path):
data = InsightGenerator.load_analysis_pool(file_path, task_id)
data = InstructionGenerator.load_analysis_pool(file_path, task_id)
new_instructions = []
if len(data) == 0:
mcts_logger.log("MCTS", f"No insights available for task {task_id}")
return [original_instruction] # Return the original instruction if no insights are available
for item in data[:max_num]:
insights = item["Analysis"]
new_instruction = await InsightGenerator.generate_new_instruction(original_instruction, insights)
new_instruction = await InstructionGenerator.generate_new_instruction(original_instruction, insights)
new_instructions.append(new_instruction)
return new_instructions

View file

@ -3,7 +3,7 @@ from expo.research_assistant import ResearchAssistant
import asyncio
from expo.utils import DATA_CONFIG, get_exp_pool_path
from expo.dataset import generate_task_requirement
from expo.insights.InsightGenerate import InsightGenerator
from exp_optimizer.expo.insights.instruction_generator import InstructionGenerator
from expo.MCTS import create_initial_state
from expo.evaluation.evaluation import evaluate_score
import json
@ -48,12 +48,12 @@ async def main(task_name, use_reflection=True, mode="single", num_experiments=2)
user_requirement = generate_task_requirement(task_name, data_config)
exp_pool_path = get_exp_pool_path(task_name, data_config, pool_name="ds_analysis_pool")
exp_pool = InsightGenerator.load_analysis_pool(exp_pool_path)
exp_pool = InstructionGenerator.load_analysis_pool(exp_pool_path)
if mode == "single":
exps = InsightGenerator._random_sample(exp_pool, num_experiments)
exps = InstructionGenerator._random_sample(exp_pool, num_experiments)
exps = [exp["Analysis"] for exp in exps]
elif mode == "set":
exp_set = InsightGenerator.sample_instruction_set(exp_pool)
exp_set = InstructionGenerator.sample_instruction_set(exp_pool)
exp_set_text = "\n".join([f"{exp['task_id']}: {exp['Analysis']}" for exp in exp_set])
exps = [exp_set_text] * num_experiments
else: