-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update support for claude and minicpm-v, add a answer extractor for m…
…odels like o1, a tiny fix of eval metrics
- Loading branch information
1 parent
db67800
commit ccda8fe
Showing
8 changed files
with
310 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
""" | ||
Extract answers from the output of the o1 model | ||
""" | ||
|
||
import json | ||
import pdb | ||
|
||
from tqdm import tqdm | ||
from prompts import answer_extractor_prompt | ||
from models.gpt import GPTEvaluator | ||
from args import parse_args_for_answer_extractor | ||
|
||
def extract_answer(model,pred): | ||
""" | ||
Extract answers from the output of the o1 model | ||
""" | ||
|
||
messages = [{ | ||
"role": "system", | ||
"content": answer_extractor_prompt | ||
},{ | ||
"role": "system", | ||
"content": pred | ||
} | ||
] | ||
|
||
pred_extract = model.generate_response(messages,prepare_inputs=False) | ||
|
||
return pred_extract | ||
|
||
def main(args): | ||
with open(args.prediction_file, 'r', encoding="utf-8") as f: | ||
pred_data = json.load(f) | ||
|
||
model=GPTEvaluator(api_key=args.api_key, model=args.model_version, api_url=args.api_url, max_tokens=500, temperature=0, top_p=1, presence_penalty=0.0, frequency_penalty=0.0) | ||
|
||
for pred in tqdm(pred_data.keys()): | ||
pred_extract=extract_answer(model,pred_data[pred]["prediction"]) | ||
pred_data[pred]["prediction"]=[pred_extract, pred_data[pred]["prediction"]] | ||
|
||
with open(args.prediction_file.replace(".json", "_extracted.json"), 'w', encoding="utf-8") as f: | ||
json.dump(pred_data, f, ensure_ascii=False, indent=4) | ||
|
||
if __name__ == "__main__": | ||
args = parse_args_for_answer_extractor() | ||
main(args) |
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
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
Oops, something went wrong.