-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #271 from Azure-Samples/users/daviwu/ignite2024
Run evaluation from `microsoft/genai-evals` and merge evaluation output
- Loading branch information
Showing
2 changed files
with
78 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import json | ||
import sys | ||
import uuid | ||
|
||
if len(sys.argv) != 3: | ||
print("Usage: python genai_evals_convert.py input_file output_file") | ||
sys.exit(1) | ||
else: | ||
# TODO: remove this print | ||
print("Converting to genai-evals data format...\n", sys.argv[1], "\n", sys.argv[2]) | ||
|
||
# Get input_file from the first parameters | ||
input_file = sys.argv[1] | ||
output_file = sys.argv[2] | ||
|
||
with open(input_file, 'r') as f: | ||
content = f.read() # Reads the entire file into a string | ||
eval_results = json.loads(content) | ||
|
||
with open(output_file, 'w') as f: | ||
for index, row in enumerate(eval_results["rows"]): | ||
description = { | ||
"context": { | ||
"system-prompt": f"Test {index + 1}", | ||
}, | ||
} | ||
|
||
new_row = { | ||
"id": uuid.uuid4().hex, | ||
"description": json.dumps(description), | ||
"query": row["inputs.query"], | ||
"context": row["inputs.context"], | ||
"response": row["inputs.response"], | ||
"ground_truth": "", | ||
} | ||
f.write(json.dumps(new_row) + "\n") | ||
|
||
print("Converted to genai-evals data format") |