ramnathv commited on
Commit
a8981ff
1 Parent(s): d3d830e

Add new SentenceTransformer model.

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ 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
+ pytorch_model.bin filter=lfs diff=lfs merge=lfs -text
1_Pooling/config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "word_embedding_dimension": 1024,
3
+ "pooling_mode_cls_token": false,
4
+ "pooling_mode_mean_tokens": true,
5
+ "pooling_mode_max_tokens": false,
6
+ "pooling_mode_mean_sqrt_len_tokens": false,
7
+ "pooling_mode_weightedmean_tokens": false,
8
+ "pooling_mode_lasttoken": false
9
+ }
README.md ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ pipeline_tag: sentence-similarity
3
+ tags:
4
+ - sentence-transformers
5
+ - feature-extraction
6
+ - sentence-similarity
7
+ - transformers
8
+
9
+ ---
10
+
11
+ # {MODEL_NAME}
12
+
13
+ This is a [sentence-transformers](https://www.SBERT.net) model: It maps sentences & paragraphs to a 1024 dimensional dense vector space and can be used for tasks like clustering or semantic search.
14
+
15
+ <!--- Describe your model here -->
16
+
17
+ ## Usage (Sentence-Transformers)
18
+
19
+ Using this model becomes easy when you have [sentence-transformers](https://www.SBERT.net) installed:
20
+
21
+ ```
22
+ pip install -U sentence-transformers
23
+ ```
24
+
25
+ Then you can use the model like this:
26
+
27
+ ```python
28
+ from sentence_transformers import SentenceTransformer
29
+ sentences = ["This is an example sentence", "Each sentence is converted"]
30
+
31
+ model = SentenceTransformer('{MODEL_NAME}')
32
+ embeddings = model.encode(sentences)
33
+ print(embeddings)
34
+ ```
35
+
36
+
37
+
38
+ ## Usage (HuggingFace Transformers)
39
+ Without [sentence-transformers](https://www.SBERT.net), you can use the model like this: First, you pass your input through the transformer model, then you have to apply the right pooling-operation on-top of the contextualized word embeddings.
40
+
41
+ ```python
42
+ from transformers import AutoTokenizer, AutoModel
43
+ import torch
44
+
45
+
46
+ #Mean Pooling - Take attention mask into account for correct averaging
47
+ def mean_pooling(model_output, attention_mask):
48
+ token_embeddings = model_output[0] #First element of model_output contains all token embeddings
49
+ input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float()
50
+ return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(input_mask_expanded.sum(1), min=1e-9)
51
+
52
+
53
+ # Sentences we want sentence embeddings for
54
+ sentences = ['This is an example sentence', 'Each sentence is converted']
55
+
56
+ # Load model from HuggingFace Hub
57
+ tokenizer = AutoTokenizer.from_pretrained('{MODEL_NAME}')
58
+ model = AutoModel.from_pretrained('{MODEL_NAME}')
59
+
60
+ # Tokenize sentences
61
+ encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')
62
+
63
+ # Compute token embeddings
64
+ with torch.no_grad():
65
+ model_output = model(**encoded_input)
66
+
67
+ # Perform pooling. In this case, mean pooling.
68
+ sentence_embeddings = mean_pooling(model_output, encoded_input['attention_mask'])
69
+
70
+ print("Sentence embeddings:")
71
+ print(sentence_embeddings)
72
+ ```
73
+
74
+
75
+
76
+ ## Evaluation Results
77
+
78
+ <!--- Describe how your model was evaluated -->
79
+
80
+ For an automated evaluation of this model, see the *Sentence Embeddings Benchmark*: [https://seb.sbert.net](https://seb.sbert.net?model_name={MODEL_NAME})
81
+
82
+
83
+ ## Training
84
+ The model was trained with the parameters:
85
+
86
+ **DataLoader**:
87
+
88
+ `torch.utils.data.dataloader.DataLoader` of length 75 with parameters:
89
+ ```
90
+ {'batch_size': 4, 'sampler': 'torch.utils.data.sampler.SequentialSampler', 'batch_sampler': 'torch.utils.data.sampler.BatchSampler'}
91
+ ```
92
+
93
+ **Loss**:
94
+
95
+ `sentence_transformers.losses.MultipleNegativesRankingLoss.MultipleNegativesRankingLoss` with parameters:
96
+ ```
97
+ {'scale': 20.0, 'similarity_fct': 'cos_sim'}
98
+ ```
99
+
100
+ Parameters of the fit()-Method:
101
+ ```
102
+ {
103
+ "epochs": 10,
104
+ "evaluation_steps": 50,
105
+ "evaluator": "sentence_transformers.evaluation.InformationRetrievalEvaluator.InformationRetrievalEvaluator",
106
+ "max_grad_norm": 1,
107
+ "optimizer_class": "<class 'torch.optim.adamw.AdamW'>",
108
+ "optimizer_params": {
109
+ "lr": 2e-05
110
+ },
111
+ "scheduler": "WarmupLinear",
112
+ "steps_per_epoch": null,
113
+ "warmup_steps": 75,
114
+ "weight_decay": 0.01
115
+ }
116
+ ```
117
+
118
+
119
+ ## Full Model Architecture
120
+ ```
121
+ SentenceTransformer(
122
+ (0): Transformer({'max_seq_length': 512, 'do_lower_case': False}) with Transformer model: BertModel
123
+ (1): Pooling({'word_embedding_dimension': 1024, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False})
124
+ )
125
+ ```
126
+
127
+ ## Citing & Authors
128
+
129
+ <!--- Describe where people can find more information -->
config.json ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "WhereIsAI/UAE-Large-V1",
3
+ "architectures": [
4
+ "BertModel"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "classifier_dropout": null,
8
+ "gradient_checkpointing": false,
9
+ "hidden_act": "gelu",
10
+ "hidden_dropout_prob": 0.1,
11
+ "hidden_size": 1024,
12
+ "id2label": {
13
+ "0": "LABEL_0"
14
+ },
15
+ "initializer_range": 0.02,
16
+ "intermediate_size": 4096,
17
+ "label2id": {
18
+ "LABEL_0": 0
19
+ },
20
+ "layer_norm_eps": 1e-12,
21
+ "max_position_embeddings": 512,
22
+ "model_type": "bert",
23
+ "num_attention_heads": 16,
24
+ "num_hidden_layers": 24,
25
+ "pad_token_id": 0,
26
+ "position_embedding_type": "absolute",
27
+ "torch_dtype": "float32",
28
+ "transformers_version": "4.33.3",
29
+ "type_vocab_size": 2,
30
+ "use_cache": false,
31
+ "vocab_size": 30522
32
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "2.2.2",
4
+ "transformers": "4.33.3",
5
+ "pytorch": "2.1.0+cu118"
6
+ }
7
+ }
eval/Information-Retrieval_evaluation_results.csv ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ epoch,steps,cos_sim-Accuracy@1,cos_sim-Accuracy@3,cos_sim-Accuracy@5,cos_sim-Accuracy@10,cos_sim-Precision@1,cos_sim-Recall@1,cos_sim-Precision@3,cos_sim-Recall@3,cos_sim-Precision@5,cos_sim-Recall@5,cos_sim-Precision@10,cos_sim-Recall@10,cos_sim-MRR@10,cos_sim-NDCG@10,cos_sim-MAP@100,dot_score-Accuracy@1,dot_score-Accuracy@3,dot_score-Accuracy@5,dot_score-Accuracy@10,dot_score-Precision@1,dot_score-Recall@1,dot_score-Precision@3,dot_score-Recall@3,dot_score-Precision@5,dot_score-Recall@5,dot_score-Precision@10,dot_score-Recall@10,dot_score-MRR@10,dot_score-NDCG@10,dot_score-MAP@100
2
+ 0,50,0.92,0.94,0.97,0.97,0.92,0.92,0.3133333333333333,0.94,0.19399999999999995,0.97,0.09699999999999998,0.97,0.9348333333333333,0.9433531192611393,0.936996794871795,0.91,0.93,0.96,0.99,0.91,0.91,0.30999999999999994,0.93,0.19199999999999995,0.96,0.09899999999999999,0.99,0.9265277777777777,0.9410994187131007,0.9269625603864733
3
+ 0,-1,0.9,0.93,0.95,0.98,0.9,0.9,0.30999999999999994,0.93,0.18999999999999997,0.95,0.09799999999999998,0.98,0.9222619047619047,0.935874757101945,0.9236057782796914,0.88,0.93,0.95,0.97,0.88,0.88,0.30999999999999994,0.93,0.18999999999999997,0.95,0.09699999999999998,0.97,0.9094444444444446,0.9241137955963317,0.9118370518370519
4
+ 1,50,0.89,0.93,0.96,0.98,0.89,0.89,0.30999999999999994,0.93,0.19199999999999995,0.96,0.09799999999999999,0.98,0.9192500000000001,0.9337645464077078,0.9205833333333332,0.91,0.95,0.95,0.96,0.91,0.91,0.31666666666666665,0.95,0.18999999999999997,0.95,0.09599999999999997,0.96,0.9297619047619047,0.9372612259404771,0.9330800865800866
5
+ 1,-1,0.92,0.94,0.94,0.99,0.92,0.92,0.3133333333333333,0.94,0.18799999999999997,0.94,0.09899999999999999,0.99,0.9350793650793652,0.9475586359867411,0.9359126984126983,0.9,0.94,0.95,0.98,0.9,0.9,0.3133333333333333,0.94,0.18999999999999997,0.95,0.09799999999999999,0.98,0.9245119047619048,0.9376132885522472,0.926254329004329
6
+ 2,50,0.92,0.93,0.95,0.98,0.92,0.92,0.30999999999999994,0.93,0.18999999999999997,0.95,0.09799999999999999,0.98,0.9334682539682541,0.9441615578121003,0.9352106782106782,0.9,0.93,0.95,0.99,0.9,0.9,0.30999999999999994,0.93,0.18999999999999997,0.95,0.09899999999999999,0.99,0.9251349206349208,0.9403422247546098,0.9258492063492063
7
+ 2,-1,0.91,0.93,0.95,0.99,0.91,0.91,0.30999999999999994,0.93,0.18999999999999997,0.95,0.09899999999999999,0.99,0.9297182539682539,0.9436255041156724,0.9305515873015874,0.9,0.93,0.94,0.98,0.9,0.9,0.30999999999999994,0.93,0.18799999999999997,0.94,0.09799999999999999,0.98,0.9235119047619048,0.9368467840312288,0.9251902264402264
8
+ 3,50,0.91,0.93,0.95,0.99,0.91,0.91,0.30999999999999994,0.93,0.18999999999999997,0.95,0.09899999999999999,0.99,0.9292777777777778,0.9432373205795546,0.9301111111111111,0.9,0.93,0.94,0.98,0.9,0.9,0.30999999999999994,0.93,0.18799999999999997,0.94,0.09799999999999999,0.98,0.9232738095238094,0.9366180454934817,0.9248763736263735
9
+ 3,-1,0.91,0.93,0.94,0.99,0.91,0.91,0.30999999999999994,0.93,0.18799999999999997,0.94,0.09899999999999999,0.99,0.9289444444444445,0.9429308643782894,0.9297777777777777,0.9,0.93,0.94,0.98,0.9,0.9,0.30999999999999994,0.93,0.18799999999999997,0.94,0.09799999999999999,0.98,0.9232738095238094,0.9366180454934817,0.9248763736263735
10
+ 4,50,0.91,0.93,0.94,0.99,0.91,0.91,0.30999999999999994,0.93,0.18799999999999997,0.94,0.09899999999999999,0.99,0.928595238095238,0.9425824741470816,0.9294285714285714,0.9,0.93,0.94,0.98,0.9,0.9,0.30999999999999994,0.93,0.18799999999999997,0.94,0.09799999999999999,0.98,0.9228174603174604,0.9361506633055708,0.9244200244200245
11
+ 4,-1,0.91,0.93,0.94,0.99,0.91,0.91,0.30999999999999994,0.93,0.18799999999999997,0.94,0.09899999999999999,0.99,0.9282182539682539,0.9422093867981173,0.9290515873015872,0.89,0.93,0.94,0.98,0.89,0.89,0.30999999999999994,0.93,0.18799999999999997,0.94,0.09799999999999999,0.98,0.9178174603174604,0.9324599608412855,0.9194200244200245
12
+ 5,50,0.91,0.93,0.94,0.98,0.91,0.91,0.30999999999999994,0.93,0.18799999999999997,0.94,0.09799999999999999,0.98,0.9269007936507937,0.9389957051582448,0.9286432178932178,0.88,0.93,0.94,0.98,0.88,0.88,0.30999999999999994,0.93,0.18799999999999997,0.94,0.09799999999999999,0.98,0.9128174603174604,0.928769258377,0.9144200244200245
13
+ 5,-1,0.91,0.93,0.94,0.98,0.91,0.91,0.30999999999999994,0.93,0.18799999999999997,0.94,0.09799999999999999,0.98,0.9269007936507937,0.9389957051582448,0.9285674603174603,0.88,0.93,0.94,0.98,0.88,0.88,0.30999999999999994,0.93,0.18799999999999997,0.94,0.09799999999999999,0.98,0.912638888888889,0.928590573811524,0.9142414529914531
14
+ 6,50,0.89,0.93,0.94,0.98,0.89,0.89,0.30999999999999994,0.93,0.18799999999999997,0.94,0.09799999999999999,0.98,0.9169007936507937,0.931614300229674,0.9185674603174603,0.87,0.93,0.94,0.98,0.87,0.87,0.30999999999999994,0.93,0.18799999999999997,0.94,0.09799999999999999,0.98,0.9074007936507936,0.9246711328094918,0.9090033577533577
15
+ 6,-1,0.89,0.93,0.94,0.98,0.89,0.89,0.30999999999999994,0.93,0.18799999999999997,0.94,0.09799999999999999,0.98,0.9169007936507937,0.931614300229674,0.9185674603174603,0.87,0.93,0.94,0.98,0.87,0.87,0.30999999999999994,0.93,0.18799999999999997,0.94,0.09799999999999999,0.98,0.9072619047619048,0.9245267839982741,0.9088644688644688
16
+ 7,50,0.89,0.93,0.94,0.98,0.89,0.89,0.30999999999999994,0.93,0.18799999999999997,0.94,0.09799999999999999,0.98,0.9169007936507937,0.931614300229674,0.9185674603174603,0.87,0.93,0.94,0.98,0.87,0.87,0.30999999999999994,0.93,0.18799999999999997,0.94,0.09799999999999999,0.98,0.9071507936507937,0.9244071323048132,0.9087533577533579
17
+ 7,-1,0.89,0.93,0.94,0.98,0.89,0.89,0.30999999999999994,0.93,0.18799999999999997,0.94,0.09799999999999999,0.98,0.9169007936507937,0.931614300229674,0.9185674603174603,0.87,0.93,0.94,0.98,0.87,0.87,0.30999999999999994,0.93,0.18799999999999997,0.94,0.09799999999999999,0.98,0.9071507936507937,0.9244071323048132,0.9087533577533579
18
+ 8,50,0.89,0.93,0.94,0.98,0.89,0.89,0.30999999999999994,0.93,0.18799999999999997,0.94,0.09799999999999999,0.98,0.9169007936507937,0.931614300229674,0.9185674603174603,0.87,0.94,0.94,0.97,0.87,0.87,0.3133333333333333,0.94,0.18799999999999997,0.94,0.09699999999999998,0.97,0.9068730158730159,0.9220900667674394,0.9093846708846709
19
+ 8,-1,0.89,0.93,0.94,0.98,0.89,0.89,0.30999999999999994,0.93,0.18799999999999997,0.94,0.09799999999999999,0.98,0.9169007936507937,0.931614300229674,0.9185674603174603,0.87,0.94,0.94,0.97,0.87,0.87,0.3133333333333333,0.94,0.18799999999999997,0.94,0.09699999999999998,0.97,0.9068730158730159,0.9220900667674394,0.9093846708846709
20
+ 9,50,0.89,0.93,0.94,0.98,0.89,0.89,0.30999999999999994,0.93,0.18799999999999997,0.94,0.09799999999999999,0.98,0.9169007936507937,0.931614300229674,0.9185674603174603,0.87,0.94,0.94,0.97,0.87,0.87,0.3133333333333333,0.94,0.18799999999999997,0.94,0.09699999999999998,0.97,0.9068730158730159,0.9220900667674394,0.9093846708846709
21
+ 9,-1,0.89,0.93,0.94,0.98,0.89,0.89,0.30999999999999994,0.93,0.18799999999999997,0.94,0.09799999999999999,0.98,0.9169007936507937,0.931614300229674,0.9185674603174603,0.87,0.94,0.94,0.97,0.87,0.87,0.3133333333333333,0.94,0.18799999999999997,0.94,0.09699999999999998,0.97,0.9068730158730159,0.9220900667674394,0.9093846708846709
modules.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "idx": 0,
4
+ "name": "0",
5
+ "path": "",
6
+ "type": "sentence_transformers.models.Transformer"
7
+ },
8
+ {
9
+ "idx": 1,
10
+ "name": "1",
11
+ "path": "1_Pooling",
12
+ "type": "sentence_transformers.models.Pooling"
13
+ }
14
+ ]
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a22a9ec99f80c62d220ae9dfa1b6eac46a2cca481f079719a649a85f908f04e4
3
+ size 1340699814
sentence_bert_config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "max_seq_length": 512,
3
+ "do_lower_case": false
4
+ }
special_tokens_map.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": "[CLS]",
3
+ "mask_token": "[MASK]",
4
+ "pad_token": "[PAD]",
5
+ "sep_token": "[SEP]",
6
+ "unk_token": "[UNK]"
7
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "[PAD]",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "100": {
12
+ "content": "[UNK]",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "101": {
20
+ "content": "[CLS]",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "102": {
28
+ "content": "[SEP]",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "103": {
36
+ "content": "[MASK]",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "clean_up_tokenization_spaces": true,
45
+ "cls_token": "[CLS]",
46
+ "do_basic_tokenize": true,
47
+ "do_lower_case": true,
48
+ "mask_token": "[MASK]",
49
+ "model_max_length": 512,
50
+ "never_split": null,
51
+ "pad_token": "[PAD]",
52
+ "sep_token": "[SEP]",
53
+ "strip_accents": null,
54
+ "tokenize_chinese_chars": true,
55
+ "tokenizer_class": "BertTokenizer",
56
+ "unk_token": "[UNK]"
57
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff