Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about the right position to encode retrieved #11

Closed
soheeyang opened this issue Apr 10, 2022 · 2 comments
Closed

Question about the right position to encode retrieved #11

soheeyang opened this issue Apr 10, 2022 · 2 comments

Comments

@soheeyang
Copy link
Contributor

soheeyang commented Apr 10, 2022

Hi, I am currently reading through the code and got confused when I reached this line:

retrieved = self.encoder(retrieved, mask = encoder_retrieved_mask, chunked_seq = embed_as_context)

image
According to Algorithm 1 in the paper (the screenshot above), doesn't this line need to go inside the decoder, under this line?

if exists(cross_attn) and exists(retrieved):

This is an example of how I think the code of decoder.forward should be.

def forward(self, x, *, context_mask = None, retrieved = None):
  encoded = False  # flag to know if p = min(P) (in the algorithm)
  ...
    if exists(cross_attn) and exists(retrieved):
      if not encoded:
        ...
        # use x (H at layer p where p = min(P)), not embed (Emb(X))
        x_as_context = repeat(x[:, :seq_index], 'b (k n) d -> (b k r) n d', n = self.chunk_size, r = num_neighbors)
        retrieved = self.encoder(retrieved, mask = encoder_retrieved_mask, chunked_seq = x_as_context)
        encoded = True
@lucidrains
Copy link
Owner

@soheeyang Hi Sohee again! Yet again you discovered another bug :( I apologize for this and have made a correction in the latest commit (v0.3.0) 4f99e31

@soheeyang
Copy link
Contributor Author

@lucidrains Hi Phil, thank you so much for the prompt fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants