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, 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 subscribe 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.3.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.3-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: transformer_tricks-0.3.3.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.3.tar.gz
Algorithm Hash digest
SHA256 b8d2349a3f9095e111327cc419a5a7970ae825e6d387351e845642316beb62f6
MD5 547183e30b28e73bc66f9f83e58013c7
BLAKE2b-256 0483b364084b06b457a66434989c33fa773402af67ce7276aead0212a0d20590

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for transformer_tricks-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4176a18c9a80cd06037564b5e22a0a45c100eee5ffa1001447e90c91e82d2c18
MD5 582f0c7180544c56e74fe2346039b694
BLAKE2b-256 fb2ccedff83364b0b2962a312457507b1d5a2e48e94a927ad19897f65ccb6ae9

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