Skip to content

Commit

Permalink
State_Action file transformation
Browse files Browse the repository at this point in the history
  • Loading branch information
SQLai2099 committed Apr 14, 2024
1 parent fc4cd7f commit bb38451
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions finetune/state_action_2_instructions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import argparse
from utils.my_utils import load_json, getPrompt, state2text, dump_json

def main(input_file, output_file):
state_action_data = load_json(input_file)
instructions = []

for data in state_action_data:
state = data['state']
instruction = getPrompt(state2text(state))[-1]['content']
output = data['prompt'][-1]['content'] if 'content' in data['prompt'][-1] else data['prompt'][-1]

instructions.append({
"instruction": instruction,
"input": "",
"output": output
})

dump_json(instructions, output_file)

if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Process state-action data and generate instructions.")
parser.add_argument("input_file", help="Input file path")
parser.add_argument("output_file", help="Output file path")
args = parser.parse_args()
main(args.input_file, args.output_file)

0 comments on commit bb38451

Please sign in to comment.