Skip to content

Commit

Permalink
Merge pull request #159 from dividez/fix_rl_training
Browse files Browse the repository at this point in the history
Update rl_training.py
  • Loading branch information
shibing624 authored Aug 9, 2023
2 parents 53e166c + 6ba6ba1 commit e253502
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions rl_training.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,16 +348,19 @@ def preprocess_function(examples):
"query": [],
"input_ids": [],
}
for instruction, input in zip(examples['instruction'], examples['input']):
if input:
instruction = instruction + "\n" + input
source = PROMPT_TEMPLATE.format_map({"instruction": instruction})
tokenized_question = tokenizer(
source, truncation=True, max_length=max_source_length, padding="max_length",
return_tensors="pt"
)
new_examples["query"].append(source)
new_examples["input_ids"].append(tokenized_question["input_ids"])
for conversation in examples['conversations']:
for message in conversation:
instruction = message['value']
input = message['from']
if input:
instruction = instruction + "\n" + input
source = PROMPT_TEMPLATE.format_map({"instruction": instruction})
tokenized_question = tokenizer(
source, truncation=True, max_length=max_source_length, padding="max_length",
return_tensors="pt"
)
new_examples["query"].append(source)
new_examples["input_ids"].append(tokenized_question["input_ids"])

return new_examples

Expand Down

0 comments on commit e253502

Please sign in to comment.