hotchpotch commited on
Commit
4e67350
·
verified ·
1 Parent(s): 3664bdd

Update README.md

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