sbhargav commited on
Commit
0148bbe
1 Parent(s): e2a3a27
.DS_Store ADDED
Binary file (6.15 kB). View file
 
1_Pooling/config.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "word_embedding_dimension": 768,
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
+ }
README.md CHANGED
@@ -1,3 +1,129 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 768 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 30 with parameters:
89
+ ```
90
+ {'batch_size': 10, 'sampler': 'torch.utils.data.sampler.RandomSampler', '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": 20,
104
+ "evaluation_steps": -1,
105
+ "evaluator": "src.data.IrEvaluator",
106
+ "max_grad_norm": 1,
107
+ "optimizer_class": "<class 'torch.optim.adamw.AdamW'>",
108
+ "optimizer_params": {
109
+ "lr": 6e-05
110
+ },
111
+ "scheduler": "WarmupLinear",
112
+ "steps_per_epoch": null,
113
+ "warmup_steps": 0,
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: DistilBertModel
123
+ (1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False})
124
+ )
125
+ ```
126
+
127
+ ## Citing & Authors
128
+
129
+ <!--- Describe where people can find more information -->
config.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "/home/sbhargav/.cache/torch/sentence_transformers/distilbert-base-uncased",
3
+ "activation": "gelu",
4
+ "architectures": [
5
+ "DistilBertModel"
6
+ ],
7
+ "attention_dropout": 0.1,
8
+ "dim": 768,
9
+ "dropout": 0.1,
10
+ "hidden_dim": 3072,
11
+ "initializer_range": 0.02,
12
+ "max_position_embeddings": 512,
13
+ "model_type": "distilbert",
14
+ "n_heads": 12,
15
+ "n_layers": 6,
16
+ "pad_token_id": 0,
17
+ "qa_dropout": 0.1,
18
+ "seq_classif_dropout": 0.2,
19
+ "sinusoidal_pos_embds": false,
20
+ "tie_weights_": true,
21
+ "torch_dtype": "float32",
22
+ "transformers_version": "4.40.2",
23
+ "vocab_size": 30522
24
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "2.2.2",
4
+ "transformers": "4.40.2",
5
+ "pytorch": "2.3.0+cu121"
6
+ }
7
+ }
eval/Information-Retrieval_evaluation_dev2_results.csv ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ epoch,steps,cos_sim-Accuracy@1000,cos_sim-Precision@1000,cos_sim-Recall@1000,cos_sim-MRR@1000,cos_sim-NDCG@10,cos_sim-NDCG@1000,cos_sim-MAP@1000,dot_score-Accuracy@1000,dot_score-Precision@1000,dot_score-Recall@1000,dot_score-MRR@1000,dot_score-NDCG@10,dot_score-NDCG@1000,dot_score-MAP@1000
2
+ 0,-1,1.0,0.0010000000000000002,1.0,0.21478264165219874,0.2654187903251689,0.3647205719047765,0.21478264165219874,1.0,0.0010000000000000002,1.0,0.1765448955743,0.22276776356656483,0.3253456249149124,0.17654489557430006
3
+ 1,-1,1.0,0.0010000000000000002,1.0,0.23031055133959144,0.2746423606300469,0.37352192135174483,0.23031055133959144,1.0,0.0010000000000000002,1.0,0.16116246733664852,0.19528828917405788,0.31252840054752035,0.16116246733664857
4
+ 2,-1,1.0,0.0010000000000000002,1.0,0.2383370163671117,0.2883509512375327,0.3826862609192197,0.23833701636711163,1.0,0.0010000000000000002,1.0,0.19819666867135277,0.2507022672025061,0.3467474561398994,0.19819666867135283
5
+ 3,-1,1.0,0.0010000000000000002,1.0,0.24637383756632006,0.28992012211590235,0.3865205215227734,0.24637383756631992,1.0,0.0010000000000000002,1.0,0.19783645621287102,0.23811451109512793,0.3452348739484996,0.19783645621287113
6
+ 4,-1,1.0,0.0010000000000000002,1.0,0.2557476734165179,0.2966803482091579,0.3957932200186219,0.25574767341651766,1.0,0.0010000000000000002,1.0,0.20823103354324754,0.24815140813977554,0.35469422697570885,0.20823103354324757
7
+ 5,-1,1.0,0.0010000000000000002,1.0,0.25756658380784053,0.2989068305046046,0.39380323104667836,0.25756658380784025,1.0,0.0010000000000000002,1.0,0.20437947243168494,0.2525261553225652,0.3496621197214021,0.2043794724316849
8
+ 6,-1,1.0,0.0010000000000000002,1.0,0.23669045791896753,0.2804258456624145,0.38035758053755186,0.23669045791896745,1.0,0.0010000000000000002,1.0,0.20975338393256387,0.26075703370118947,0.35551409625305647,0.20975338393256387
9
+ 7,-1,1.0,0.0010000000000000002,1.0,0.2737882744689679,0.31171596459545403,0.4102114051123706,0.2737882744689678,1.0,0.0010000000000000002,1.0,0.24438387394513172,0.27600432363260474,0.38510689522452357,0.24438387394513172
10
+ 8,-1,1.0,0.0010000000000000002,1.0,0.26494423733598255,0.30832544722327154,0.40202668605917824,0.2649442373359824,1.0,0.0010000000000000002,1.0,0.21722168085477975,0.25874603116307354,0.36265460604362987,0.2172216808547797
11
+ 9,-1,1.0,0.0010000000000000002,1.0,0.26094359915856363,0.3044546975127253,0.39899784302507024,0.2609435991585635,1.0,0.0010000000000000002,1.0,0.22261176656523182,0.2683569519897886,0.3669187287387258,0.2226117665652317
12
+ 10,-1,1.0,0.0010000000000000002,1.0,0.269390808631807,0.3152140275643737,0.4062630677045657,0.2693908086318068,1.0,0.0010000000000000002,1.0,0.23118253247694098,0.2755125138473274,0.37430345302078566,0.2311825324769409
13
+ 11,-1,1.0,0.0010000000000000002,1.0,0.2730847159534095,0.32024940855765205,0.4104054486890142,0.27308471595340944,1.0,0.0010000000000000002,1.0,0.2269044694743224,0.27821982154420577,0.3721995471484176,0.2269044694743225
14
+ 12,-1,1.0,0.0010000000000000002,1.0,0.279196089268259,0.32485476763603627,0.41379654167771546,0.2791960892682589,1.0,0.0010000000000000002,1.0,0.2231122958332923,0.27899167086501536,0.368056164661416,0.22311229583329237
15
+ 13,-1,1.0,0.0010000000000000002,1.0,0.2753154284869351,0.3201150230583376,0.4109468195346987,0.27531542848693497,1.0,0.0010000000000000002,1.0,0.23153649693602252,0.28220717522626226,0.3750097567553414,0.23153649693602238
16
+ 14,-1,1.0,0.0010000000000000002,1.0,0.2784425030707504,0.32938109226349593,0.4140191568082857,0.27844250307075025,1.0,0.0010000000000000002,1.0,0.24016439644121898,0.289559450484183,0.3823046204628328,0.24016439644121892
17
+ 15,-1,1.0,0.0010000000000000002,1.0,0.2823079687517416,0.33051415699870157,0.4174743001837484,0.2823079687517415,1.0,0.0010000000000000002,1.0,0.23763818376383805,0.2863916567312545,0.38114435370445005,0.2376381837638379
18
+ 16,-1,1.0,0.0010000000000000002,1.0,0.26681816983793866,0.3209140189385327,0.40560284906173577,0.2668181698379386,1.0,0.0010000000000000002,1.0,0.2300070511833308,0.28030617760569226,0.3747302250744342,0.23000705118333079
19
+ 17,-1,1.0,0.0010000000000000002,1.0,0.27013705725012205,0.3218974688609506,0.4075391173401515,0.2701370572501219,1.0,0.0010000000000000002,1.0,0.22542751756062027,0.27506332707783193,0.37064872603511956,0.22542751756062018
20
+ 18,-1,1.0,0.0010000000000000002,1.0,0.26682658699873474,0.3195330568205544,0.40530654626640855,0.26682658699873457,1.0,0.0010000000000000002,1.0,0.22761415599019932,0.27876562150455425,0.3727079685310349,0.2276141559901992
21
+ 19,-1,1.0,0.0010000000000000002,1.0,0.26654827028275446,0.32117103467843794,0.4051199190694705,0.26654827028275424,1.0,0.0010000000000000002,1.0,0.23214366018228147,0.2821787226335282,0.37618398308539,0.23214366018228139
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c14049a0196ca0d2b392198462dbc9c34c1890af4bf4a9bf4ef8a4a08060771c
3
+ size 265462608
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
+ ]
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,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_lower_case": true,
47
+ "mask_token": "[MASK]",
48
+ "model_max_length": 512,
49
+ "pad_token": "[PAD]",
50
+ "sep_token": "[SEP]",
51
+ "strip_accents": null,
52
+ "tokenize_chinese_chars": true,
53
+ "tokenizer_class": "DistilBertTokenizer",
54
+ "unk_token": "[UNK]"
55
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff