forked from allenai/WildBench
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
(Bill) Yuchen Lin
committed
Oct 28, 2024
1 parent
9657e36
commit c7071d8
Showing
10 changed files
with
71,165 additions
and
26 deletions.
There are no files selected for viewing
25,002 changes: 25,002 additions & 0 deletions
25,002
result_dirs/zebra-grid/self_verification/gpt-4o-mini-2024-07-18.self_verification.T=1.json
Large diffs are not rendered by default.
Oops, something went wrong.
23,002 changes: 23,002 additions & 0 deletions
23,002
result_dirs_follow_up/zebra-grid/gpt-4o-2024-08-06.self_verification.T=1.json
Large diffs are not rendered by default.
Oops, something went wrong.
23,002 changes: 23,002 additions & 0 deletions
23,002
result_dirs_follow_up/zebra-grid/gpt-4o-mini-2024-07-18.self_verification.T=1.json
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,41 @@ | ||
""" | ||
This script is to add a follow-up instruction to the existing result file, | ||
where there is already a chat-history of the previous conversation, and an existing output (at least one) from the model. | ||
""" | ||
import json, os | ||
from templates import FOLLOW_UP | ||
|
||
def add_follow_up_instruction(file_path, output_path, follow_up_mode="self_verification"): | ||
# Load the existing data | ||
with open(file_path, 'r') as file: | ||
data = json.load(file) | ||
|
||
for item in data: | ||
# Add the follow-up instruction to each item | ||
chat_history = item["chat_history"] | ||
current_output = item["output"][0] | ||
if follow_up_mode == "self_verification": | ||
follow_up_prompt = FOLLOW_UP.SELF_VERIFICATION | ||
else: | ||
raise ValueError(f"Unknown follow_up_mode: {follow_up_mode}") | ||
new_chat_history = chat_history + [current_output] + [follow_up_prompt] | ||
item["chat_history"] = new_chat_history | ||
item["output"] = [] | ||
|
||
# save the modified data back to the file | ||
# create the output directory (and the parents) if it doesn't exist | ||
os.makedirs(os.path.dirname(output_path), exist_ok=True) | ||
with open(output_path, 'w') as file: | ||
json.dump(data, file, indent=2) | ||
|
||
if __name__ == "__main__": | ||
# Example usage | ||
file_path = "result_dirs/zebra-grid/gpt-4o-mini-2024-07-18.json" | ||
follow_up_mode = "self_verification" | ||
output_file = "result_dirs_follow_up/zebra-grid/gpt-4o-mini-2024-07-18.self_verification.T=1.json" | ||
add_follow_up_instruction(file_path, output_file, follow_up_mode) # Call the function to add follow-up instruction | ||
|
||
file_path = "result_dirs/zebra-grid/gpt-4o-2024-08-06.json" | ||
output_file = "result_dirs_follow_up/zebra-grid/gpt-4o-2024-08-06.self_verification.T=1.json" | ||
add_follow_up_instruction(file_path, output_file, follow_up_mode) # Call the function to add follow-up instruction | ||
|
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,7 @@ | ||
SELF_VERIFICATION = """ | ||
Please review the initial prompt, including the question and the constraints or requirements provided. | ||
Reassess your reasoning and the answer you provided to ensure they align with the given information. | ||
If any adjustments are needed, modify your reasoning and answer accordingly. | ||
Finally, present your response in the same JSON format mentioned in the initial prompt. | ||
If the original answer was already correct, you can simply repeat it in the same JSON format. | ||
""" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Initialize default values | ||
DATA_NAME="zebra-grid" | ||
# model_name="openai/gpt-4o-mini-2024-07-18" | ||
# model_pretty_name="gpt-4o-mini-2024-07-18.self_verification.T=1" | ||
model_name="openai/gpt-4o-2024-08-06" | ||
model_pretty_name="gpt-4o-2024-08-06.self_verification.T=1" | ||
n_shards=8 | ||
run_name="self_verification" | ||
TEMP=0 | ||
TOP_P=1.0 | ||
rp=1.0 | ||
engine_name="openai" | ||
MAX_TOKENS=4096; | ||
num_outputs=1 # New default value | ||
batch_size=4; | ||
CACHE_DIR=${HF_HOME:-"default"} | ||
|
||
|
||
# Check if required arguments are provided | ||
if [ -z "$DATA_NAME" ] || [ -z "$model_name" ] || [ -z "$model_pretty_name" ] || [ -z "$n_shards" ]; then | ||
echo "Usage: $0 -d DATA_NAME -m model_name -p model_pretty_name -s n_shards [-r run_name] [-t TEMP] [-o TOP_P] [-e rp] [-f engine_name] [-n num_outputs]" | ||
exit 1 | ||
fi | ||
|
||
# output_dir="result_dirs/${DATA_NAME}/cot=${cot}/" | ||
if [ "$run_name" = "default" ]; then | ||
output_dir="result_dirs/${DATA_NAME}/" | ||
else | ||
output_dir="result_dirs/${DATA_NAME}/${run_name}/" | ||
fi | ||
|
||
|
||
echo "Using Data-parallelism" | ||
shards_dir="${output_dir}/tmp_${model_pretty_name}" | ||
for ((shard_id = 0; shard_id < $n_shards; shard_id++)); do | ||
python src/unified_infer.py \ | ||
--follow_up_mode "self_verification" \ | ||
--follow_up_file "result_dirs_follow_up/zebra-grid/${model_pretty_name}.json" \ | ||
--num_shards $n_shards \ | ||
--shard_id $shard_id \ | ||
--data_name $DATA_NAME \ | ||
--engine $engine_name \ | ||
--model_name $model_name \ | ||
--run_name $run_name \ | ||
--model_pretty_name $model_pretty_name \ | ||
--top_p $TOP_P --temperature $TEMP --repetition_penalty $rp \ | ||
--batch_size $batch_size --max_tokens $MAX_TOKENS \ | ||
--num_outputs $num_outputs \ | ||
--output_folder $shards_dir/ \ | ||
& | ||
done | ||
wait | ||
python src/merge_results.py $shards_dir/ $model_pretty_name | ||
cp $shards_dir/${model_pretty_name}.json $output_dir/${model_pretty_name}.json | ||
|