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!
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.3.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6ee81ec9e9dc6cb8acdcf8e567694d9932086d1ac5c6ff697d29217364b50f7 |
|
MD5 | 82af5b93969f92149a4c96be6ff59bc0 |
|
BLAKE2b-256 | c4530fc1303ba8a52ab1409f0d829c7d20441cc5a0587e142ccad6d0cdb29483 |
Close
Hashes for fast_sentence_transformers-0.3.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 34fbe2b5708c0842d2cb631d3f29cc96683a4823c42c14194e00795416d35f13 |
|
MD5 | f728e3a548aa374add944a42983e0879 |
|
BLAKE2b-256 | 84f873968abf1a8f14613062ad012e165c8eeb762c007bbd34ceacc9dc0a5c30 |