Recurrent Transformer (wip)
Explorations into the Recurrent Transformer proposed by Costin-Andrei Oncescu et al. of Harvard University
Usage
import torch
from recurrent_transformer import RecurrentTransformer
model = RecurrentTransformer(
num_tokens = 256,
dim = 512,
depth = 6,
recurrent = True
)
tokens = torch.randint(0, 256, (2, 1024))
# forward for loss
loss = model(tokens, return_loss = True)
loss.backward()
# generate
prompt = torch.randint(0, 256, (2, 32))
sampled = model.generate(prompt, 128) # (2, 128)
Train
Train on enwik8, validating at the trained length and extrapolated length
$ uv run train_enwik8.py
Citations
@misc{oncescu2026recurrenttransformergreatereffective,
title = {The Recurrent Transformer: Greater Effective Depth and Efficient Decoding},
author = {Costin-Andrei Oncescu and Depen Morwani and Samy Jelassi and Alexandru Meterez and Mujin Kwun and Sham Kakade},
year = {2026},
eprint = {2604.21215},
archivePrefix = {arXiv},
primaryClass = {cs.LG},
url = {https://arxiv.org/abs/2604.21215},
}
@misc{bahdanau2014neural,
title = {Neural Machine Translation by Jointly Learning to Align and Translate},
author = {Dzmitry Bahdanau and Kyunghyun Cho and Yoshua Bengio},
year = {2014},
eprint = {1409.0473},
archivePrefix = {arXiv},
primaryClass = {cs.CL},
url = {https://arxiv.org/abs/1409.0473}
}
@Article{AlphaFold2021,
author = {Jumper, John and Evans, Richard and Pritzel, Alexander and Green, Tim and Figurnov, Michael and Ronneberger, Olaf and Tunyasuvunakool, Kathryn and Bates, Russ and {\v{Z}}{\'\i}dek, Augustin and Potapenko, Anna and Bridgland, Alex and Meyer, Clemens and Kohl, Simon A A and Ballard, Andrew J and Cowie, Andrew and Romera-Paredes, Bernardino and Nikolov, Stanislav and Jain, Rishub and Adler, Jonas and Back, Trevor and Petersen, Stig and Reiman, David and Clancy, Ellen and Zielinski, Michal and Steinegger, Martin and Pacholska, Michalina and Berghammer, Tamas and Bodenstein, Sebastian and Silver, David and Vinyals, Oriol and Senior, Andrew W and Kavukcuoglu, Koray and Kohli, Pushmeet and Hassabis, Demis},
journal = {Nature},
title = {Highly accurate protein structure prediction with {AlphaFold}},
year = {2021},
doi = {10.1038/s41586-021-03819-2},
note = {(Accelerated article preview)},
}
@inproceedings{ren2026rethinking,
title = {Rethinking Expressivity and Degradation-Awareness in Attention for All-in-One Blind Image Restoration},
author = {Bin Ren and Runyi Yang and Qi Ma and Xu Zheng and Mengyuan Liu and Danda Pani Paudel and Luc Van Gool and Rita Cucchiara and Nicu Sebe},
booktitle = {The Fourteenth International Conference on Learning Representations},
year = {2026},
url = {https://openreview.net/forum?id=IBzmQVia88}
}
@inproceedings{press2022train,
title = {Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation},
author = {Ofir Press and Noah A. Smith and Mike Lewis},
booktitle = {International Conference on Learning Representations},
year = {2022},
url = {https://openreview.net/forum?id=R8sQPpGCv0}
}
Metadata
Release files for recurrent-transformer-pytorch 0.0.17
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| recurrent_transformer_pytorch-0.0.17.tar.gz | 15.4 kB | Without provenance | Details for recurrent_transformer_pytorch-0.0.17.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| recurrent_transformer_pytorch-0.0.17-py3-none-any.whl | Python 3 | none | any | Details for recurrent_transformer_pytorch-0.0.17-py3-none-any.whl |
Total release size: 30.7 kB
Release files / recurrent_transformer_pytorch-0.0.17.tar.gz
| Download URL | recurrent_transformer_pytorch-0.0.17.tar.gz |
|---|---|
| Size | 15.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b6fbe54c4589b0953ec7509f3ec67fe4cdd74dd07b2748b101366ce26a523d30
|
|
BLAKE2b-256 checksum How to use checksums |
5c01298cad605695944ca616e70f7a4a21a79cd2e5f1239a600380e49b4f5754
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.17
|
Release files / recurrent_transformer_pytorch-0.0.17-py3-none-any.whl
| Download URL | recurrent_transformer_pytorch-0.0.17-py3-none-any.whl |
|---|---|
| Size | 15.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ec2e68a5cb01873097af2e4bdd17825e20e4dd093a466cee15be6c8bd5feb081
|
|
BLAKE2b-256 checksum How to use checksums |
0ba5a6d1607fb6fb303bd16a4c9cbc4be2f3c6c6f54c8e6412de3c452ddedc46
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.17
|
Security for recurrent-transformer-pytorch 0.0.17
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.