fast-sentence-transformers-0.4.1
توضیحات
This repository contains code to run faster sentence-transformers using tools like quantization, ONNX and pruning.
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | fast-sentence-transformers-0.4.1 |
| نام | fast-sentence-transformers |
| نسخه کتابخانه | 0.4.1 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | David Berenstein |
| ایمیل نویسنده | david.m.berenstein@gmail.com |
| آدرس صفحه اصلی | https://github.com/pandora-intelligence/fast-sentence-transformers |
| آدرس اینترنتی | https://pypi.org/project/fast-sentence-transformers/ |
| مجوز | MIT |
# 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!
[](https://github.com/Pandora-Intelligence/fast-sentence-transformers/actions/workflows/python-package.yml)
[](https://github.com/pandora-intelligence/fast-sentence-transformers/releases)
[](https://pypi.org/project/fast-sentence-transformers/)
[](https://pypi.org/project/fast-sentence-transformers/)
[](https://github.com/ambv/black)
# Install
```bash
pip install fast-sentence-transformers
```
Or for GPU support.
```bash
pip install fast-sentence-transformers[gpu]
```
# Quickstart
```python
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`.
نیازمندی
| مقدار | نام |
|---|---|
| >=1.12.0,<2.0.0 | onnx |
| >=1.10,<2.0 | onnxruntime |
| >=5.9.2,<6.0.0 | psutil |
| >=2.1.0 | sentence-transformers |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.8,<3.12 | Python |
نحوه نصب
نصب پکیج whl fast-sentence-transformers-0.4.1:
pip install fast-sentence-transformers-0.4.1.whl
نصب پکیج tar.gz fast-sentence-transformers-0.4.1:
pip install fast-sentence-transformers-0.4.1.tar.gz