Aymen Ben Othmen commited on
Commit
41735f6
1 Parent(s): eab256f

Add SetFit model

Browse files
1_Pooling/config.json CHANGED
@@ -1,5 +1,5 @@
1
  {
2
- "word_embedding_dimension": 768,
3
  "pooling_mode_cls_token": false,
4
  "pooling_mode_mean_tokens": true,
5
  "pooling_mode_max_tokens": false,
 
1
  {
2
+ "word_embedding_dimension": 384,
3
  "pooling_mode_cls_token": false,
4
  "pooling_mode_mean_tokens": true,
5
  "pooling_mode_max_tokens": false,
README.md CHANGED
@@ -4,13 +4,12 @@ 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
 
@@ -35,44 +34,6 @@ print(embeddings)
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 -->
@@ -116,8 +77,9 @@ Parameters of the fit()-Method:
116
  ## Full Model Architecture
117
  ```
118
  SentenceTransformer(
119
- (0): Transformer({'max_seq_length': 128, 'do_lower_case': False}) with Transformer model: XLMRobertaModel
120
- (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})
 
121
  )
122
  ```
123
 
 
4
  - sentence-transformers
5
  - feature-extraction
6
  - sentence-similarity
 
7
 
8
  ---
9
 
10
  # {MODEL_NAME}
11
 
12
+ This is a [sentence-transformers](https://www.SBERT.net) model: It maps sentences & paragraphs to a 384 dimensional dense vector space and can be used for tasks like clustering or semantic search.
13
 
14
  <!--- Describe your model here -->
15
 
 
34
 
35
 
36
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  ## Evaluation Results
38
 
39
  <!--- Describe how your model was evaluated -->
 
77
  ## Full Model Architecture
78
  ```
79
  SentenceTransformer(
80
+ (0): Transformer({'max_seq_length': 128, 'do_lower_case': False}) with Transformer model: BertModel
81
+ (1): Pooling({'word_embedding_dimension': 384, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False})
82
+ (2): Normalize()
83
  )
84
  ```
85
 
config.json CHANGED
@@ -1,29 +1,26 @@
1
  {
2
- "_name_or_path": "/home/ubuntu/.cache/torch/sentence_transformers/sentence-transformers_paraphrase-multilingual-mpnet-base-v2/",
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
  "gradient_checkpointing": false,
11
  "hidden_act": "gelu",
12
  "hidden_dropout_prob": 0.1,
13
- "hidden_size": 768,
14
  "initializer_range": 0.02,
15
- "intermediate_size": 3072,
16
- "layer_norm_eps": 1e-05,
17
- "max_position_embeddings": 514,
18
- "model_type": "xlm-roberta",
19
  "num_attention_heads": 12,
20
  "num_hidden_layers": 12,
21
- "output_past": true,
22
- "pad_token_id": 1,
23
  "position_embedding_type": "absolute",
24
  "torch_dtype": "float32",
25
  "transformers_version": "4.22.2",
26
- "type_vocab_size": 1,
27
  "use_cache": true,
28
- "vocab_size": 250002
29
  }
 
1
  {
2
+ "_name_or_path": "/home/ubuntu/.cache/torch/sentence_transformers/sentence-transformers_all-MiniLM-L12-v2/",
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": 384,
12
  "initializer_range": 0.02,
13
+ "intermediate_size": 1536,
14
+ "layer_norm_eps": 1e-12,
15
+ "max_position_embeddings": 512,
16
+ "model_type": "bert",
17
  "num_attention_heads": 12,
18
  "num_hidden_layers": 12,
19
+ "pad_token_id": 0,
 
20
  "position_embedding_type": "absolute",
21
  "torch_dtype": "float32",
22
  "transformers_version": "4.22.2",
23
+ "type_vocab_size": 2,
24
  "use_cache": true,
25
+ "vocab_size": 30522
26
  }
config_sentence_transformers.json CHANGED
@@ -1,7 +1,7 @@
1
  {
2
  "__version__": {
3
  "sentence_transformers": "2.0.0",
4
- "transformers": "4.7.0",
5
- "pytorch": "1.9.0+cu102"
6
  }
7
  }
 
1
  {
2
  "__version__": {
3
  "sentence_transformers": "2.0.0",
4
+ "transformers": "4.6.1",
5
+ "pytorch": "1.8.1"
6
  }
7
  }
model_head.pkl CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:9f56361ace5f6f56a0e02ed037fe2b27d3f04310b927b947e29a4e3d7a659d56
3
- size 6991
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f6eae23b659d39b6f62d822370ba98e574e166200fa517cc4b6983f8c79ecacb
3
+ size 3919
modules.json CHANGED
@@ -10,5 +10,11 @@
10
  "name": "1",
11
  "path": "1_Pooling",
12
  "type": "sentence_transformers.models.Pooling"
 
 
 
 
 
 
13
  }
14
  ]
 
10
  "name": "1",
11
  "path": "1_Pooling",
12
  "type": "sentence_transformers.models.Pooling"
13
+ },
14
+ {
15
+ "idx": 2,
16
+ "name": "2",
17
+ "path": "2_Normalize",
18
+ "type": "sentence_transformers.models.Normalize"
19
  }
20
  ]
pytorch_model.bin CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:06f5c7293262539ec4fa42b6dd01557b97de7c19644c410a3c08165514482343
3
- size 1112244081
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6770ebc876245c3b1e9a22ad7b6bf7f8cbe68972d992371358b6cacdd3f62b85
3
+ size 133509425
special_tokens_map.json CHANGED
@@ -1,15 +1,7 @@
1
  {
2
- "bos_token": "<s>",
3
- "cls_token": "<s>",
4
- "eos_token": "</s>",
5
- "mask_token": {
6
- "content": "<mask>",
7
- "lstrip": true,
8
- "normalized": false,
9
- "rstrip": false,
10
- "single_word": false
11
- },
12
- "pad_token": "<pad>",
13
- "sep_token": "</s>",
14
- "unk_token": "<unk>"
15
  }
 
1
  {
2
+ "cls_token": "[CLS]",
3
+ "mask_token": "[MASK]",
4
+ "pad_token": "[PAD]",
5
+ "sep_token": "[SEP]",
6
+ "unk_token": "[UNK]"
 
 
 
 
 
 
 
 
7
  }
tokenizer.json CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:b60b6b43406a48bf3638526314f3d232d97058bc93472ff2de930d43686fa441
3
- size 17082913
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2fc687b11de0bc1b3d8348f92e3b49ef1089a621506c7661fbf3248fcd54947e
3
+ size 711649
tokenizer_config.json CHANGED
@@ -1,20 +1,16 @@
1
  {
2
- "bos_token": "<s>",
3
- "cls_token": "<s>",
4
- "eos_token": "</s>",
5
- "mask_token": {
6
- "__type": "AddedToken",
7
- "content": "<mask>",
8
- "lstrip": true,
9
- "normalized": true,
10
- "rstrip": false,
11
- "single_word": false
12
- },
13
  "model_max_length": 512,
14
- "name_or_path": "/home/ubuntu/.cache/torch/sentence_transformers/sentence-transformers_paraphrase-multilingual-mpnet-base-v2/",
15
- "pad_token": "<pad>",
16
- "sep_token": "</s>",
17
- "special_tokens_map_file": null,
18
- "tokenizer_class": "XLMRobertaTokenizer",
19
- "unk_token": "<unk>"
 
 
 
20
  }
 
1
  {
2
+ "cls_token": "[CLS]",
3
+ "do_basic_tokenize": true,
4
+ "do_lower_case": true,
5
+ "mask_token": "[MASK]",
 
 
 
 
 
 
 
6
  "model_max_length": 512,
7
+ "name_or_path": "/home/ubuntu/.cache/torch/sentence_transformers/sentence-transformers_all-MiniLM-L12-v2/",
8
+ "never_split": null,
9
+ "pad_token": "[PAD]",
10
+ "sep_token": "[SEP]",
11
+ "special_tokens_map_file": "/home/ubuntu/.cache/torch/sentence_transformers/sentence-transformers_all-MiniLM-L12-v2/special_tokens_map.json",
12
+ "strip_accents": null,
13
+ "tokenize_chinese_chars": true,
14
+ "tokenizer_class": "BertTokenizer",
15
+ "unk_token": "[UNK]"
16
  }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff