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 reducing memory 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=-1, 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.

model Type default ONNX ONNX+quantized
paraphrase-albert-small-v2 memory 1x 1x 1x
speed 1x 2x 5x
paraphrase-multilingual-mpnet-base-v2 memory 1x 1x 4x
speed 1x 2x 5x

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.0.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

File details

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

File metadata

File hashes

Hashes for fast-sentence-transformers-0.3.0.tar.gz
Algorithm Hash digest
SHA256 200cdf1fab3427c053d81667aaada266e0cf6d57c8e053e492c4072fe73f01ba
MD5 49ebe8301c16f3d4fec54d7b2cb92986
BLAKE2b-256 4fe054e2a62855248a434b41773ce9aad5229a018f4e077c331a312eeb48acd4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fast_sentence_transformers-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d73165565d39170b7b7d98e42a2fe86b0a3974a5cee41bb9dcbe2114b0f7803b
MD5 4f35e4ae55e72f6616651efdffacfcf2
BLAKE2b-256 46d3d88440a967493090b4aa7b45e1dc685835c706b4218decb3380a427542f0

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