Update README.md
Browse files
README.md
CHANGED
|
@@ -79,36 +79,6 @@ scores = model.predict(
|
|
| 79 |
print("Scores:", scores)
|
| 80 |
```
|
| 81 |
|
| 82 |
-
### SentenceTransformers + onnx の利用
|
| 83 |
-
|
| 84 |
-
CPU 環境や arm 環境などで、より高速に動かしたい場合は onnx や量子化モデルを利用できます。
|
| 85 |
-
|
| 86 |
-
```
|
| 87 |
-
pip install onnx onnxruntime accelerate optimum
|
| 88 |
-
```
|
| 89 |
-
|
| 90 |
-
```python
|
| 91 |
-
from sentence_transformers import CrossEncoder
|
| 92 |
-
|
| 93 |
-
# oxxn のモデルを選ばないと model.onnx が自動で使われる
|
| 94 |
-
# onnx_filename = None
|
| 95 |
-
|
| 96 |
-
# 量子化された最適なモデルを使う場合は、onnx_filename にファイル名を指定する
|
| 97 |
-
# onnx_filename = "onnx/model_qint8_avx2.onnx"
|
| 98 |
-
onnx_filename = "onnx/model_qint8_arm64.onnx"
|
| 99 |
-
|
| 100 |
-
if onnx_filename:
|
| 101 |
-
model = CrossEncoder(
|
| 102 |
-
MODEL_NAME,
|
| 103 |
-
device="cpu",
|
| 104 |
-
backend="onnx",
|
| 105 |
-
model_kwargs={"file_name": onnx_filename},
|
| 106 |
-
)
|
| 107 |
-
else:
|
| 108 |
-
model = CrossEncoder(MODEL_NAME, device="cpu", backend="onnx")
|
| 109 |
-
|
| 110 |
-
...
|
| 111 |
-
```
|
| 112 |
|
| 113 |
|
| 114 |
## HuggingFace transformers
|
|
|
|
| 79 |
print("Scores:", scores)
|
| 80 |
```
|
| 81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
|
| 83 |
|
| 84 |
## HuggingFace transformers
|