Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: answer augmentation review #48

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions commons/synthetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ async def _augment_answer(
)

# merge generated JS code into HTML file
result = _merge_JS_and_HTML(result)
result = _merge_js_and_html(result)

logger.info(f" {id} {augmentation} answer generated")
return model, result, augmentation, id
Expand All @@ -502,7 +502,7 @@ async def _augment_answer(


# merges output index.js into index.html
def _merge_JS_and_HTML(result):
def _merge_js_and_html(result):
ans_with_index_html = build_single_index_html(result)
html_file = next(
(file for file in ans_with_index_html.files if file.filename == "index.html"),
Expand Down Expand Up @@ -561,7 +561,7 @@ async def _generate_response(
if result is None:
raise ValueError("generate_answer() returned none")
# TODO remove after testing ensure single index.html file just for now
result = _merge_JS_and_HTML(result)
result = _merge_js_and_html(result)

return model, result, level, qa_id

Expand All @@ -570,11 +570,11 @@ async def _generate_response(
persona = get_random_persona()

# 2. randomly select a topic. change weights accordingly to choose what topic of Tasks to generate.
selected_topic = random.choices(list(Topics), weights=[0.4, 0.4, 0.2], k=1)
selected_topic = random.choices(list(Topics), weights=[0.4, 0.4, 0.2], k=1)[0]
try:
# 3. generate a question using the topic
question_prompt = await generate_question(
client, question_model, selected_topic[0], persona
client, question_model, selected_topic, persona
)

if question_prompt is None:
Expand All @@ -587,7 +587,7 @@ async def _generate_response(
model, base_answer, _, qa_id = await _generate_response(
answer_models,
question_prompt,
selected_topic[0],
selected_topic,
qa_id=str(uuid.uuid4()),
)
base_response = [(model, base_answer, AnswerAugmentation.ORIGINAL, qa_id)]
Expand Down Expand Up @@ -617,7 +617,7 @@ async def _generate_response(
# generate 3 augmented questions from base question
for level in QuestionAugmentation:
augmented_question, qa_id = await augment_question(
client, question_model, question_prompt, level, selected_topic[0]
client, question_model, question_prompt, level, selected_topic
)
augmented_prompts.append(
{"level": level.name, "question": augmented_question}
Expand All @@ -627,7 +627,7 @@ async def _generate_response(
_generate_response(
answer_models,
augmented_question,
topic=selected_topic[0],
topic=selected_topic,
level=level,
qa_id=qa_id,
)
Expand Down Expand Up @@ -673,7 +673,7 @@ async def _generate_response(
"responses": responses,
"ground_truth": synthetic_ground_truth,
"augmented_prompts": augmented_prompts,
"topic": selected_topic[0].name,
"topic": selected_topic.name,
"persona": persona,
"augment_type": augment_strategy.name,
}