Commit
•
b1e07be
1
Parent(s):
a286e00
Update README.md
Browse files
README.md
CHANGED
@@ -4,6 +4,7 @@ license: apache-2.0
|
|
4 |
|
5 |
## Convert pytorch model to onnx format.
|
6 |
|
|
|
7 |
import torch
|
8 |
import onnx
|
9 |
import onnxruntime
|
@@ -37,11 +38,12 @@ quantize_dynamic(
|
|
37 |
optimize_model=False,
|
38 |
use_external_data_format=False
|
39 |
)
|
|
|
40 |
##Copy pooling layer and tokenizer files to the output directory
|
41 |
|
42 |
|
43 |
## How to generate embeddings?
|
44 |
-
|
45 |
from onnxruntime import InferenceSession
|
46 |
import torch
|
47 |
from transformers.modeling_outputs import BaseModelOutput
|
@@ -99,3 +101,4 @@ m1 = sbert_onnx_encode('That is a happy person')
|
|
99 |
m2 = sbert.encode('That is a happy person').tolist()
|
100 |
print(util.cos_sim(m1,m2))
|
101 |
##tensor([[0.9925]])
|
|
|
|
4 |
|
5 |
## Convert pytorch model to onnx format.
|
6 |
|
7 |
+
```
|
8 |
import torch
|
9 |
import onnx
|
10 |
import onnxruntime
|
|
|
38 |
optimize_model=False,
|
39 |
use_external_data_format=False
|
40 |
)
|
41 |
+
```
|
42 |
##Copy pooling layer and tokenizer files to the output directory
|
43 |
|
44 |
|
45 |
## How to generate embeddings?
|
46 |
+
```
|
47 |
from onnxruntime import InferenceSession
|
48 |
import torch
|
49 |
from transformers.modeling_outputs import BaseModelOutput
|
|
|
101 |
m2 = sbert.encode('That is a happy person').tolist()
|
102 |
print(util.cos_sim(m1,m2))
|
103 |
##tensor([[0.9925]])
|
104 |
+
```
|