This repository contains code to run faster sentence-transformers using tools like quantization, ONNX and pruning.
Project description
Fast Sentence Transformers
This repository contains code to run faster sentence-transformers
using tools like quantization and ONNX
. Just run your model much faster, while a lot of memory. There is not much to it!
Install
pip install fast-sentence-transformers
Or for GPU support.
pip install fast-sentence-transformers[gpu]
Quickstart
from fast_sentence_transformers import FastSentenceTransformer as SentenceTransformer
# use any sentence-transformer
encoder = SentenceTransformer("all-MiniLM-L6-v2", device="cpu", quantize=True)
encoder.encode("Hello hello, hey, hello hello")
encoder.encode(["Life is too short to eat bad food!"] * 2)
Benchmark
Indicative benchmark for CPU usage with smallest and largest model on sentence-transformers
. Note, ONNX doesn't have GPU support for quantization yet.
model | Type | default | ONNX | ONNX+quantized | ONNX+GPU |
---|---|---|---|---|---|
paraphrase-albert-small-v2 | memory | 1x | 1x | 1x | 1x |
speed | 1x | 2x | 5x | 20x | |
paraphrase-multilingual-mpnet-base-v2 | memory | 1x | 1x | 4x | 4x |
speed | 1x | 2x | 5x | 20x |
Shout-Out
This package heavily leans on sentence-transformers
and txtai
.
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
Close
Hashes for fast_sentence_transformers-0.4.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1627cb744a50f0167a705563b2085c3f31eff50c63c6a778215866f0e0ecad95 |
|
MD5 | eefd73a06ce61474eb26eca3676da9e9 |
|
BLAKE2b-256 | d9b8f9d0890e331c2dd70fcc316213a171ee3776373316ba18c283b5688fd34c |
Close
Hashes for fast_sentence_transformers-0.4.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e41c37078d37f230323e74828e27c3d7bab501c349295e13b25d48a4a97336a5 |
|
MD5 | ef0c3d103527fbdfc0990b08db5e6d71 |
|
BLAKE2b-256 | 48230e2f99aea51ad76a26ea136dbe9a294a93c4ea866723b026b55e504d9737 |