GithubHelp home page GithubHelp logo

mask error about flash-pytorch HOT 6 CLOSED

lucidrains avatar lucidrains commented on May 29, 2024 1
mask error

from flash-pytorch.

Comments (6)

marsggbo avatar marsggbo commented on May 29, 2024 1

@lucidrains thanks for your quick reply. I double check the code and understand that the causal_mask will be created when causal==True and everything is well taken care of.

However, I'm curious about these parts below.

if exists(mask):
lin_mask = rearrange(mask, '... -> ... 1')
lin_k = lin_k.masked_fill(~lin_mask, 0.)

if exists(mask):
attn = attn.masked_fill(~mask, 0.)

In summary, my two question is:
By default, mask=None, what is this variable for and what is the difference between mask and causal_mask?

from flash-pytorch.

lucidrains avatar lucidrains commented on May 29, 2024

@keyunluo oops! should be fixed here 8e0d2fd

from flash-pytorch.

marsggbo avatar marsggbo commented on May 29, 2024

In vanilla multi-head transformer, the mask is an upper triangle matrix and the shape of mask is [bs, n_head, seq, seq]. But here, the shape of mask is [bs, seq]. Is any explanation for this? How do we set the mask for mixed chunk attention, performing similarly to the upper triangle matrix?

from flash-pytorch.

lucidrains avatar lucidrains commented on May 29, 2024

@marsggbo just set causal = True and everything is taken care of

from flash-pytorch.

lucidrains avatar lucidrains commented on May 29, 2024

@marsggbo the mask is for non-causal variable lengthed sequences

from flash-pytorch.

lucidrains avatar lucidrains commented on May 29, 2024

mask is for bidirectional attention (like BERT)

you often have sequences of variable lengths, so you would use the mask to only attend to non-padding tokens

from flash-pytorch.

Related Issues (12)

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.