# Smerity/sha-rnn

Single Headed Attention RNN - "Stop thinking with your head"

Repository: https://github.com/Smerity/sha-rnn
Canonical: https://ross.abutalabs.com/products/sha-rnn
Language: Python
License Family: other
Last push: 2021-11-27T07:17:07+00:00

## Health v2 (maintenance only)
Score: 32/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 0, release rhythm 35, longevity 100
- inputs: {"age_days": 2543, "days_push": 1740, "days_rel": null, "gap_med": null, "n_releases_24m": 0}
- flags: no_releases, no_license
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 1180, forks 131 (observed 2026-08-28T04:03:53.591918+00:00)

## What it is
A PyTorch implementation of the Single Headed Attention RNN (SHA-LSTM) from Stephen Merity's paper, combining an LSTM with a single attention head for byte-level language modeling. It achieves strong enwik8 results while training in under 24 hours on a single 12GB GPU.

## Use cases
- train a byte-level language model on a single GPU
- reproduce SHA-LSTM results on enwik8
- model long-range dependencies without transformer memory overhead
- avoid fragile transformer warmup and training instability
- build a small language model exportable to ONNX with standard components

## When to choose
- you need an efficient, low-resource language model trainable on one GPU
- you want LSTM-based architecture with simple attention for long contexts
- you need a model composed of standard, productionizable components

## When to avoid
- you need state-of-the-art transformer performance
- you want a polished library with CLI options and stable API
- you need an actively maintained project - the code is research-grade and the author notes it is not kind

## Facets
- artifact type: library
- maturity: maintenance
- function: machine-learning, deep-learning
- domain: deep-learning, machine-learning
- platform: python
- tags: rnn, lstm, attention, language-modeling, pytorch, research-code, sha-lstm, natural-language-processing, gpu

## Member repositories
- Smerity/sha-rnn (main) score 32

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:03:53.591918+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T06:25:14.766792+00:00, confidence not recorded.
  - readme: https://github.com/Smerity/sha-rnn (fetched 2026-08-28T04:03:53.591918+00:00, sha 34bb87b8400c)
- Data as of 2026-08-30T08:39:29.467469+00:00.
