import torch
import torch.nn.purposeful as F
class DPOTrainer:
def __init__(self, mannequin, ref_model, beta=0.1, lr=1e-5):
self.mannequin = mannequin
self.ref_model = ref_model
self.beta = beta
self.optimizer = torch.optim.AdamW(self.mannequin.parameters(),…
![](https://terracyborg.com/wp-content/uploads/2024/08/DALL·E-2024-08-09-00.38.43-An-anime-style-cartoon-featuring-a-minimalist-forest-setting-where-a-dog-is-following-machines.-The-scene-is-set-in-a-serene-lush-forest-with-tall-tr-1000x600.webp-840x473.webp)