Skip to main content

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

Project description

Setup

To use the latest transformer-tricks python package:

pip3 install transformer-tricks

If you want to use the latest version of tricks.py, do this:

pip3 install --quiet -r requirements.txt

To run llama and other LLMs that need an agreement (not SmolLM), you first have to type the following:

huggingface-cli login

Above will ask you for the hf_token, which is the same you use e.g. in colab

Test FlashNorm

python3 test_flashNorm.py

Above should return the following:

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)

Use the transformer-tricks package

import transformer_tricks.tricks as tt

Example

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

import transformer_tricks.tricks as tt

# convert model to 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)

Above should return the following:

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)

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: transformer_tricks-0.1.12.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.12.tar.gz
Algorithm Hash digest
SHA256 e2a312edbc19bea35231c19c4e55020c581b38132ab0e69010e35b8ad353157c
MD5 f93d7be9e0da0eb5472e3068c9530c05
BLAKE2b-256 e272fffed1a87dc1ecf56cfdbc833261948ac29a2e83173d786a4024c0fa1564

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for transformer_tricks-0.1.12-py3-none-any.whl
Algorithm Hash digest
SHA256 fd3f10ffd89e432efcc249ebdafa9bce620e1a5e544e9784b684d69b93f9d6be
MD5 12ba982ad549d2a20bea345ac1fd10fa
BLAKE2b-256 8c872daaff644c8cb6510a297b54a0ce615a8c4a85b44b54bb569eabf5d93b1e

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