DPO Training ruins my model’s conversational coherence A developer reports that DPO training ruins the conversational coherence of a T5 model, causing it to output repetitive tokens like 'a a a a a a' or 'b b b b b b b' during inference. The issue emerges only after DPO training, not after fine-tuning, and persists even when using the pre-trained 't5-small' model. Hi, I am running some tests with DPOTrainer to see how it works but I have encou … ntered some problems during the inference phase of the generated model. In details, this is the pipeline of operations I performed: 1. I pre-trained from scratch a T5 model on natural language English language . For this operation, I followed the instructions of the Hugging Face library. https://github.com/huggingface/transformers/tree/main/examples/flax/language-modeling As for training the tokenizer, this was done using the sentencepiece library https://github.com/google/sentencepiece . The generated file extension .model was then used through the T5Tokenizer class, which allows using the .model file instead of a json file. 2. I fine-tuned T5 using a very trivial dataset such as the following. | Input | Target | |-------------------------------------------|--------| | I love cats | a | | The cat is orange | b | | The cat is on the table | c | | The cat chased the mouse under the table. | d | In summary, if there is no word 'the' in the input then the output will be 'a', if there is only one occurrence of 'the' then the output will be 'b', and so on... For fine-tuning, I did not use the SFTTrainer class but the classic Seq2SeqTrainer. 3. Then, I performed the DPO with the same inputs as the dataset present above, but in the JSON format. The code used is the same as the example on the repository https://github.com/huggingface/trl/blob/main/examples/research projects/stack llama 2/scripts/dpo llama2.py . In this case, however, we used our finetuned T5 model and tokenizer with classes T5ForConditionalGeneration, T5Tokenizer, T5Config . You can find the JSON file and the full code at the end of this message. The problem arises in the inference phase of the model generated by the DPOTrainer. In fact, for several instances the output generated by the model is 'a a a a a a', ' b b b b b b b', 'c c c c c c c c', and so on... the number of repetitions of the class is variable . Moreover, this behavior becomes more pronounced as the number of steps increases. Also, as the number of steps increases, words that are part of the train set are generated in the output e.g., 'aaacat' is generated . I cannot figure out what could be the cause of this behavior. By making inference of the simply fine-tuned model, the output generated is as expected i.e., a class between 'a', 'b', 'c' and 'd' , so the problem is introduced during training with DPO. I also tried to use the pre-trained 't5-small' model / tokenizer instead of the ones trained from scratch, but the problem still persists. I look forward to your feedback should more information or snippets of code used be needed.