Skip to main content

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

Project description

Transformer Tricks

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.0.tar.gz (7.1 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.0-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: transformer_tricks-0.3.0.tar.gz
  • Upload date:
  • Size: 7.1 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.0.tar.gz
Algorithm Hash digest
SHA256 8ef117d707d737e28e9374b4572aa8f724dc5547b19fda7f97e5ef6476dd7980
MD5 8bc06850140a29842329b302b27625cc
BLAKE2b-256 bf4c8d905665b3b5745ff8353bbfb5b01fca608e7c57b44aa740c00d5208ad1c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for transformer_tricks-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 41259d88acd8fd159a0c4dc07cd24282f2e44c57ca06a87c8ced841408720a2b
MD5 1fd96cae6052874608111a8f02f469e0
BLAKE2b-256 d603e1db751c547881ec87c4e41981cc9e841b74631b7826fad67d44d4f93635

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