Fast Weight Product Key Memory
Project description
Fast Weight Product Key Memory
Implementation of the Fast Weight Product Key Memory proposed by Sakana AI
Appreciation
- Pranoy for the contribution of multi-head variant!
Install
$ pip install fast-weight-product-key-memory
Usage
import torch
from fast_weight_product_key_memory import fwPKM
mem = fwPKM(
dim = 512,
num_memories = 256 * 256,
dim_queries_keys = 512,
dim_values = 512,
topk = 8,
learning_rate = 1.,
chunk_size = 256
)
tokens = torch.randn(2, 256, 512)
# forward a chunk of tokens for retrieved and the fast weight episodic memories
retrieved, next_memories = mem(tokens, return_next_memories = True)
# chain memories
retrieved, next_memories = mem(tokens, return_next_memories = True, past_memories = next_memories)
retrieved, next_memories = mem(tokens, return_next_memories = True, past_memories = next_memories)
retrieved, next_memories = mem(tokens, return_next_memories = True, past_memories = next_memories)
Enwik8
Character-level language model with fwPKM
$ uv run train_enwik8.py
Citations
@misc{zhao2026fastweightproductkeymemory,
title = {Fast-weight Product Key Memory},
author = {Tianyu Zhao and Llion Jones},
year = {2026},
eprint = {2601.00671},
archivePrefix = {arXiv},
primaryClass = {cs.CL},
url = {https://arxiv.org/abs/2601.00671},
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fast_weight_product_key_memory-0.1.4.tar.gz.
File metadata
- Download URL: fast_weight_product_key_memory-0.1.4.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
041c3709bbbefde4fdf03f785c32f0e83e0cadb29ce530210174829ea6024538
|
|
| MD5 |
433d1c57fce4d0430a58a6d6176ca74a
|
|
| BLAKE2b-256 |
ec50ffa56e9ad039ba851ea07e938680f21b8439ca476ef25f78d9aca44f2671
|
File details
Details for the file fast_weight_product_key_memory-0.1.4-py3-none-any.whl.
File metadata
- Download URL: fast_weight_product_key_memory-0.1.4-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
91519a005d84be78f4072e89bcd7c56b6cf1de2342be27ec36b504f803e9844f
|
|
| MD5 |
a88470f70dbf6e1d495357a106a102db
|
|
| BLAKE2b-256 |
310b445095c6a38733b6bb2063512189f99a8150af787ef85b04e1b6091c944f
|