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

Added an option to add prompt to the logprobs #147

Merged
merged 2 commits into from
May 30, 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
16 changes: 7 additions & 9 deletions eval/api_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,22 +270,14 @@ def run_api_eval(args):
)

output_df = pd.DataFrame(output_rows)
del output_df["prompt"]

print(output_df.groupby("query_category")[["correct", "error_db_exec"]].mean())
output_df = output_df.sort_values(by=["db_name", "query_category", "question"])
# get directory of output_file and create if not exist
output_dir = os.path.dirname(output_file)
if not os.path.exists(output_dir):
os.makedirs(output_dir)

with open(output_file.replace(".csv", ".json"), "w") as f:
json.dump(output_df.to_dict("records"), f)

try:
output_df.to_csv(output_file, index=False, float_format="%.2f")
except:
output_df.to_pickle(output_file)

if logprobs:
print(
f"Writing logprobs to JSON file at {output_file.replace('.csv', '.json')}"
Expand All @@ -297,6 +289,12 @@ def run_api_eval(args):
) as f:
json.dump(results, f)

del output_df["prompt"]
try:
output_df.to_csv(output_file, index=False, float_format="%.2f")
except:
output_df.to_pickle(output_file)

# upload results
# with open(prompt_file, "r") as f:
# prompt = f.read()
Expand Down
Loading