Skip to main content

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!

Python package Current Release Version pypi Version PyPi downloads Code style: black

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fast-sentence-transformers-0.3.2.1.tar.gz (15.8 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file fast-sentence-transformers-0.3.2.1.tar.gz.

File metadata

File hashes

Hashes for fast-sentence-transformers-0.3.2.1.tar.gz
Algorithm Hash digest
SHA256 96dd4620f5d10d50c7ea6a999eb9960423d99f98084c7f17b1e2c2a413196bfa
MD5 7e5efeec609dc5be37f7168f134787d3
BLAKE2b-256 be139e76c0eb7f709c90d72721e93944ed04e85dd4b3c40e26f3160c6bf71247

See more details on using hashes here.

File details

Details for the file fast_sentence_transformers-0.3.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for fast_sentence_transformers-0.3.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 342384b938be129915b7f3f2990ba1e9b3a9962e1642527c1aae0094a131529e
MD5 8c9e3e716570fb06b57518a8eb2b43df
BLAKE2b-256 a49703a35305d51814224ffea09d7a8773b0a95bec27798161f59262e85bc0a6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page