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

Uploaded Source

Built Distribution

File details

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

File metadata

File hashes

Hashes for fast-sentence-transformers-0.2.2.tar.gz
Algorithm Hash digest
SHA256 42183d5851aa87ce0eb1ce3796bec6da4bded737b9cf3e747a70afb0d5f8910f
MD5 0e0ed072f8cfcb4c85080f80dbdd18b2
BLAKE2b-256 602926af126ab5b3d0e0b9205d2fcb617a1081d8a96818933cd8fe2ccbd4d628

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fast_sentence_transformers-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c417a16dae70bbda545e96b7aa99b2b69cf0202a4d5397d823c76777eff8d507
MD5 573e53cc20e5cc391e5aeae9925e2b31
BLAKE2b-256 a9265a25951c5134d3bd509f69f57fc9ba60855482f6c90b354b9dc8fcc3672d

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