Giter Site home page Giter Site logo

dpo's Introduction

DPO

Direct Preference Optimization Implementation

image

  1. Loss function of policy model with respect to reference model.
  2. Expectation of the dataset with ‘x’ samples of ‘yw’ winner (chosen) and ‘yl’ loser (rejected) outputs.
  3. The logarithmic of the sigmoid applied to the argument. In torch: ‘F.logsigmoid’ This will scale the result between 0 and 1, providing a probabilistic interpretation.
  4. Beta: Hyperparameter that weights the importance of the deviation between the policy model and the reference model.
  5. Log Probability (in torch: log_softmax) ratio of the policy model’s probability of choosing the same ‘yw’ given the input ‘x’, divided by the reference model’s probability of choosing the same ‘yw’ given the same input ‘x’. These rations indicate how much more or less likely the policy model is to choose a particular action compared to the reference model.

The formula calculates the difference between the log probability rations for the chosen and rejected actions, scaled by Beta, and then applies the sigmoid function to this difference.

The expectation ‘E’ of this value across the dataset provides a measure of how well the policy model aligns with the human preferences as exhibited by the chosen and rejected outputs.

The loss function ‘L’ is then minimized during training to adjust the parameters of the policy model so that it more closely aligns with the human-labeled preferences. By doing this, the policy model’s behavior should become more similar to the desired behavior as indicated by the reference model and the human choices in the dataset. The use of the sigmoid function ensures that the loss is bounded and that the optimization process is stable.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.