Coder Social home page Coder Social logo

Implementation with RoPE about lm-infinite HOT 2 CLOSED

sdc17 avatar sdc17 commented on June 9, 2024 1
Implementation with RoPE

from lm-infinite.

Comments (2)

Glaciohound avatar Glaciohound commented on June 9, 2024 1

Hello! Thanks for your interests in our work!

Basically, the difference in rotating angles determines the "attention distance" between two tokens. For example, in original RoPE encoding, every token at position $i$ is just rotated with angle $i\theta$. Then the dot product between query at $i$: $q_i$ and key at position $j$: $k_j$, i.e., $q_i^\top k_j$, depends only on $i-j$. (For why this is the case, a more detailed explanation and derivation can be found in the original paper. Basically the authors carefully constructed the mechanism just to achieve this effect!)

Going back to our work, we want to let "global branch" tokens be exactly $L_{pretrain}$ distance when being attended, regardless of their "true" distance. So a token at position 100 being attended by another token at position 8k will be attended "as if" the distance is $L_{pretrain}$ instead of $8k-100=7900$. To achieve this effect efficiently, in global branch only, we rotate all $k$ vector by angle $0$, rotate all $q$ vectors by angle $L_{pretrain}\theta$, then for the same reason mentioned above, their attention will always be as if their distances are $L_{pretrain}$.

Does this make sense to you? Feel free to follow up if I missed anything!

from lm-infinite.

sdc17 avatar sdc17 commented on June 9, 2024

Truly helpful explanations, thanks!

from lm-infinite.

Related Issues (9)

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.