Wills17 commited on
Commit
356a914
·
verified ·
1 Parent(s): 0ae5d0f

Upload 11 files

Browse files
models/paraphrase-MiniLM-L3-v2/1_Pooling/config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "word_embedding_dimension": 384,
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
+ "include_prompt": true
10
+ }
models/paraphrase-MiniLM-L3-v2/README.md ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ library_name: sentence-transformers
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
+ pipeline_tag: sentence-similarity
24
+ ---
25
+
26
+ # sentence-transformers/paraphrase-MiniLM-L3-v2
27
+
28
+ 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.
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-MiniLM-L3-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-MiniLM-L3-v2')
73
+ model = AutoModel.from_pretrained('sentence-transformers/paraphrase-MiniLM-L3-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
+ ## Full Model Architecture
92
+ ```
93
+ SentenceTransformer(
94
+ (0): Transformer({'max_seq_length': 128, 'do_lower_case': False}) with Transformer model: BertModel
95
+ (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})
96
+ )
97
+ ```
98
+
99
+ ## Citing & Authors
100
+
101
+ This model was trained by [sentence-transformers](https://www.sbert.net/).
102
+
103
+ 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):
104
+ ```bibtex
105
+ @inproceedings{reimers-2019-sentence-bert,
106
+ title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
107
+ author = "Reimers, Nils and Gurevych, Iryna",
108
+ booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
109
+ month = "11",
110
+ year = "2019",
111
+ publisher = "Association for Computational Linguistics",
112
+ url = "http://arxiv.org/abs/1908.10084",
113
+ }
114
+ ```
models/paraphrase-MiniLM-L3-v2/config.json ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "BertModel"
4
+ ],
5
+ "attention_probs_dropout_prob": 0.1,
6
+ "classifier_dropout": null,
7
+ "dtype": "float32",
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": 3,
19
+ "pad_token_id": 0,
20
+ "position_embedding_type": "absolute",
21
+ "transformers_version": "4.56.2",
22
+ "type_vocab_size": 2,
23
+ "use_cache": true,
24
+ "vocab_size": 30522
25
+ }
models/paraphrase-MiniLM-L3-v2/config_sentence_transformers.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "5.1.1",
4
+ "transformers": "4.56.2",
5
+ "pytorch": "2.8.0+cpu"
6
+ },
7
+ "model_type": "SentenceTransformer",
8
+ "prompts": {
9
+ "query": "",
10
+ "document": ""
11
+ },
12
+ "default_prompt_name": null,
13
+ "similarity_fn_name": "cosine"
14
+ }
models/paraphrase-MiniLM-L3-v2/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f59d73a201e0f6092d7e88ac8589f886a946725cff96d0250231d7e272e63071
3
+ size 69565312
models/paraphrase-MiniLM-L3-v2/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
+ ]
models/paraphrase-MiniLM-L3-v2/sentence_bert_config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "max_seq_length": 128,
3
+ "do_lower_case": false
4
+ }
models/paraphrase-MiniLM-L3-v2/special_tokens_map.json ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": {
3
+ "content": "[CLS]",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "mask_token": {
10
+ "content": "[MASK]",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": {
17
+ "content": "[PAD]",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ },
23
+ "sep_token": {
24
+ "content": "[SEP]",
25
+ "lstrip": false,
26
+ "normalized": false,
27
+ "rstrip": false,
28
+ "single_word": false
29
+ },
30
+ "unk_token": {
31
+ "content": "[UNK]",
32
+ "lstrip": false,
33
+ "normalized": false,
34
+ "rstrip": false,
35
+ "single_word": false
36
+ }
37
+ }
models/paraphrase-MiniLM-L3-v2/tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
models/paraphrase-MiniLM-L3-v2/tokenizer_config.json ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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": false,
45
+ "cls_token": "[CLS]",
46
+ "do_basic_tokenize": true,
47
+ "do_lower_case": true,
48
+ "extra_special_tokens": {},
49
+ "mask_token": "[MASK]",
50
+ "max_length": 128,
51
+ "model_max_length": 128,
52
+ "never_split": null,
53
+ "pad_to_multiple_of": null,
54
+ "pad_token": "[PAD]",
55
+ "pad_token_type_id": 0,
56
+ "padding_side": "right",
57
+ "sep_token": "[SEP]",
58
+ "stride": 0,
59
+ "strip_accents": null,
60
+ "tokenize_chinese_chars": true,
61
+ "tokenizer_class": "BertTokenizer",
62
+ "truncation_side": "right",
63
+ "truncation_strategy": "longest_first",
64
+ "unk_token": "[UNK]"
65
+ }
models/paraphrase-MiniLM-L3-v2/vocab.txt ADDED
The diff for this file is too large to render. See raw diff