aradha / agop_feature_learning Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
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
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)
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+1
th 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)
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?
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!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.