hooman650 commited on
Commit
2fb50ad
1 Parent(s): 61cb51b

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ model_optimized.onnx.data filter=lfs diff=lfs merge=lfs -text
37
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
.ipynb_checkpoints/README-checkpoint.md ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ pipeline_tag: feature-extraction
4
+ ---
5
+
6
+ # bge-m3-onnx-o4
7
+
8
+ This is `bge-m3-onnx-o4` weights of the original [`BAAI/bge-m3`](https://huggingface.co/BAAI/bge-m3). Why is this model cool?
9
+
10
+ - [x] Multi-Functionality: It can simultaneously perform the three common retrieval functionalities of embedding model: dense retrieval, multi-vector retrieval, and sparse retrieval.
11
+ - [x] Multi-Linguality: It can support more than **100** working languages.
12
+ - [x] Multi-Granularity: It is able to process inputs of different granularities, spanning from short sentences to long documents of up to **8192** tokens.
13
+
14
+ ## Usage
15
+
16
+ ### Dense Retrieval
17
+
18
+ ```
19
+ # for cuda
20
+ pip install --upgrade-strategy eager optimum[onnxruntime]
21
+ ```
22
+
23
+ ```python
24
+
25
+ from optimum.onnxruntime import ORTModelForFeatureExtraction
26
+ from transformers import AutoTokenizer
27
+ import torch
28
+
29
+ model = ORTModelForFeatureExtraction.from_pretrained("hooman650/bge-m3-onnx-o4", provider="CUDAExecutionProvider")
30
+ tokenizer = AutoTokenizer.from_pretrained("hooman650/bge-m3-onnx-o4")
31
+
32
+ sentences = [
33
+ "English: The quick brown fox jumps over the lazy dog.",
34
+ "Spanish: El rápido zorro marrón salta sobre el perro perezoso.",
35
+ "French: Le renard brun rapide saute par-dessus le chien paresseux.",
36
+ "German: Der schnelle braune Fuchs springt über den faulen Hund.",
37
+ "Italian: La volpe marrone veloce salta sopra il cane pigro.",
38
+ "Japanese: 速い茶色の狐が怠惰な犬を飛び越える。",
39
+ "Chinese (Simplified): 快速的棕色狐狸跳过懒狗。",
40
+ "Russian: Быстрая коричневая лиса прыгает через ленивую собаку.",
41
+ "Arabic: الثعلب البني السريع يقفز فوق الكلب الكسول.",
42
+ "Hindi: तेज़ भूरी लोमड़ी आलसी कुत्ते के ऊपर कूद जाती है।"
43
+ ]
44
+
45
+ encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt').to("cuda")
46
+
47
+ # Get the embeddings
48
+ out=model(**encoded_input,return_dict=True).last_hidden_state
49
+
50
+ # normalize the embeddings
51
+ dense_vecs = torch.nn.functional.normalize(out[:, 0], dim=-1)
52
+ ```
53
+ ### Multi-Vector (ColBERT)
54
+
55
+ `coming soon...`
56
+
57
+
README.md CHANGED
@@ -1,3 +1,57 @@
1
  ---
2
  license: mit
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: mit
3
+ pipeline_tag: feature-extraction
4
  ---
5
+
6
+ # bge-m3-onnx-o4
7
+
8
+ This is `bge-m3-onnx-o4` weights of the original [`BAAI/bge-m3`](https://huggingface.co/BAAI/bge-m3). Why is this model cool?
9
+
10
+ - [x] Multi-Functionality: It can simultaneously perform the three common retrieval functionalities of embedding model: dense retrieval, multi-vector retrieval, and sparse retrieval.
11
+ - [x] Multi-Linguality: It can support more than **100** working languages.
12
+ - [x] Multi-Granularity: It is able to process inputs of different granularities, spanning from short sentences to long documents of up to **8192** tokens.
13
+
14
+ ## Usage
15
+
16
+ ### Dense Retrieval
17
+
18
+ ```
19
+ # for cuda
20
+ pip install --upgrade-strategy eager optimum[onnxruntime]
21
+ ```
22
+
23
+ ```python
24
+
25
+ from optimum.onnxruntime import ORTModelForFeatureExtraction
26
+ from transformers import AutoTokenizer
27
+ import torch
28
+
29
+ model = ORTModelForFeatureExtraction.from_pretrained("hooman650/bge-m3-onnx-o4", provider="CUDAExecutionProvider")
30
+ tokenizer = AutoTokenizer.from_pretrained("hooman650/bge-m3-onnx-o4")
31
+
32
+ sentences = [
33
+ "English: The quick brown fox jumps over the lazy dog.",
34
+ "Spanish: El rápido zorro marrón salta sobre el perro perezoso.",
35
+ "French: Le renard brun rapide saute par-dessus le chien paresseux.",
36
+ "German: Der schnelle braune Fuchs springt über den faulen Hund.",
37
+ "Italian: La volpe marrone veloce salta sopra il cane pigro.",
38
+ "Japanese: 速い茶色の狐が怠惰な犬を飛び越える。",
39
+ "Chinese (Simplified): 快速的棕色狐狸跳过懒狗。",
40
+ "Russian: Быстрая коричневая лиса прыгает через ленивую собаку.",
41
+ "Arabic: الثعلب البني السريع يقفز فوق الكلب الكسول.",
42
+ "Hindi: तेज़ भूरी लोमड़ी आलसी कुत्ते के ऊपर कूद जाती है।"
43
+ ]
44
+
45
+ encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt').to("cuda")
46
+
47
+ # Get the embeddings
48
+ out=model(**encoded_input,return_dict=True).last_hidden_state
49
+
50
+ # normalize the embeddings
51
+ dense_vecs = torch.nn.functional.normalize(out[:, 0], dim=-1)
52
+ ```
53
+ ### Multi-Vector (ColBERT)
54
+
55
+ `coming soon...`
56
+
57
+
config.json ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "bge-m3-v1/config.json",
3
+ "architectures": [
4
+ "XLMRobertaModel"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "bos_token_id": 0,
8
+ "classifier_dropout": null,
9
+ "eos_token_id": 2,
10
+ "hidden_act": "gelu",
11
+ "hidden_dropout_prob": 0.1,
12
+ "hidden_size": 1024,
13
+ "initializer_range": 0.02,
14
+ "intermediate_size": 4096,
15
+ "layer_norm_eps": 1e-05,
16
+ "max_position_embeddings": 8194,
17
+ "model_type": "xlm-roberta",
18
+ "num_attention_heads": 16,
19
+ "num_hidden_layers": 24,
20
+ "output_past": true,
21
+ "pad_token_id": 1,
22
+ "position_embedding_type": "absolute",
23
+ "torch_dtype": "float32",
24
+ "transformers_version": "4.37.2",
25
+ "type_vocab_size": 1,
26
+ "use_cache": true,
27
+ "vocab_size": 250002
28
+ }
model_optimized.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:35af0110ac67f418fb78ebb8f1e138743b156c29d875f081f5e851ef0f92638c
3
+ size 82707
model_optimized.onnx.data ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d1b1235afd54571edb3f1152c295c42fb3b7b1bcd8ca233d236b29aef43ea11a
3
+ size 1133475856
ort_config.json ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "one_external_file": true,
3
+ "opset": null,
4
+ "optimization": {
5
+ "disable_attention": null,
6
+ "disable_attention_fusion": false,
7
+ "disable_bias_gelu": null,
8
+ "disable_bias_gelu_fusion": false,
9
+ "disable_bias_skip_layer_norm": null,
10
+ "disable_bias_skip_layer_norm_fusion": false,
11
+ "disable_embed_layer_norm": true,
12
+ "disable_embed_layer_norm_fusion": true,
13
+ "disable_gelu": null,
14
+ "disable_gelu_fusion": false,
15
+ "disable_group_norm_fusion": true,
16
+ "disable_layer_norm": null,
17
+ "disable_layer_norm_fusion": false,
18
+ "disable_packed_kv": true,
19
+ "disable_rotary_embeddings": false,
20
+ "disable_shape_inference": false,
21
+ "disable_skip_layer_norm": null,
22
+ "disable_skip_layer_norm_fusion": false,
23
+ "enable_gelu_approximation": true,
24
+ "enable_gemm_fast_gelu_fusion": false,
25
+ "enable_transformers_specific_optimizations": true,
26
+ "fp16": true,
27
+ "no_attention_mask": false,
28
+ "optimization_level": 2,
29
+ "optimize_for_gpu": true,
30
+ "optimize_with_onnxruntime_only": null,
31
+ "use_mask_index": false,
32
+ "use_multi_head_attention": false,
33
+ "use_raw_attention_mask": false
34
+ },
35
+ "optimum_version": "1.16.2",
36
+ "quantization": {},
37
+ "transformers_version": "4.37.2",
38
+ "use_external_data_format": true
39
+ }
sentencepiece.bpe.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cfc8146abe2a0488e9e2a0c56de7952f7c11ab059eca145a0a727afce0db2865
3
+ size 5069051
special_tokens_map.json ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<s>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "cls_token": {
10
+ "content": "<s>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "eos_token": {
17
+ "content": "</s>",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ },
23
+ "mask_token": {
24
+ "content": "<mask>",
25
+ "lstrip": true,
26
+ "normalized": false,
27
+ "rstrip": false,
28
+ "single_word": false
29
+ },
30
+ "pad_token": {
31
+ "content": "<pad>",
32
+ "lstrip": false,
33
+ "normalized": false,
34
+ "rstrip": false,
35
+ "single_word": false
36
+ },
37
+ "sep_token": {
38
+ "content": "</s>",
39
+ "lstrip": false,
40
+ "normalized": false,
41
+ "rstrip": false,
42
+ "single_word": false
43
+ },
44
+ "unk_token": {
45
+ "content": "<unk>",
46
+ "lstrip": false,
47
+ "normalized": false,
48
+ "rstrip": false,
49
+ "single_word": false
50
+ }
51
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6710678b12670bc442b99edc952c4d996ae309a7020c1fa0096dd245c2faf790
3
+ size 17082821
tokenizer_config.json ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "<s>",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "1": {
12
+ "content": "<pad>",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "2": {
20
+ "content": "</s>",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "3": {
28
+ "content": "<unk>",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "250001": {
36
+ "content": "<mask>",
37
+ "lstrip": true,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "bos_token": "<s>",
45
+ "clean_up_tokenization_spaces": true,
46
+ "cls_token": "<s>",
47
+ "eos_token": "</s>",
48
+ "mask_token": "<mask>",
49
+ "model_max_length": 8192,
50
+ "pad_token": "<pad>",
51
+ "sep_token": "</s>",
52
+ "sp_model_kwargs": {},
53
+ "tokenizer_class": "XLMRobertaTokenizer",
54
+ "unk_token": "<unk>"
55
+ }