Skip to content

Why is dividing by e**(1/4) for both keys and queries more memory efficient? #5

@esvhd

Description

@esvhd

Hi,

Would you mind explaining why the follow code is more memory efficient than just dividing one of them by sqrt(e)?

former/former/modules.py

Lines 48 to 52 in 7b12ae6

queries = queries / (e ** (1/4))
keys = keys / (e ** (1/4))
# - Instead of dividing the dot products by sqrt(e), we scale the keys and values.
# This should be more memory efficient

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions