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

Uploaded Source

Built Distribution

File details

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

File metadata

File hashes

Hashes for fast-sentence-transformers-0.1.3.tar.gz
Algorithm Hash digest
SHA256 6929641b1029b4a98aee7fe2a77a6eeae938048572bf54287d81de3289f2d3fa
MD5 0dabfc4a37fee58d898ce0bdaf0b50c0
BLAKE2b-256 8a6cacbf17b3e9b204378611a222144d10f731af51b737f0e644008718d8e2e4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fast_sentence_transformers-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 79acb989c9c248c7c149a3d5a6c439c25900c949f8682d7088ac3254f36fdf93
MD5 a8cd556564575e747255466454b577bb
BLAKE2b-256 f96da881fd07612f1bf5408fb2cb5c3f02b13df20c99a201e352b8b80ac03aa9

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