SamLowe commited on
Commit
1258449
1 Parent(s): 368f307

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +47 -0
README.md CHANGED
@@ -1,3 +1,50 @@
1
  ---
 
 
 
 
 
 
 
2
  license: apache-2.0
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ language: en
3
+ tags:
4
+ - feature-extraction
5
+ - onnx
6
+ - use
7
+ - text-embedding
8
+ - tensorflow-hub
9
  license: apache-2.0
10
+ inference: false
11
+ widget:
12
+ - text: Thank goodness ONNX is available, it is lots faster!
13
  ---
14
+ ### Universal Sentence Encoder Large v5
15
+
16
+ ONNX version of [https://tfhub.dev/google/universal-sentence-encoder-large/5](https://tfhub.dev/google/universal-sentence-encoder-large/5)
17
+
18
+ The original TFHub version of the model is referenced in other models here E.g. [https://huggingface.co/vprelovac/universal-sentence-encoder-large-5](https://huggingface.co/vprelovac/universal-sentence-encoder-large-5)
19
+
20
+ ### Overview
21
+
22
+ See overview and license details at [https://tfhub.dev/google/universal-sentence-encoder-large/5](https://tfhub.dev/google/universal-sentence-encoder-large/5)
23
+
24
+ This model is a full precision version of the TFHub original, in ONNX format.
25
+
26
+ It uses the [ONNXRuntime Extensions](https://github.com/microsoft/onnxruntime-extensions) to embed the tokenizer within the ONNX model, so no seperate tokenizer is needed, and text is fed directly into the ONNX model.
27
+
28
+ Post-processing (E.g. pooling, normalization) is also implemented within the ONNX model, so no separate processing is necessary.
29
+
30
+ ### How to use
31
+
32
+ ```python
33
+ import onnxruntime as ort
34
+ from onnxruntime_extensions import get_library_path
35
+ from os import cpu_count
36
+
37
+ sentences = ["hello world"]
38
+
39
+ def load_onnx_model(model_filepath):
40
+ _options = ort.SessionOptions()
41
+ _options.inter_op_num_threads, _options.intra_op_num_threads = cpu_count(), cpu_count()
42
+ _options.register_custom_ops_library(get_library_path())
43
+ _providers = ["CPUExecutionProvider"] # could use ort.get_available_providers()
44
+ return ort.InferenceSession(path_or_bytes=model_filepath, sess_options=_options, providers=_providers)
45
+
46
+ model = load_onnx_model("filepath_for_model_dot_onnx")
47
+
48
+ model_outputs = model.run(output_names=["outputs"], input_feed={"inputs": sentences})[0]
49
+ print(model_outputs)
50
+ ```