Skip to main content

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

Project description

Setup

pip3 install transformer-tricks

To run llama and other LLMs that need an agreement (not SmolLM), you first have to type the following, which will ask for your hf_token:

huggingface-cli login

Example

The example below converts SmolLM-135M to FlashNorm and measures perplexity of the original and the modified model.

import transformer_tricks as tt

# convert model and store the new model in ./SmolLM-135M_flashNorm
tt.flashify_repo('HuggingFaceTB/SmolLM-135M')

# run example inference of original and modified model
tt.hello_world('HuggingFaceTB/SmolLM-135M')
tt.hello_world('SmolLM-135M_flashNorm')

# measure perplexity of original and modified model
tt.perplexity('HuggingFaceTB/SmolLM-135M', speedup=16)
tt.perplexity('SmolLM-135M_flashNorm', speedup=16)

Results:

Once upon a time there was a curious little girl
Once upon a time there was a curious little girl
ppl: tensor(16.0831)
ppl: tensor(16.0831)

Test FlashNorm

# setup
git clone https://github.com/OpenMachine-ai/transformer-tricks.git
cd python
pip3 install --quiet -r requirements.txt

# run tests
python3 flashNorm_test.py

Results:

Once upon a time there was a curious little girl
Once upon a time there was a curious little girl
Once upon a time there was a little girl named
Once upon a time there was a little girl named
ppl: tensor(16.0831)
ppl: tensor(16.0831)
ppl: tensor(12.0864)
ppl: tensor(12.0864)

Notes on python package

  • Link to package here
  • Link to stats here

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.1.14.tar.gz (3.9 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.1.14-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for transformer_tricks-0.1.14.tar.gz
Algorithm Hash digest
SHA256 5fa72013a511b06e637dce17361d3f405c178e8ac784d02fbf33b8d5532f768c
MD5 4558890c149f166bbe0b809b9a83559e
BLAKE2b-256 50aa51e7d9f52e8845a9d62262a3002838bff51420e3aca88c28966c0c138795

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for transformer_tricks-0.1.14-py3-none-any.whl
Algorithm Hash digest
SHA256 1ce32bd1a81ed4a280d318d8bfba78062c8002a96922c6c5d35550baec4bf011
MD5 799dd7548472ebad5c71b3ee90ecec28
BLAKE2b-256 edee1b9df662a7bc3236eea67e39e227f74c79be4907fa41fa26962a99fcbc4b

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