-
Notifications
You must be signed in to change notification settings - Fork 4
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 #48 from ku-nlp/fix/tie-handling
Fix tie handling
- Loading branch information
Showing
8 changed files
with
128 additions
and
51 deletions.
There are no files selected for viewing
16 changes: 8 additions & 8 deletions
16
...judgment/pairwise/gpt-4/pairwise:cyberagent--calm2-7b-chat_openai--text-davinci-003.jsonl
Large diffs are not rendered by default.
Oops, something went wrong.
10 changes: 5 additions & 5 deletions
10
...e:llm-jp--llm-jp-13b-instruct-full-jaster-dolly-oasst-v1.0_openai--text-davinci-003.jsonl
Large diffs are not rendered by default.
Oops, something went wrong.
14 changes: 7 additions & 7 deletions
14
...e:llm-jp--llm-jp-13b-instruct-lora-jaster-dolly-oasst-v1.0_openai--text-davinci-003.jsonl
Large diffs are not rendered by default.
Oops, something went wrong.
10 changes: 5 additions & 5 deletions
10
...t-4/pairwise:openai--text-davinci-003_rinna--japanese-gpt-neox-3.6b-instruction-ppo.jsonl
Large diffs are not rendered by default.
Oops, something went wrong.
10 changes: 5 additions & 5 deletions
10
.../pairwise:openai--text-davinci-003_rinna--japanese-gpt-neox-3.6b-instruction-sft-v2.jsonl
Large diffs are not rendered by default.
Oops, something went wrong.
6 changes: 3 additions & 3 deletions
6
...wise/gpt-4/pairwise:openai--text-davinci-003_tokyotech-llm--Swallow-70b-instruct-hf.jsonl
Large diffs are not rendered by default.
Oops, something went wrong.
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,74 @@ | ||
import argparse | ||
import json | ||
import logging | ||
|
||
from common import JUDGEMENT_DIR, load_judgements | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def reparse_result_pairwise(result: dict) -> dict: | ||
"""Reparse the result to determine the winner. | ||
Args: | ||
result: A result. | ||
""" | ||
reparsed_result = result.copy() | ||
|
||
g1_judgment = result["g1_judgment"] | ||
if "[[A]]" in g1_judgment: | ||
g1_winner = "model_1" | ||
elif "[[B]]" in g1_judgment: | ||
g1_winner = "model_2" | ||
elif "[[C]]" in g1_judgment: | ||
g1_winner = "tie" | ||
else: | ||
g1_winner = "error" | ||
reparsed_result["g1_winner"] = g1_winner | ||
|
||
g2_judgment = result["g2_judgment"] | ||
if "[[A]]" in g2_judgment: | ||
g2_winner = "model_2" | ||
elif "[[B]]" in g2_judgment: | ||
g2_winner = "model_1" | ||
elif "[[C]]" in g2_judgment: | ||
g2_winner = "tie" | ||
else: | ||
g2_winner = "error" | ||
reparsed_result["g2_winner"] = g2_winner | ||
|
||
return reparsed_result | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument( | ||
"--verbose", "-v", action="count", default=0, help="Verbosity level" | ||
) | ||
args = parser.parse_args() | ||
|
||
if args.verbose == 0: | ||
level = logging.INFO | ||
else: | ||
level = logging.DEBUG | ||
logging.basicConfig( | ||
format="| %(asctime)s | %(levelname)s | %(message)s", | ||
datefmt="%Y-%m-%d %H:%M:%S", | ||
level=level, | ||
) | ||
|
||
logger.info("Load judgements") | ||
for judgement_dir in (JUDGEMENT_DIR / "pairwise").iterdir(): | ||
result_id_results_map = load_judgements(judgement_dir) | ||
for result_id, results in result_id_results_map.items(): | ||
reparsed_results = [reparse_result_pairwise(result) for result in results] | ||
if any( | ||
result != reparsed_result | ||
for result, reparsed_result in zip(results, reparsed_results) | ||
): | ||
output_file = judgement_dir / f"{result_id}.jsonl" | ||
with open(output_file, "w") as f: | ||
for result in reparsed_results: | ||
f.write(json.dumps(result, ensure_ascii=False) + "\n") | ||
logger.info(f"Fixed {output_file}") | ||
logger.info("Done") |