lorenpe2 commited on
Commit
e47d360
·
1 Parent(s): 896fbac

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +18 -14
README.md CHANGED
@@ -9,29 +9,33 @@ tags:
9
  - transformers
10
  ---
11
 
12
- # sentence-transformers/distiluse-base-multilingual-cased-v2
 
 
13
 
14
- This is a [sentence-transformers](https://www.SBERT.net) model: It maps sentences & paragraphs to a 512 dimensional dense vector space and can be used for tasks like clustering or semantic search.
15
 
16
 
17
-
18
- ## Usage (Sentence-Transformers)
19
-
20
- Using this model becomes easy when you have [sentence-transformers](https://www.SBERT.net) installed:
21
-
22
  ```
23
- pip install -U sentence-transformers
24
  ```
25
-
26
  Then you can use the model like this:
 
 
27
 
 
 
 
 
 
 
28
  ```python
29
- from sentence_transformers import SentenceTransformer
30
- sentences = ["This is an example sentence", "Each sentence is converted"]
31
 
32
- model = SentenceTransformer('sentence-transformers/distiluse-base-multilingual-cased-v2')
33
- embeddings = model.encode(sentences)
34
- print(embeddings)
35
  ```
36
 
37
 
 
9
  - transformers
10
  ---
11
 
12
+ # ONNX convert distiluse-base-multilingual-cased-v2
13
+ ## Conversion of [sentence-transformers/distiluse-base-multilingual-cased-v2](https://huggingface.co/sentence-transformers/distiluse-base-multilingual-cased-v2)
14
+ This is a [sentence-transformers](https://www.SBERT.net) ONNX model: It maps sentences & paragraphs to a 512 dimensional dense vector space and can be used for tasks like clustering or semantic search. This custom model outputs `last_hidden_state` similar like original sentence-transformer implementation.
15
 
 
16
 
17
 
18
+ ## Usage (HuggingFace Optimum)
19
+ Using this model becomes easy when you have [optimum](https://github.com/huggingface/optimum) installed:
 
 
 
20
  ```
21
+ python -m pip install optimum
22
  ```
 
23
  Then you can use the model like this:
24
+ ```python
25
+ from optimum.onnxruntime.modeling_ort import ORTModelForCustomTasks
26
 
27
+ model = ORTModelForCustomTasks.from_pretrained("lorenpe2/distiluse-base-multilingual-cased-v2")
28
+ tokenizer = AutoTokenizer.from_pretrained("lorenpe2/distiluse-base-multilingual-cased-v2")
29
+ inputs = tokenizer("I love burritos!", return_tensors="pt")
30
+ pred = model(**inputs)
31
+ ```
32
+ You will also be able to leverage the pipeline API in transformers:
33
  ```python
34
+ from transformers import pipeline
 
35
 
36
+ onnx_extractor = pipeline("feature-extraction", model=model, tokenizer=tokenizer)
37
+ text = "I love burritos!"
38
+ pred = onnx_extractor(text)
39
  ```
40
 
41