Thacio Garcia Scandaroli commited on
Commit
fc5fc1f
·
1 Parent(s): b97b8f4

Upload 13 files

Browse files
1_Pooling/config.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "word_embedding_dimension": 512,
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,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 512 dimensional dense vector space and can be used for tasks like clustering or semantic search.*
14
+
15
+ Este modelo é do tipo [sentence-transformers](https://www.SBERT.net) baseado no modelo [thacio/ult5-pt-small](https://huggingface.co/thacio/ult5-pt-small). Ele mapeia sentenças e parágrafos para vetores denso de dimensão 512, e pode ser utilizado para clustering, similaridades entre textos um busca semântica.
16
+
17
+ | Model | Parameters |
18
+ | :-: | :-: |
19
+ | [thacio/ult5-pt-small](https://huggingface.co/thacio/ult5-pt-small) | 82.4M |
20
+ | [thacio/ult5-pt-small](https://huggingface.co/thacio/ult5-pt-small) | 82.4M |
21
+
22
+ ## Use cases
23
+
24
+ Os modelos [sentence-transformers](https://www.SBERT.net) geram *embeddings* do texto de melhor qualidade do que utilizar embeddings diretamente de encoders como BERT ou T5.
25
+
26
+ Possíveis aplicações para o modelo são:
27
+ *Possible use cases*:
28
+ - [Clustering](https://www.sbert.net/examples/applications/clustering/README.html)
29
+ - [Semantic Textual Similarity](https://www.sbert.net/docs/usage/semantic_textual_similarity.html)
30
+ - [Semantic Search](https://www.sbert.net/examples/applications/semantic-search/README.html)
31
+ - [Retrieve & Re-Rank](https://www.sbert.net/examples/applications/retrieve_rerank/README.html)
32
+ - [Paraphrase Mining](https://www.sbert.net/examples/applications/paraphrase-mining/README.html)
33
+
34
+ ## Usage (Sentence-Transformers)
35
+
36
+ O modo mais simples de uso é utilizar a biblioteca [sentence-transformers](https://www.SBERT.net):
37
+
38
+ *Using this model becomes easy when you have [sentence-transformers](https://www.SBERT.net) installed:*
39
+
40
+ ```
41
+ pip install -U sentence-transformers
42
+ ```
43
+
44
+ Para obter o embeddings:
45
+
46
+ *Then you can use the model like this:*
47
+
48
+ ```python
49
+ from sentence_transformers import SentenceTransformer
50
+ sentences = ["Este é um exemplo de sentença", "A sentença é convertida em um texto de dimensão 513"]
51
+
52
+ model = SentenceTransformer('{MODEL_NAME}')
53
+ embeddings = model.encode(sentences)
54
+ print(embeddings)
55
+ ```
56
+
57
+ ## Usage (HuggingFace Transformers)
58
+
59
+ É possível utilizar o modelo apenas com a biblioteca transfomers: Primeiro, passa-se o texto pelo modelo, e em seguida se aplica a operação de *right pooling* aos embeddings contextuais do texto.
60
+
61
+ *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.*
62
+
63
+ ```python
64
+ from transformers import AutoTokenizer, AutoModel
65
+ import torch
66
+
67
+
68
+ #Mean Pooling - Take attention mask into account for correct averaging
69
+ def mean_pooling(model_output, attention_mask):
70
+ token_embeddings = model_output[0] #First element of model_output contains all token embeddings
71
+ input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float()
72
+ return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(input_mask_expanded.sum(1), min=1e-9)
73
+
74
+
75
+ # Sentences we want sentence embeddings for
76
+ sentences = ['This is an example sentence', 'Each sentence is converted']
77
+
78
+ # Load model from HuggingFace Hub
79
+ tokenizer = AutoTokenizer.from_pretrained('{MODEL_NAME}')
80
+ model = AutoModel.from_pretrained('{MODEL_NAME}')
81
+
82
+ # Tokenize sentences
83
+ encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')
84
+
85
+ # Compute token embeddings
86
+ with torch.no_grad():
87
+ model_output = model(**encoded_input)
88
+
89
+ # Perform pooling. In this case, mean pooling.
90
+ sentence_embeddings = mean_pooling(model_output, encoded_input['attention_mask'])
91
+
92
+ print("Sentence embeddings:")
93
+ print(sentence_embeddings)
94
+ ```
95
+
96
+
97
+ # Full Model Architecture
98
+ ```
99
+ SentenceTransformerGradAcum(
100
+ (0): Transformer({'max_seq_length': 1024, 'do_lower_case': False}) with Transformer model: T5EncoderModel
101
+ (1): Pooling({'word_embedding_dimension': 512, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False})
102
+ )
103
+ ```
104
+
105
+ ## Citation
106
+
107
+ ```bibtex
108
+ @misc{ult5-pt2023,
109
+ author = {Thacio Garcia Scandaroli},
110
+ title = {ULT5-pt: Portuguese Language Model trained with UL2},
111
+ year = {2023},
112
+ }
113
+ ```
added_tokens.json ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "<|NLG|>": 50260,
3
+ "<|NLU|>": 50259,
4
+ "<|beginoftext|>": 50257,
5
+ "<|extra_id_0|>": 50261,
6
+ "<|extra_id_10|>": 50271,
7
+ "<|extra_id_11|>": 50272,
8
+ "<|extra_id_12|>": 50273,
9
+ "<|extra_id_13|>": 50274,
10
+ "<|extra_id_14|>": 50275,
11
+ "<|extra_id_15|>": 50276,
12
+ "<|extra_id_16|>": 50277,
13
+ "<|extra_id_17|>": 50278,
14
+ "<|extra_id_18|>": 50279,
15
+ "<|extra_id_19|>": 50280,
16
+ "<|extra_id_1|>": 50262,
17
+ "<|extra_id_20|>": 50281,
18
+ "<|extra_id_21|>": 50282,
19
+ "<|extra_id_22|>": 50283,
20
+ "<|extra_id_23|>": 50284,
21
+ "<|extra_id_24|>": 50285,
22
+ "<|extra_id_25|>": 50286,
23
+ "<|extra_id_26|>": 50287,
24
+ "<|extra_id_27|>": 50288,
25
+ "<|extra_id_28|>": 50289,
26
+ "<|extra_id_29|>": 50290,
27
+ "<|extra_id_2|>": 50263,
28
+ "<|extra_id_30|>": 50291,
29
+ "<|extra_id_31|>": 50292,
30
+ "<|extra_id_32|>": 50293,
31
+ "<|extra_id_33|>": 50294,
32
+ "<|extra_id_34|>": 50295,
33
+ "<|extra_id_35|>": 50296,
34
+ "<|extra_id_36|>": 50297,
35
+ "<|extra_id_37|>": 50298,
36
+ "<|extra_id_38|>": 50299,
37
+ "<|extra_id_39|>": 50300,
38
+ "<|extra_id_3|>": 50264,
39
+ "<|extra_id_40|>": 50301,
40
+ "<|extra_id_41|>": 50302,
41
+ "<|extra_id_42|>": 50303,
42
+ "<|extra_id_43|>": 50304,
43
+ "<|extra_id_44|>": 50305,
44
+ "<|extra_id_45|>": 50306,
45
+ "<|extra_id_46|>": 50307,
46
+ "<|extra_id_47|>": 50308,
47
+ "<|extra_id_48|>": 50309,
48
+ "<|extra_id_49|>": 50310,
49
+ "<|extra_id_4|>": 50265,
50
+ "<|extra_id_50|>": 50311,
51
+ "<|extra_id_51|>": 50312,
52
+ "<|extra_id_52|>": 50313,
53
+ "<|extra_id_53|>": 50314,
54
+ "<|extra_id_54|>": 50315,
55
+ "<|extra_id_55|>": 50316,
56
+ "<|extra_id_56|>": 50317,
57
+ "<|extra_id_57|>": 50318,
58
+ "<|extra_id_58|>": 50319,
59
+ "<|extra_id_59|>": 50320,
60
+ "<|extra_id_5|>": 50266,
61
+ "<|extra_id_60|>": 50321,
62
+ "<|extra_id_61|>": 50322,
63
+ "<|extra_id_62|>": 50323,
64
+ "<|extra_id_63|>": 50324,
65
+ "<|extra_id_64|>": 50325,
66
+ "<|extra_id_65|>": 50326,
67
+ "<|extra_id_66|>": 50327,
68
+ "<|extra_id_67|>": 50328,
69
+ "<|extra_id_68|>": 50329,
70
+ "<|extra_id_69|>": 50330,
71
+ "<|extra_id_6|>": 50267,
72
+ "<|extra_id_70|>": 50331,
73
+ "<|extra_id_71|>": 50332,
74
+ "<|extra_id_72|>": 50333,
75
+ "<|extra_id_73|>": 50334,
76
+ "<|extra_id_74|>": 50335,
77
+ "<|extra_id_75|>": 50336,
78
+ "<|extra_id_76|>": 50337,
79
+ "<|extra_id_77|>": 50338,
80
+ "<|extra_id_78|>": 50339,
81
+ "<|extra_id_79|>": 50340,
82
+ "<|extra_id_7|>": 50268,
83
+ "<|extra_id_80|>": 50341,
84
+ "<|extra_id_81|>": 50342,
85
+ "<|extra_id_82|>": 50343,
86
+ "<|extra_id_83|>": 50344,
87
+ "<|extra_id_84|>": 50345,
88
+ "<|extra_id_85|>": 50346,
89
+ "<|extra_id_86|>": 50347,
90
+ "<|extra_id_87|>": 50348,
91
+ "<|extra_id_88|>": 50349,
92
+ "<|extra_id_89|>": 50350,
93
+ "<|extra_id_8|>": 50269,
94
+ "<|extra_id_90|>": 50351,
95
+ "<|extra_id_91|>": 50352,
96
+ "<|extra_id_92|>": 50353,
97
+ "<|extra_id_93|>": 50354,
98
+ "<|extra_id_94|>": 50355,
99
+ "<|extra_id_95|>": 50356,
100
+ "<|extra_id_96|>": 50357,
101
+ "<|extra_id_97|>": 50358,
102
+ "<|extra_id_98|>": 50359,
103
+ "<|extra_id_99|>": 50360,
104
+ "<|extra_id_9|>": 50270,
105
+ "<|unk|>": 50258
106
+ }
config.json ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "thacio/ult5-pt-small",
3
+ "architectures": [
4
+ "T5EncoderModel"
5
+ ],
6
+ "bos_token_id": 50257,
7
+ "d_ff": 2048,
8
+ "d_kv": 64,
9
+ "d_model": 512,
10
+ "decoder_start_token_id": 0,
11
+ "dense_act_fn": "silu",
12
+ "dropout": 0.1,
13
+ "dropout_rate": 0.1,
14
+ "eos_token_id": 1,
15
+ "feed_forward_proj": "gated-silu",
16
+ "initializer_factor": 1.0,
17
+ "is_encoder_decoder": true,
18
+ "is_gated_act": true,
19
+ "layer_norm_epsilon": 1e-06,
20
+ "model_type": "t5",
21
+ "n_positions": 1024,
22
+ "num_decoder_layers": 6,
23
+ "num_heads": 8,
24
+ "num_layers": 6,
25
+ "output_past": true,
26
+ "pad_token_id": 0,
27
+ "relative_attention_max_distance": 128,
28
+ "relative_attention_num_buckets": 32,
29
+ "task_specific_params": {
30
+ "text-generation": {
31
+ "do_sample": true,
32
+ "max_length": 50
33
+ }
34
+ },
35
+ "torch_dtype": "float32",
36
+ "transformers_version": "4.28.0",
37
+ "use_cache": true,
38
+ "vocab_size": 50361
39
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "2.2.2",
4
+ "transformers": "4.28.0",
5
+ "pytorch": "2.0.0+cu118"
6
+ }
7
+ }
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
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:b46053a77b6d5151882139ba207c688225828439beadfc5182e700d1a4010e3d
3
+ size 203849692
sentence_bert_config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "max_seq_length": 1024,
3
+ "do_lower_case": false
4
+ }
special_tokens_map.json ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<|NLU|>",
4
+ "<|NLG|>",
5
+ "<|extra_id_0|>",
6
+ "<|extra_id_1|>",
7
+ "<|extra_id_2|>",
8
+ "<|extra_id_3|>",
9
+ "<|extra_id_4|>",
10
+ "<|extra_id_5|>",
11
+ "<|extra_id_6|>",
12
+ "<|extra_id_7|>",
13
+ "<|extra_id_8|>",
14
+ "<|extra_id_9|>",
15
+ "<|extra_id_10|>",
16
+ "<|extra_id_11|>",
17
+ "<|extra_id_12|>",
18
+ "<|extra_id_13|>",
19
+ "<|extra_id_14|>",
20
+ "<|extra_id_15|>",
21
+ "<|extra_id_16|>",
22
+ "<|extra_id_17|>",
23
+ "<|extra_id_18|>",
24
+ "<|extra_id_19|>",
25
+ "<|extra_id_20|>",
26
+ "<|extra_id_21|>",
27
+ "<|extra_id_22|>",
28
+ "<|extra_id_23|>",
29
+ "<|extra_id_24|>",
30
+ "<|extra_id_25|>",
31
+ "<|extra_id_26|>",
32
+ "<|extra_id_27|>",
33
+ "<|extra_id_28|>",
34
+ "<|extra_id_29|>",
35
+ "<|extra_id_30|>",
36
+ "<|extra_id_31|>",
37
+ "<|extra_id_32|>",
38
+ "<|extra_id_33|>",
39
+ "<|extra_id_34|>",
40
+ "<|extra_id_35|>",
41
+ "<|extra_id_36|>",
42
+ "<|extra_id_37|>",
43
+ "<|extra_id_38|>",
44
+ "<|extra_id_39|>",
45
+ "<|extra_id_40|>",
46
+ "<|extra_id_41|>",
47
+ "<|extra_id_42|>",
48
+ "<|extra_id_43|>",
49
+ "<|extra_id_44|>",
50
+ "<|extra_id_45|>",
51
+ "<|extra_id_46|>",
52
+ "<|extra_id_47|>",
53
+ "<|extra_id_48|>",
54
+ "<|extra_id_49|>",
55
+ "<|extra_id_50|>",
56
+ "<|extra_id_51|>",
57
+ "<|extra_id_52|>",
58
+ "<|extra_id_53|>",
59
+ "<|extra_id_54|>",
60
+ "<|extra_id_55|>",
61
+ "<|extra_id_56|>",
62
+ "<|extra_id_57|>",
63
+ "<|extra_id_58|>",
64
+ "<|extra_id_59|>",
65
+ "<|extra_id_60|>",
66
+ "<|extra_id_61|>",
67
+ "<|extra_id_62|>",
68
+ "<|extra_id_63|>",
69
+ "<|extra_id_64|>",
70
+ "<|extra_id_65|>",
71
+ "<|extra_id_66|>",
72
+ "<|extra_id_67|>",
73
+ "<|extra_id_68|>",
74
+ "<|extra_id_69|>",
75
+ "<|extra_id_70|>",
76
+ "<|extra_id_71|>",
77
+ "<|extra_id_72|>",
78
+ "<|extra_id_73|>",
79
+ "<|extra_id_74|>",
80
+ "<|extra_id_75|>",
81
+ "<|extra_id_76|>",
82
+ "<|extra_id_77|>",
83
+ "<|extra_id_78|>",
84
+ "<|extra_id_79|>",
85
+ "<|extra_id_80|>",
86
+ "<|extra_id_81|>",
87
+ "<|extra_id_82|>",
88
+ "<|extra_id_83|>",
89
+ "<|extra_id_84|>",
90
+ "<|extra_id_85|>",
91
+ "<|extra_id_86|>",
92
+ "<|extra_id_87|>",
93
+ "<|extra_id_88|>",
94
+ "<|extra_id_89|>",
95
+ "<|extra_id_90|>",
96
+ "<|extra_id_91|>",
97
+ "<|extra_id_92|>",
98
+ "<|extra_id_93|>",
99
+ "<|extra_id_94|>",
100
+ "<|extra_id_95|>",
101
+ "<|extra_id_96|>",
102
+ "<|extra_id_97|>",
103
+ "<|extra_id_98|>",
104
+ "<|extra_id_99|>"
105
+ ],
106
+ "bos_token": "<|beginoftext|>",
107
+ "eos_token": "<|endoftext|>",
108
+ "pad_token": "<|pad|>",
109
+ "unk_token": "<|unk|>"
110
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "additional_special_tokens": [
4
+ "<|pad|>",
5
+ "<|endoftext|>"
6
+ ],
7
+ "bos_token": "<|pad|>",
8
+ "clean_up_tokenization_spaces": true,
9
+ "eos_token": "<|pad|>",
10
+ "model_max_length": 1024,
11
+ "tokenizer_class": "GPT2Tokenizer",
12
+ "unk_token": "<|pad|>"
13
+ }
vocab.json ADDED
The diff for this file is too large to render. See raw diff