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

Uploaded Source

Built Distribution

File details

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

File metadata

File hashes

Hashes for fast-sentence-transformers-0.1.2.tar.gz
Algorithm Hash digest
SHA256 0379deed943c556d48f0282fb116398663a3264d3c902c6a2eb3df90c8c804b5
MD5 d9be9cb7c9feae996e823959c79f0558
BLAKE2b-256 44997910be25f0fcc695b22d16351781ecf1e1e82c2d2180f2bf0070cfebe5dc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fast_sentence_transformers-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 09a79ec5f5319eddd78732eefc990e284f03d9e9fc6c7fec1357eb481b226214
MD5 e86afb98ee0df17a3d1acd3f0431d94f
BLAKE2b-256 5fd10cbd149b69f8a3970d82bdeacb210b83d2045efdac0874c342632b5f0080

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