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 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 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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file transformer_tricks-0.1.13.tar.gz.
File metadata
- Download URL: transformer_tricks-0.1.13.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
168c6ac09bef74f910ca5124cd5a5c5449c2c4f1289309753969a716f0ac780d
|
|
| MD5 |
f48fed5648d09852ccfc20d1702902f0
|
|
| BLAKE2b-256 |
7007609c7aa11ce3600086ccde23e7fedf9c0de33d7dc21dd28dc4a78b2d1a28
|
File details
Details for the file transformer_tricks-0.1.13-py3-none-any.whl.
File metadata
- Download URL: transformer_tricks-0.1.13-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b9bbe3394e813525cb08ceed63b132d19678501344fb26dee41929b7eca1e2af
|
|
| MD5 |
db08615901925267e9cd4e262cb2771c
|
|
| BLAKE2b-256 |
22a3f9b1a1bc35278e05017591761622def8d922b7a1c58638429afa0176572d
|