Giter Site home page Giter Site logo

lucidrains / block-recurrent-transformer-pytorch Goto Github PK

View Code? Open in Web Editor NEW
210.0 8.0 18.0 35.04 MB

Implementation of Block Recurrent Transformer - Pytorch

License: MIT License

Python 100.00%
artificial-intelligence attention-mechanisms deep-learning long-context-attention long-context-transformers memory recurrence

block-recurrent-transformer-pytorch's People

Contributors

lucidrains avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

block-recurrent-transformer-pytorch's Issues

It seems line 942 states = [] is override states from params

def generate(
    self,
    prime,
    length = None,
    xl_memories: List[torch.Tensor] = [],
    states: List[torch.Tensor] = [],
    temperature = 1.,
    filter_thres = 0.9,
    return_memories_and_states = False
):
    length = default(length, self.max_seq_len + 1)
    start_len = prime.shape[-1]

    assert start_len < self.max_seq_len
    assert length <= (self.max_seq_len + 1)
    assert start_len < length

    output = prime

    memories = []
    states = []

    for ind in range(length - start_len):

Question

Is it supposed to detach?

Inside block_recurrent_transformer_pytorch.py line 815

if exists(layer_next_states):
next_states.append(layer_next_states.detach())

How would the gradients flow through the states?

recurrent state

Hi, i noticed that recurrent state keys and values are derived from self.init_state rather than previous recurrent state. In this case, the keys and value embedding layers, along with the projection and MLP layers for horizontal attention will not be trained? I am not sure if this is the intended behavior as I could not find any details regarding this in the paper.

Incorrect pip install in README

Hello, I believe there is a typo in the "Install" section of the readme.

Instead of:

pip install block-recurrent-transformer

I used this:

pip install block-recurrent-transformer-pytorch

Suggestion

Can you try to input the recurrent state to the first transformer layer? Like a recurrent layer but without next state? Maybe that will improve the performance since high level representations don't have to be recomputed and remembered info can be passed through the whole model again without any additional compute cost

Cross attention wrong query vector

Hi, in the AttentionBlock forward function, the vertical attention is computing cross-attention with Qe^v instead of Qs^v? Same goes for the horizontal direction, it is computing using Qs^h instead of Qe^h.

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.