Skip to main content

A collection of tricks to speed up LLMs, see our transformer-tricks papers on arXiv

Project description

Transformer Tricks

PyPI PyPI Downloads

A collection of tricks to simplify and speed up transformer models:

Many of these tricks follow a recent trend of removing parts from neural networks such as RMSNorm’s removal of mean centering from LayerNorm, PaLM's removal of bias-parameters, NoPE’s removal of positional encoding, GPT’s removal of the encoder stack, and of course transformer’s revolutionary removal of recurrent layers. Specifically, our FlashNorm removes the weights from RMSNorm and merges them with the next linear layer. And slim attention removes the entire V-cache from the context memory for MHA transformers.


Installation

Install the transformer tricks package:

pip install transformer-tricks

Documentation

Follow the links below for documentation of the python code in this directory:


Notebooks

The papers are accompanied by the following Jupyter notebooks:

  • Slim attention: Colab
  • Flash normalization: Colab Colab
  • Removing weights from skipless transformers: Colab

Newsletter

Please subsribe to our [newsletter] on substack to get the latest news about this project. We will never send you more than one email per month.

Substack


Contributing

Before making a change to this repo, please do the following:

  • Format your code by typing autopep8 *.py. It's using the config in pyproject.toml
  • Whenever you change transformer_tricks.py, publish a new version of the package as follows:
    • First, update the version number in pyproject.toml and in requirements.txt
    • Then, push the package to PyPi by typing ./push_pypi.sh
    • Links for python package: pypi, stats, source of this readme
  • Generate notebooks from python by typing util/gen_notebooks

Please give us a ⭐ if you like this repo, thanks!


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

transformer_tricks-0.3.1.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

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

transformer_tricks-0.3.1-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file transformer_tricks-0.3.1.tar.gz.

File metadata

  • Download URL: transformer_tricks-0.3.1.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.9

File hashes

Hashes for transformer_tricks-0.3.1.tar.gz
Algorithm Hash digest
SHA256 ae0ed778af0b1d8c08572dea19d9129693d013e471fefc4a6cfea575f13957a9
MD5 fc96a4dd47bbf2ae30ed916403d0e3be
BLAKE2b-256 20e304c171f68b7f061dc7e45b8cb298f87cfc371479359df9b2db08e6abeb20

See more details on using hashes here.

File details

Details for the file transformer_tricks-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for transformer_tricks-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9a54b542cf6f52b48eb7696e2d443222fae1930732792222722abf8f0a4cd986
MD5 5d225cf1708d25b73afc9a9b5fe1506b
BLAKE2b-256 fe4a0f96f8c039b2bb0f70f34bfd385246ff0dec8b8481e879f337a6526d2bda

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