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

About mistakes in the implementation of SMA #18

Open
renll opened this issue Feb 7, 2024 · 0 comments
Open

About mistakes in the implementation of SMA #18

renll opened this issue Feb 7, 2024 · 0 comments

Comments

@renll
Copy link

renll commented Feb 7, 2024

Thanks for the great work. I think the implementation of SMA has some mistakes.

  1. The original SMA takes the logarithm during initialization and the exponential during forward path to ensure that the temperature scaler is larger than zero:
    https://github.com/renll/SeqBoat/blob/5a34aed3c573858630ec64b0f2c4a22948962947/fairseq/modules/seqboat_utils.py#L166

But it seems that this trick is lacked in the zoology implementation:

self.temperature = nn.Parameter(torch.ones(1) * math.sqrt(d_model) * alpha)

  1. The original SMA selects the inputs tokens for the attention module:
    https://github.com/renll/SeqBoat/blob/5a34aed3c573858630ec64b0f2c4a22948962947/fairseq/modules/seqboat_unit.py#L603
    but the Zoology one only selects the output:
    y = attn_output * selection + x
@renll renll changed the title About a small mistake in the implementation of SMA About mistakes in the implementation of SMA Feb 16, 2024
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

1 participant