Giter Site home page Giter Site logo

Comments (2)

maxjeblick avatar maxjeblick commented on June 12, 2024

Thanks a lot for posting, interesting findings!

I've checked Perplexity implementation, code-wise I haven't found any issues.
For Dpo, validation loss and perplexity may exhibit different behavior, as dpo calculation is using
policy_chosen_logps - policy_rejected_logps - (reference_chosen_logps - reference_rejected_logps)
whereas Perplexity is using chosen_logits, only.

It is probably a good idea to add additional train/validation metrics (that will be logged to neptune) such as CE loss to better track the experiment.
I've created this branch where SampleAveragedCrossEntropyLoss is used as a validation loss and ran some experiments on it. So far, val loss is in sync with Perplexity.
Screenshot 2024-02-05 at 13-01-52 H2O LLM Studio

from h2o-llmstudio.

maxjeblick avatar maxjeblick commented on June 12, 2024

I digged a bit deeper into the loss curves in this branch; cross entropy is logged for both accepted as well as rejected samples; alongside with the corresponding perplexity.

Regarding the different behavior of loss vs. perplexity, my explanation for this is that evaluation samples the model struggles to predict can disproportionately impact the overall perplexity.

As an example, suppose we have a dataset with 4 samples where the third sample is out-of-distribution of the SFT model.

  • After epoch 1, suppose the model has the following cross entropy loss for each sample: (1, 1, 9, 1) (third answer is hard to predict).
    Mean cross-entropy (cross-entropy per sample / num_samples) will be 12/4 = 3
    Mean perplexity (perplexity per sample / num_samples) will be mean([exp(1), exp(1), exp(9), exp(1)]) ~ 2027.8.
  • After epoch 2, suppose the model has the following cross entropy loss for each sample: (4, 4, 4, 4) (model adapts to third sample at the cost of predicting the other samples worse)
    Mean cross-entropy will be 16/4 = 4
    Mean perplexity will be exp(4) / 4 ~ 13.6

My assumption is that this explains the behavior observed (and it is not caused by a bug).

from h2o-llmstudio.

Related Issues (20)

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.