Giter VIP home page Giter VIP logo

Comments (2)

fartashf avatar fartashf commented on June 13, 2024 1

Thanks for reporting.
Generally, we observed that MAX loss can be harder to optimize. There are ways to reduce the difficulty:

  • Train with the SUM loss and make sure it achieves a reasonable performance. This is rather a sanity check for the rest of your code.
  • Stage-wise optimization. First, start from pretrained encoders and train only the embedding, then switch to fine-tuning and train end-to-end.
  • Tune the batch size. I expect the optimal batch size for MAX loss to be dataset-dependent. If the batch size is too large hard negatives can be outliers. If they are too small, it can take longer to train or the best we end up with is bounded by the SUM loss.
  • We have unpublished studies on the effect of a separate negative set. On MSCOCO, it happended that the optimal negative set size was the same as the batch size used (128). Depending on your setting, a large negative set could be cheaper. You can trade-off speed for a larger negative set. Choose a large negative set, compute all embeddings, get rid of activations for memory saving, match your mini-batch to a single example in the negative set, then do another forward pass only for selected pairs.
    Here is a plot for varying the negative set size on MSCOCO. figure

from vsepp.

mesnico avatar mesnico commented on June 13, 2024

Thank you very much for these hints. Actually, I think that the stage-wise optimization is the way to go. If I first optimize using SUM loss and then I resume, after 10 epochs, using MAX loss, the problem disappears and the validation metrics keep increasing smoothly.

However, I will pay attention also to the batch size, as you suggested.
Thanks again

from vsepp.

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.