Feature Extraction
sentence-transformers
ONNX
English
sentence-similarity
Inference Endpoints
shuttie commited on
Commit
93ed3ee
0 Parent(s):

initial commit

Browse files
Files changed (6) hide show
  1. .gitattributes +1 -0
  2. .gitignore +1 -0
  3. README.md +66 -0
  4. convert.py +11 -0
  5. pytorch_model.onnx +3 -0
  6. requirements.txt +4 -0
.gitattributes ADDED
@@ -0,0 +1 @@
 
 
1
+ *.onnx filter=lfs diff=lfs merge=lfs -text
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ .venv
README.md ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - sentence-transformers
4
+ - feature-extraction
5
+ - sentence-similarity
6
+ language: en
7
+ license: apache-2.0
8
+ datasets:
9
+ - s2orc
10
+ - flax-sentence-embeddings/stackexchange_xml
11
+ - ms_marco
12
+ - gooaq
13
+ - yahoo_answers_topics
14
+ - code_search_net
15
+ - search_qa
16
+ - eli5
17
+ - snli
18
+ - multi_nli
19
+ - wikihow
20
+ - natural_questions
21
+ - trivia_qa
22
+ - embedding-data/sentence-compression
23
+ - embedding-data/flickr30k-captions
24
+ - embedding-data/altlex
25
+ - embedding-data/simple-wiki
26
+ - embedding-data/QQP
27
+ - embedding-data/SPECTER
28
+ - embedding-data/PAQ_pairs
29
+ - embedding-data/WikiAnswers
30
+
31
+ ---
32
+
33
+ # ONNX version of sentence-transormers/all-MiniLM-L12-v2
34
+
35
+ This is a sentence-transformers model: It maps sentences & paragraphs to a 384 dimensional dense vector space and can be used for tasks like clustering or semantic search. The ONNX version of this model is made for the [Metarank](https://github.com/metarank/metarank) re-ranker
36
+ to do semantic similarity.
37
+
38
+ Check out the [main Metarank docs](https://docs.metarank.ai) on how to configure it.
39
+
40
+ TLDR:
41
+ ```yaml
42
+ - type: field_match
43
+ name: title_query_match
44
+ rankingField: ranking.query
45
+ itemField: item.title
46
+ distance: cos
47
+ method:
48
+ type: bert
49
+ model: metarank/all-MiniLM-L12-v2
50
+ ```
51
+
52
+ ## Building the model
53
+
54
+ ```shell
55
+ $> pip install -r requirements.txt
56
+ $> python convert.py
57
+
58
+ ============= Diagnostic Run torch.onnx.export version 2.0.0+cu117 =============
59
+ verbose: False, log level: Level.ERROR
60
+ ======================= 0 NONE 0 NOTE 0 WARNING 0 ERROR ========================
61
+
62
+ ```
63
+
64
+ ## License
65
+
66
+ Apache 2.0
convert.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import AutoTokenizer, AutoModel
2
+ import torch
3
+
4
+ model = AutoModel.from_pretrained("sentence-transformers/all-MiniLM-L12-v2")
5
+ model.eval()
6
+
7
+ sample = torch.randint(low=0, high=1, size=(1,128))
8
+ input = (sample, sample, sample)
9
+
10
+ torch.onnx.export(model, input, 'pytorch_model.onnx', export_params=True)
11
+
pytorch_model.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a504d31e57702a74fecf5c2d7df67fa9fcb5635baa2cd335ac74bc2cbdefcbdd
3
+ size 133597269
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ sentence-transformers==2.2.2
2
+ torch==2.0.0
3
+ onnx==1.13.1
4
+ huggingface_hub==0.13.3