abhijitt commited on
Commit
790f46d
·
1 Parent(s): e32acfc

Upload with huggingface_hub

Browse files
Files changed (6) hide show
  1. 1_Pooling/config.json +1 -1
  2. README.md +6 -44
  3. config.json +16 -14
  4. modules.json +6 -0
  5. pytorch_model.bin +2 -2
  6. tokenizer_config.json +4 -2
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 -->
@@ -85,7 +46,7 @@ The model was trained with the parameters:
85
 
86
  **DataLoader**:
87
 
88
- `torch.utils.data.dataloader.DataLoader` of length 1 with parameters:
89
  ```
90
  {'batch_size': 64, 'sampler': 'torch.utils.data.sampler.RandomSampler', 'batch_sampler': 'torch.utils.data.sampler.BatchSampler'}
91
  ```
@@ -110,7 +71,7 @@ Parameters of the fit()-Method:
110
  },
111
  "scheduler": "WarmupLinear",
112
  "steps_per_epoch": null,
113
- "warmup_steps": 1,
114
  "weight_decay": 0.01
115
  }
116
  ```
@@ -119,8 +80,9 @@ Parameters of the fit()-Method:
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
 
 
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 -->
 
46
 
47
  **DataLoader**:
48
 
49
+ `torch.utils.data.dataloader.DataLoader` of length 1369 with parameters:
50
  ```
51
  {'batch_size': 64, 'sampler': 'torch.utils.data.sampler.RandomSampler', 'batch_sampler': 'torch.utils.data.sampler.BatchSampler'}
52
  ```
 
71
  },
72
  "scheduler": "WarmupLinear",
73
  "steps_per_epoch": null,
74
+ "warmup_steps": 1369,
75
  "weight_decay": 0.01
76
  }
77
  ```
 
80
  ## Full Model Architecture
81
  ```
82
  SentenceTransformer(
83
+ (0): Transformer({'max_seq_length': 512, 'do_lower_case': False}) with Transformer model: BertModel
84
+ (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})
85
+ (2): Normalize()
86
  )
87
  ```
88
 
config.json CHANGED
@@ -1,24 +1,26 @@
1
  {
2
- "_name_or_path": "/home/jtang/.cache/torch/sentence_transformers/sentence-transformers_msmarco-distilbert-dot-v5/",
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.26.1",
 
 
23
  "vocab_size": 30522
24
  }
 
1
  {
2
+ "_name_or_path": "/home/jtang/.cache/torch/sentence_transformers/sentence-transformers_multi-qa-MiniLM-L6-cos-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": 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": 6,
19
  "pad_token_id": 0,
20
+ "position_embedding_type": "absolute",
 
 
 
21
  "torch_dtype": "float32",
22
  "transformers_version": "4.26.1",
23
+ "type_vocab_size": 2,
24
+ "use_cache": true,
25
  "vocab_size": 30522
26
  }
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:ea71ca5fdecde873030ba6d8c648c4c0bbf25de7880b35fd09c3f11b34fbe25e
3
- size 265484701
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ea83c0bc402863aaaea0d8cf6002f1da792a5c625eb7441d9295ceb5eed1d30e
3
+ size 90891565
tokenizer_config.json CHANGED
@@ -1,14 +1,16 @@
1
  {
2
  "cls_token": "[CLS]",
 
3
  "do_lower_case": true,
4
  "mask_token": "[MASK]",
5
  "model_max_length": 512,
6
- "name_or_path": "/home/jtang/.cache/torch/sentence_transformers/sentence-transformers_msmarco-distilbert-dot-v5/",
 
7
  "pad_token": "[PAD]",
8
  "sep_token": "[SEP]",
9
  "special_tokens_map_file": null,
10
  "strip_accents": null,
11
  "tokenize_chinese_chars": true,
12
- "tokenizer_class": "DistilBertTokenizer",
13
  "unk_token": "[UNK]"
14
  }
 
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/jtang/.cache/torch/sentence_transformers/sentence-transformers_multi-qa-MiniLM-L6-cos-v1/",
8
+ "never_split": null,
9
  "pad_token": "[PAD]",
10
  "sep_token": "[SEP]",
11
  "special_tokens_map_file": null,
12
  "strip_accents": null,
13
  "tokenize_chinese_chars": true,
14
+ "tokenizer_class": "BertTokenizer",
15
  "unk_token": "[UNK]"
16
  }