tinybeachthor commited on
Commit
8d3ccad
·
1 Parent(s): a385f00
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 ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ pipeline_tag: sentence-similarity
3
+ license: apache-2.0
4
+ tags:
5
+ - sentence-transformers
6
+ - feature-extraction
7
+ - sentence-similarity
8
+ - transformers
9
+ datasets:
10
+ - flax-sentence-embeddings/stackexchange_xml
11
+ - s2orc
12
+ - ms_marco
13
+ - wiki_atomic_edits
14
+ - snli
15
+ - multi_nli
16
+ - embedding-data/altlex
17
+ - embedding-data/simple-wiki
18
+ - embedding-data/flickr30k-captions
19
+ - embedding-data/coco_captions
20
+ - embedding-data/sentence-compression
21
+ - embedding-data/QQP
22
+ - yahoo_answers_topics
23
+
24
+ ---
25
+
26
+ # sentence-transformers/paraphrase-albert-small-v2
27
+
28
+ 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.
29
+
30
+
31
+
32
+ ## Usage (Sentence-Transformers)
33
+
34
+ Using this model becomes easy when you have [sentence-transformers](https://www.SBERT.net) installed:
35
+
36
+ ```
37
+ pip install -U sentence-transformers
38
+ ```
39
+
40
+ Then you can use the model like this:
41
+
42
+ ```python
43
+ from sentence_transformers import SentenceTransformer
44
+ sentences = ["This is an example sentence", "Each sentence is converted"]
45
+
46
+ model = SentenceTransformer('sentence-transformers/paraphrase-albert-small-v2')
47
+ embeddings = model.encode(sentences)
48
+ print(embeddings)
49
+ ```
50
+
51
+
52
+
53
+ ## Usage (HuggingFace Transformers)
54
+ 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.
55
+
56
+ ```python
57
+ from transformers import AutoTokenizer, AutoModel
58
+ import torch
59
+
60
+
61
+ #Mean Pooling - Take attention mask into account for correct averaging
62
+ def mean_pooling(model_output, attention_mask):
63
+ token_embeddings = model_output[0] #First element of model_output contains all token embeddings
64
+ input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float()
65
+ return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(input_mask_expanded.sum(1), min=1e-9)
66
+
67
+
68
+ # Sentences we want sentence embeddings for
69
+ sentences = ['This is an example sentence', 'Each sentence is converted']
70
+
71
+ # Load model from HuggingFace Hub
72
+ tokenizer = AutoTokenizer.from_pretrained('sentence-transformers/paraphrase-albert-small-v2')
73
+ model = AutoModel.from_pretrained('sentence-transformers/paraphrase-albert-small-v2')
74
+
75
+ # Tokenize sentences
76
+ encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')
77
+
78
+ # Compute token embeddings
79
+ with torch.no_grad():
80
+ model_output = model(**encoded_input)
81
+
82
+ # Perform pooling. In this case, max pooling.
83
+ sentence_embeddings = mean_pooling(model_output, encoded_input['attention_mask'])
84
+
85
+ print("Sentence embeddings:")
86
+ print(sentence_embeddings)
87
+ ```
88
+
89
+
90
+
91
+ ## Evaluation Results
92
+
93
+
94
+
95
+ For an automated evaluation of this model, see the *Sentence Embeddings Benchmark*: [https://seb.sbert.net](https://seb.sbert.net?model_name=sentence-transformers/paraphrase-albert-small-v2)
96
+
97
+
98
+
99
+ ## Full Model Architecture
100
+ ```
101
+ SentenceTransformer(
102
+ (0): Transformer({'max_seq_length': 100, 'do_lower_case': False}) with Transformer model: AlbertModel
103
+ (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})
104
+ )
105
+ ```
106
+
107
+ ## Citing & Authors
108
+
109
+ This model was trained by [sentence-transformers](https://www.sbert.net/).
110
+
111
+ If you find this model helpful, feel free to cite our publication [Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks](https://arxiv.org/abs/1908.10084):
112
+ ```bibtex
113
+ @inproceedings{reimers-2019-sentence-bert,
114
+ title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
115
+ author = "Reimers, Nils and Gurevych, Iryna",
116
+ booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
117
+ month = "11",
118
+ year = "2019",
119
+ publisher = "Association for Computational Linguistics",
120
+ url = "http://arxiv.org/abs/1908.10084",
121
+ }
122
+ ```
config.json ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "old_models/paraphrase-albert-small-v2/0_Transformer",
3
+ "architectures": [
4
+ "AlbertModel"
5
+ ],
6
+ "attention_probs_dropout_prob": 0,
7
+ "bos_token_id": 2,
8
+ "classifier_dropout_prob": 0.1,
9
+ "down_scale_factor": 1,
10
+ "embedding_size": 128,
11
+ "eos_token_id": 3,
12
+ "gap_size": 0,
13
+ "hidden_act": "gelu_new",
14
+ "hidden_dropout_prob": 0,
15
+ "hidden_size": 768,
16
+ "initializer_range": 0.02,
17
+ "inner_group_num": 1,
18
+ "intermediate_size": 3072,
19
+ "layer_norm_eps": 1e-12,
20
+ "max_position_embeddings": 512,
21
+ "model_type": "albert",
22
+ "net_structure_type": 0,
23
+ "num_attention_heads": 12,
24
+ "num_hidden_groups": 1,
25
+ "num_hidden_layers": 6,
26
+ "num_memory_blocks": 0,
27
+ "pad_token_id": 0,
28
+ "position_embedding_type": "absolute",
29
+ "transformers_version": "4.7.0",
30
+ "type_vocab_size": 2,
31
+ "vocab_size": 30000
32
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "2.0.0",
4
+ "transformers": "4.7.0",
5
+ "pytorch": "1.9.0+cu102"
6
+ }
7
+ }
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:4120d577507f732a10585d7993b963f6ee7c9e963a3926e88a0c1bbaeedf9c06
3
+ size 46747799
rust_model.ot ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c24ca54a1794d338ee78b8a9d0a6357bf3db8e0408d826fdf0ae20d1fdfed322
3
+ size 46745679
sentence_bert_config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "max_seq_length": 100,
3
+ "do_lower_case": false
4
+ }
special_tokens_map.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"bos_token": "[CLS]", "eos_token": "[SEP]", "unk_token": "<unk>", "sep_token": "[SEP]", "pad_token": "<pad>", "cls_token": "[CLS]", "mask_token": {"content": "[MASK]", "single_word": false, "lstrip": true, "rstrip": false, "normalized": false}}
spiece.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fefb02b667a6c5c2fe27602d28e5fb3428f66ab89c7d6f388e7c8d44a02d0336
3
+ size 760289
tf_model.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:759fe84f34b16e5b96daae2f7965e24cf570af8d22e654c4086d88c1588da861
3
+ size 46771352
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"do_lower_case": true, "remove_space": true, "keep_accents": false, "bos_token": "[CLS]", "eos_token": "[SEP]", "unk_token": "<unk>", "sep_token": "[SEP]", "pad_token": "<pad>", "cls_token": "[CLS]", "mask_token": {"content": "[MASK]", "single_word": false, "lstrip": true, "rstrip": false, "normalized": true, "__type": "AddedToken"}, "model_max_length": 512, "special_tokens_map_file": null, "name_or_path": "old_models/paraphrase-albert-small-v2/0_Transformer"}