Skip to content

Commit a8e6c5c

Browse files
committed
Nomenclature change: problem -> task
1 parent bdb607a commit a8e6c5c

File tree

2 files changed

+54
-54
lines changed

2 files changed

+54
-54
lines changed

src/generate_tasks.py

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -5,64 +5,64 @@
55
from model import Model
66
from utils.capability_utils import extract_and_parse_response
77
from utils.prompts import (
8-
PROBLEM_GENERATION_RESPONSE_JSON_FORMAT,
9-
PROBLEM_GENERATION_SYSTEM_PROMPT,
10-
PROBLEM_GENERATION_USER_PROMPT,
11-
PROBLEM_GENERATION_ZERO_OR_FEW_SHOT_PATCH,
8+
TASK_GENERATION_RESPONSE_JSON_FORMAT,
9+
TASK_GENERATION_SYSTEM_PROMPT,
10+
TASK_GENERATION_USER_PROMPT,
11+
TASK_GENERATION_ZERO_OR_FEW_SHOT_PATCH,
1212
)
1313

1414

15-
def get_problem_generation_prompt(
15+
def get_task_generation_prompt(
1616
capability: Capability,
17-
num_gen_problems: int,
17+
num_gen_tasks: int,
1818
few_shot: bool = False,
19-
sample_problems: List[Dict[str, Any]] | None = None,
19+
sample_tasks: List[Dict[str, Any]] | None = None,
2020
) -> Tuple[str, str]:
2121
"""
22-
Generate the system and user prompts for problem generation.
22+
Generate the system and user prompts for task generation.
2323
24-
Generate the system and user prompts for problem generation
25-
based on the given capability, number of problems to generate,
24+
Generate the system and user prompts for task generation
25+
based on the given capability, number of tasks to generate,
2626
and the few-shot setting.
2727
2828
Args
2929
----
30-
capability (Capability): The capability to generate problems for.
31-
num_gen_problems (int): The number of problems to generate.
30+
capability (Capability): The capability to generate tasks for.
31+
num_gen_tasks (int): The number of tasks to generate.
3232
few_shot (bool, optional): The few-shot setting. Defaults to False.
33-
sample_problems (List[Dict[str, Any]] | None, optional): The sample problems
33+
sample_tasks (List[Dict[str, Any]] | None, optional): The sample tasks
3434
to use. Defaults to None.
3535
3636
Returns
3737
-------
3838
Tuple[str, str]: The system and user prompts.
3939
"""
40-
assert (few_shot and (sample_problems is not None)) or (not few_shot), (
41-
"Few-shot setting is enabled but no sample problems are provided."
40+
assert (few_shot and (sample_tasks is not None)) or (not few_shot), (
41+
"Few-shot setting is enabled but no sample tasks are provided."
4242
)
4343
prompt_type = "few_shot" if few_shot else "zero_shot"
44-
sys_prompt = PROBLEM_GENERATION_SYSTEM_PROMPT.format(
45-
zero_or_few_shot_patch=PROBLEM_GENERATION_ZERO_OR_FEW_SHOT_PATCH[prompt_type][
44+
sys_prompt = TASK_GENERATION_SYSTEM_PROMPT.format(
45+
zero_or_few_shot_patch=TASK_GENERATION_ZERO_OR_FEW_SHOT_PATCH[prompt_type][
4646
"sys"
4747
],
48-
response_json_format=PROBLEM_GENERATION_RESPONSE_JSON_FORMAT,
48+
response_json_format=TASK_GENERATION_RESPONSE_JSON_FORMAT,
4949
)
50-
user_zero_or_few_shot_patch = PROBLEM_GENERATION_ZERO_OR_FEW_SHOT_PATCH[
51-
prompt_type
52-
]["user"]
53-
if few_shot and sample_problems is not None:
50+
user_zero_or_few_shot_patch = TASK_GENERATION_ZERO_OR_FEW_SHOT_PATCH[prompt_type][
51+
"user"
52+
]
53+
if few_shot and sample_tasks is not None:
5454
user_zero_or_few_shot_patch = user_zero_or_few_shot_patch.format(
55-
capability_sample_problems=json.dumps(
56-
{f"problem_{elm['id']}": elm["problem"] for elm in sample_problems},
55+
capability_sample_tasks=json.dumps(
56+
{f"task_{elm['id']}": elm["problem"] for elm in sample_tasks},
5757
indent=4,
5858
),
5959
)
60-
user_prompt = PROBLEM_GENERATION_USER_PROMPT.format(
60+
user_prompt = TASK_GENERATION_USER_PROMPT.format(
6161
capability_name=capability.name,
6262
capability_description=capability.description,
6363
capability_domain=capability.domain,
6464
zero_or_few_shot_patch=user_zero_or_few_shot_patch,
65-
num_gen_problems=num_gen_problems,
65+
num_gen_tasks=num_gen_tasks,
6666
)
6767
return sys_prompt, user_prompt
6868

@@ -120,18 +120,18 @@ def generate_tasks_using_llm(
120120
# c. using a scoring function
121121

122122
# Generate task problems
123-
# Extract sample problems from representative tasks
124-
sample_problems = capability.get_repr_tasks()
125-
for task in sample_problems:
123+
# Extract sample tasks from representative tasks
124+
sample_tasks = capability.get_repr_tasks()
125+
for task in sample_tasks:
126126
# Remove the answer
127127
task.pop("answer", None)
128128

129-
# Generate new problems using the scientist LLM
130-
sys_prompt, user_prompt = get_problem_generation_prompt(
129+
# Generate new tasks using the scientist LLM
130+
sys_prompt, user_prompt = get_task_generation_prompt(
131131
capability=capability,
132-
num_gen_problems=num_tasks,
132+
num_gen_tasks=num_tasks,
133133
few_shot=kwargs.get("few_shot", True),
134-
sample_problems=sample_problems,
134+
sample_tasks=sample_tasks,
135135
)
136136
response, task_gen_metadata = scientist_llm.generate(
137137
sys_prompt=sys_prompt,
@@ -143,17 +143,17 @@ def generate_tasks_using_llm(
143143
print(f"Output:\n\n{response}\n\n")
144144
print(f"Metadata: {task_gen_metadata}")
145145
parsed_response = extract_and_parse_response(response)
146-
new_problems = parsed_response["parsed_response"]
147-
# Combine with sample problems to get the full set of problems
148-
start_id = len(sample_problems) + 1
149-
all_problems = sample_problems + [
150-
{"id": (start_id + idx), "problem": new_problems[idx]}
151-
for idx in range(len(new_problems))
146+
new_tasks = parsed_response["parsed_response"]
147+
# Combine with sample tasks to get the full set of tasks
148+
start_id = len(sample_tasks) + 1
149+
all_tasks = sample_tasks + [
150+
{"id": (start_id + idx), "problem": new_tasks[idx]}
151+
for idx in range(len(new_tasks))
152152
]
153153

154154
# Solve task and generate answers
155155
solved_tasks, task_solver_metadata = capability.solve_tasks(
156-
tasks=all_problems,
156+
tasks=all_tasks,
157157
llm=scientist_llm,
158158
gen_cfg=scientist_llm_gen_cfg_task_solve,
159159
)

src/utils/prompts.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,45 +58,45 @@ def score(t: dict, submission: str) -> float | None:
5858
Generate {num_gen_capabilities} new interesting capabilities within the {domain} domain.
5959
"""
6060

61-
PROBLEM_GENERATION_SYSTEM_PROMPT = """
62-
You are an expert in designing tasks for a given capability. Each task consists of a problem and an answer. Your goal is to create problems alone. The name, description, {zero_or_few_shot_patch} for the capability will be provided. You will be particularly rewarded for designing diverse problems spanning a wide range of difficulty levels for the given capability.
61+
TASK_GENERATION_SYSTEM_PROMPT = """
62+
You are an expert in designing tasks for a given capability. The name, description, {zero_or_few_shot_patch} for the capability will be provided. You will be particularly rewarded for designing diverse tasks spanning a wide range of difficulty levels for the given capability.
6363
6464
Respond precisely in the following format, including the JSON start and end markers:
6565
6666
THOUGHT: <THOUGHT>
6767
RESPONSE JSON:
6868
{response_json_format}
6969
70-
In <THOUGHT>, briefly think and reason about what kind of problems you want to propose.
71-
In <STR>, provide a string containing the problem text.
70+
In <THOUGHT>, briefly think and reason about what kind of tasks you want to propose.
71+
In <STR>, provide a string containing the task text.
7272
73-
Be careful to make sure that all proposed problems are unique. Also ensure that all problems are within the scope of the given capability. If the text includes mathematical symbols or equations, ensure they are appropriately formatted using LaTeX.
73+
Be careful to make sure that all proposed tasks are unique. Also ensure that all tasks are within the scope of the given capability. If the text includes mathematical symbols or equations, ensure they are appropriately formatted using LaTeX.
7474
7575
Your response will be automatically parsed so ensure it adheres to the specified format.
7676
"""
7777

78-
PROBLEM_GENERATION_USER_PROMPT = """
79-
Design problems for the following capability:
78+
TASK_GENERATION_USER_PROMPT = """
79+
Design tasks for the following capability:
8080
8181
Name: {capability_name}
8282
Description: {capability_description}
8383
Domain: {capability_domain}
8484
{zero_or_few_shot_patch}
85-
Generate {num_gen_problems} new problems for the given capability.
85+
Generate {num_gen_tasks} new tasks for the given capability.
8686
"""
8787

88-
PROBLEM_GENERATION_ZERO_OR_FEW_SHOT_PATCH = {
88+
TASK_GENERATION_ZERO_OR_FEW_SHOT_PATCH = {
8989
"zero_shot": {"sys": "and domain", "user": ""},
9090
"few_shot": {
91-
"sys": "domain and a few sample problems",
92-
"user": "Sample problems:\n{capability_sample_problems}\n",
91+
"sys": "domain and a few sample tasks",
92+
"user": "Sample tasks:\n{capability_sample_tasks}\n",
9393
},
9494
}
9595

96-
PROBLEM_GENERATION_RESPONSE_JSON_FORMAT = """
96+
TASK_GENERATION_RESPONSE_JSON_FORMAT = """
9797
{
98-
"problem_1": <STR>,
99-
"problem_2": <STR>,
98+
"task_1": <STR>,
99+
"task_2": <STR>,
100100
...
101101
}""".strip("\n")
102102

0 commit comments

Comments
 (0)