Skip to main content

UltraMem

Project description

UltraMem

Implementation of UltraMem, improved Product Key Memory design, from Bytedance AI labs

Install

$ pip install ultra-mem

Usage

import torch
from ultra_mem import UltraMem

ultra_mem = UltraMem(
    dim = 512,
    core_heads = 2,
    topk = 32,
)

tokens = torch.randn(1, 1024, 512)

out, mem_indices, aux_loss = ultra_mem(tokens) # (1, 1024, 512), (2, 1, 1024, 32), ()

Char-level LM

$ uv run train.py

Citations

@misc{huang2025ultrasparsememorynetwork,
    title   = {Ultra-Sparse Memory Network}, 
    author  = {Zihao Huang and Qiyang Min and Hongzhi Huang and Defa Zhu and Yutao Zeng and Ran Guo and Xun Zhou},
    year    = {2025},
    eprint  = {2411.12364},
    archivePrefix = {arXiv},
    primaryClass = {cs.LG},
    url     = {https://arxiv.org/abs/2411.12364}, 
}
@inproceedings{Lin2025ContinualLV,
    title   = {Continual Learning via Sparse Memory Finetuning},
    author  = {Jessy Lin and Luke S. Zettlemoyer and Gargi Ghosh and Wen-tau Yih and Aram H. Markosyan and Vincent-Pierre Berges and Barlas Ouguz},
    year    = {2025},
    url     = {https://api.semanticscholar.org/CorpusID:282203348}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ultra_mem-0.1.2.tar.gz (36.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ultra_mem-0.1.2-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file ultra_mem-0.1.2.tar.gz.

File metadata

  • Download URL: ultra_mem-0.1.2.tar.gz
  • Upload date:
  • Size: 36.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for ultra_mem-0.1.2.tar.gz
Algorithm Hash digest
SHA256 b3e8b06d289a1c24cc0c983b9704544eec6c1d2a7d43b2d7d9adb91600fe4b47
MD5 a580803e044fa724703eaaf1699531d2
BLAKE2b-256 c08eb9db4669f413ac8da7ad7d1a8c6d039e4b95ee460f6589a5b501011af25a

See more details on using hashes here.

File details

Details for the file ultra_mem-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: ultra_mem-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for ultra_mem-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a0914e032b78d32ff09adb9e9856c970ad0adf40d69c507dfd5f42e069352841
MD5 bf686003ae57dcf8ac683053ec16923b
BLAKE2b-256 8355add0886d9c51395ba343e3825b085a0fb2b52fde7024d61ba50d5ec74ca5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page