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

Uploaded Python 3

File details

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

File metadata

  • Download URL: transformer_tricks-0.3.2.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.2.tar.gz
Algorithm Hash digest
SHA256 ccd27633b919c407c2c1d23502de903b1f81f2033838b312f47e7537623f5243
MD5 e8199070c87c634b496ef16fc0d24450
BLAKE2b-256 c1267aea5b62d45eb0703d83c1bc58e9f33098e9c10b3f769079826d1d1b76c9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for transformer_tricks-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 432ab2fb6483cfbf2579eccdcd315a7543e03335926965b9c463064fe7ed1b70
MD5 1c3bd389df25e9f538804711a5842104
BLAKE2b-256 e1ba341ca6f3f4da6bf94f8211399ddc54212c38cc7ae2ed0e924037069cfb47

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