Coder Social home page Coder Social logo

Comments (5)

calclavia avatar calclavia commented on June 19, 2024

@yyht A few questions:

  • Did you initialize \alpha to zero?
  • How did you initialize the embedding matrix? We found that GPT2's embedding initialization doesn't work very well.

from rezero.

yyht avatar yyht commented on June 19, 2024
  1. I initizlied \alpha to zero
  2. the initialization are followed by official BERT initialization:
    ebmbedding matrix and kernel matrix are initialized via:
    def create_initializer(initializer_range=0.02):
    """Creates a truncated_normal_initializer with the given range."""
    return tf.truncated_normal_initializer(stddev=initializer_range)

from rezero.

calclavia avatar calclavia commented on June 19, 2024

Try initializing the embedding matrix to uniform distribution drawn from +- 1 / d.

from rezero.

sooheon avatar sooheon commented on June 19, 2024

@calclavia can you give a little more insight into reasoning for this embedding init recommendation? Curious if it's motivated by empirical performance or other theoretical justification.

from rezero.

calclavia avatar calclavia commented on June 19, 2024

@sooheon It depends on the particular implementation of your Transformer. Some implementations (Huggingface) scale the embedding by 1 / d before padding it into higher layers while initializing the embedding with a uniform distribution (-1 to + 1). This effectively does the same thing as initializing it as +- 1/d.

The reasoning for this initialization is less to do with our paper - we simply follow what previous work has recommended. I believe the Attention is all your need paper recommended 1/d scaling for attentional softmax (when d is large). By scaling to 1/d, the gradients for the softmax layer is more well behaved.

The same principle is applied to the output softmax when predicting output vocabularies. When Rezero initializes the Transformer layers to zero, it essentially starts off as a pass-through from input embedding directly to output embedding. Having 1/d initialization ensures the gradients as well behaved.

from rezero.

Related Issues (16)

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.