Skip to content

Commit 74bfcce

Browse files
fix(baselines): fix _post_process in genie
1 parent 6af1cda commit 74bfcce

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

baselines/Genie/genie.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,11 @@
4949

5050

5151
def _post_process(content: str) -> tuple:
52-
lines = content.split('\n')
53-
question = lines[0].split('[question]: ')[1]
54-
answer = lines[1].split('[answer]: ')[1]
55-
return question, answer
52+
if "[question]:" in content and "[answer]:" in content:
53+
question = content.split('[question]: ')[1].split('[answer]: ')[0]
54+
answer = content.split('[answer]: ')[1]
55+
return question, answer
56+
return None, None
5657

5758

5859
@dataclass
@@ -81,10 +82,11 @@ async def process_chunk(content: str):
8182
for result in tqdm_async(asyncio.as_completed(tasks), total=len(tasks), desc="Generating using Genie"):
8283
try:
8384
question, answer = _post_process(await result)
84-
final_results[compute_content_hash(question)] = {
85-
'question': question,
86-
'answer': answer
87-
}
85+
if question and answer:
86+
final_results[compute_content_hash(question)] = {
87+
'question': question,
88+
'answer': answer
89+
}
8890
except Exception as e: # pylint: disable=broad-except
8991
print(f"Error: {e}")
9092
return final_results

charts/plot_loss_change.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@ def plot_loss_distribution(stats: list[dict]):
5151
'tickvals': list(range(len(sorted_bins)))[::2]
5252
}
5353
)
54-
return fig
54+
return fig

0 commit comments

Comments
 (0)