#181 · Primary category: Deep Learning Frameworks
local-attention
An implementation of local windowed attention for language modeling
Project last updated:07/16/25
GitHub Stars
503
Forks
49
Contributors
3
License
MIT
Why we included this project
Full self-attention is usually the bottleneck in a long-context transformer, since the cost grows quadratically with sequence length. This library takes the practical route of windowed attention: each position attends only to tokens within a configurable window, with an option to also look back at the previous window. That keeps memory and compute costs much lower while keeping language-modeling quality strong, and the author has already used the same code in several other sparse-attention projects. It is a plain PyTorch module that drops into an existing training loop: you pick the window size, decide whether attention is causal, and flags handle lookback, shared query/key space for Reformer-style models, and automatic padding. A LocalTransformer wrapper shows how the windowed layer slots into a complete transformer stack, which makes it a handy reference even if you end up wiring the pieces yourself.
Articles for this project
No articles for this project yet.
To suggest a topic or contribute an article, contact us.
Related projects in this category
tensorflow
An Open Source Machine Learning Framework for Everyone
pytorch
Tensors and Dynamic neural networks in Python with strong GPU acceleration
keras
Deep Learning for humans
nanoGPT
The simplest, fastest repository for training/finetuning medium-sized GPTs.
ray
Ray is an AI compute engine. Ray consists of a core distributed runtime and a set of AI Libraries for accelerating ML workloads.