Giter Site home page Giter Site logo

agop_feature_learning's People

Contributors

aradha avatar aradha5772 avatar dmbeaglehole avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

agop_feature_learning's Issues

Clarification about verifying NFM Ansatz for Transformer

Hi I just wanted some clarification on the logic when verifying the NFM ansatz for transformers as implemented in /ansatz_verification/transformers/language_models/verify_ansatz.py

  1. In check_ansatz you seem to be applying dropout to the input to our original transformer before running it through all the layers - why is this done?
 with torch.no_grad():
            n, t = x.shape
            pos = torch.arange(0, t, dtype=torch.long, device='cuda')
            z = Q.drop(Q.wpe(pos) + Q.wte(x))

            for i in range(layer_idx):
                z = Q.h[i](z)
  1. Directly after the above step, z is the output after running the input tensor through layer_idx+1 full blocks of our transformer, but we then seem to arbitrarily apply the layernorm for the layer_idx+1th block corresponding to its CausalSelfAttention module- why is this done? From my understanding z should already be normalized (and in particular, has already passed through ln_2).
 with torch.no_grad():
            ln_z1 = Q.h[layer_idx].ln_1(z).unsqueeze(0)
            ln_z2 = deepcopy(ln_z1)
            ln_z3 = deepcopy(ln_z1)
            ln_z = deepcopy(ln_z1)
  1. Also, since it seems like the goal is to evaluate the NFM for attention, why are we taking the output of each block after it has already passed through the MLP layers for the corresponding block - shouldn't we hook in and get it right after it passes through our attention block?

  2. When we actually seek to get the jacobian of the model we run the renormalized ln_z1,...,ln_z back through the network using the newGPT object. Why are we passing the outputs of the network from the block at layer_idx back through the same network? Shouldn't we be passing in tokens corresponding to the text that we care about (i.e. x) and then extract the gradients for the attention matrices we care about?

 J = get_jacobian(newGPT, [z.unsqueeze(0), ln_z1, ln_z2, ln_z3, ln_z],
                                 BATCH_SIZE=BATCH_SIZE,
                                 IDX=IDX,
                                 OUT_SIZE=OUT_SIZE,
                                 OUT_IDX=OUT_IDX)

It's possible that I'm misunderstanding the implementation somewhat but I'd love to apply this work to some other transformer analysis and I'd like to know how these quantities are actually computed in your paper - thank you!

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.