You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An officially supported task in the examples folder
My own task or dataset (give details below)
Reproduction
fromtransformersimportAutoTokenizerfromtrl.trainer.utilsimportDataCollatorForChatMLtokenizer=AutoTokenizer.from_pretrained("meta-llama/Llama-3.2-1B-Instruct")
tokenizer.pad_token_id=tokenizer.eos_token_idtokenizer.pad_token=tokenizer.eos_tokendata_collator=DataCollatorForChatML(tokenizer)
examples= [
{
"messages": [
{"role": "system", "content": "You are a professional translator."},
{"role": "user", "content": "Hello!"},
{"role": "assistant", "content": "Hi there! How can I help you today?"},
],
},
]
batch=data_collator(examples)
print(tokenizer.decode(batch["input_ids"][0]))
label=batch["labels"][0]
label[label==-100] =tokenizer.eos_token_idprint(tokenizer.decode(label))
outputs:
<|begin_of_text|><|start_header_id|>system<|end_header_id|>
Cutting Knowledge Date: December 2023
Today Date: 07 Dec 2024
You are a professional translator.<|eot_id|><|start_header_id|>user<|end_header_id|>
Hello!<|eot_id|><|start_header_id|>assistant<|end_header_id|>
Hi there! How can I help you today?<|eot_id|><|start_header_id|>assistant<|end_header_id|>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Hi there! How can I help you today?<|eot_id|><|start_header_id|>assistant<|end_header_id|>
Expected behavior
When processing instruction tuning, the model is not expected to generate <|start_header_id|>assistant<|end_header_id|> after <|eot_id|>. The correct model response should be Hi there! How can I help you today?<|eot_id|>.
System Info
Information
Tasks
examples
folderReproduction
outputs:
Expected behavior
When processing instruction tuning, the model is not expected to generate
<|start_header_id|>assistant<|end_header_id|>
after<|eot_id|>
. The correct model response should beHi there! How can I help you today?<|eot_id|>
.We should change
trl/trainer/utils.py L276:277
Checklist
The text was updated successfully, but these errors were encountered: