Fast Sentence Transformers
This repository contains code to run faster feature extractors using tools like quantization, optimization and ONNX. Just run your model much faster, while using less of memory. There is not much to it!
Phillip Schmid: "We successfully quantized our vanilla Transformers model with Hugging Face and managed to accelerate our model latency from 25.6ms to 12.3ms or 2.09x while keeping 100% of the accuracy on the stsb dataset. But I have to say that this isn't a plug and play process you can transfer to any Transformers model, task or dataset.""
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")
encoder.encode("Hello hello, hey, hello hello")
encoder.encode(["Life is too short to eat bad food!"] * 2)
Benchmark
Non-exact, indicative benchmark for speed an memory usage with smaller and larger model on sentence-transformers
| 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 https://www.philschmid.de/optimize-sentence-transformers.
Metadata
Release files for fast-sentence-transformers 0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fast_sentence_transformers-0.5.tar.gz | 5.4 kB | Without provenance | Details for fast_sentence_transformers-0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fast_sentence_transformers-0.5-py3-none-any.whl | Python 3 | none | any | Details for fast_sentence_transformers-0.5-py3-none-any.whl |
Total release size: 11.3 kB
Release files / fast_sentence_transformers-0.5.tar.gz
| Download URL | fast_sentence_transformers-0.5.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d6329ca7240bcb531b112b8d37684b002d4258e2a62fbf450543bf790a102cb4
|
|
BLAKE2b-256 checksum How to use checksums |
6ea97ea7990ebbe9628bb25bca180a957954fd43cf52cf41cc293b4408585529
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.19
|
Release files / fast_sentence_transformers-0.5-py3-none-any.whl
| Download URL | fast_sentence_transformers-0.5-py3-none-any.whl |
|---|---|
| Size | 6.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f4accf68b65061c54e071813fb5df45878e73e1d792b6efb3427f148e649baca
|
|
BLAKE2b-256 checksum How to use checksums |
af3a4e6501279845b3623d3318a723bddebf64fc38ce94ac71e1ffe6f2c68c19
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.19
|
Security for fast-sentence-transformers 0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.