rufimelo commited on
Commit
21db10e
1 Parent(s): 09fffa9

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +82 -45
README.md CHANGED
@@ -1,17 +1,48 @@
 
1
  ---
 
 
 
2
  pipeline_tag: sentence-similarity
3
  tags:
4
  - sentence-transformers
5
- - feature-extraction
6
  - sentence-similarity
7
  - transformers
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  ---
9
 
10
- # {MODEL_NAME}
11
 
12
  This is a [sentence-transformers](https://www.SBERT.net) model: It maps sentences & paragraphs to a 1024 dimensional dense vector space and can be used for tasks like clustering or semantic search.
13
-
14
- <!--- Describe your model here -->
15
 
16
  ## Usage (Sentence-Transformers)
17
 
@@ -25,9 +56,9 @@ Then you can use the model like this:
25
 
26
  ```python
27
  from sentence_transformers import SentenceTransformer
28
- sentences = ["This is an example sentence", "Each sentence is converted"]
29
 
30
- model = SentenceTransformer('{MODEL_NAME}')
31
  embeddings = model.encode(sentences)
32
  print(embeddings)
33
  ```
@@ -35,7 +66,7 @@ print(embeddings)
35
 
36
 
37
  ## Usage (HuggingFace Transformers)
38
- 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.
39
 
40
  ```python
41
  from transformers import AutoTokenizer, AutoModel
@@ -53,8 +84,8 @@ def mean_pooling(model_output, attention_mask):
53
  sentences = ['This is an example sentence', 'Each sentence is converted']
54
 
55
  # Load model from HuggingFace Hub
56
- tokenizer = AutoTokenizer.from_pretrained('{MODEL_NAME}')
57
- model = AutoModel.from_pretrained('{MODEL_NAME}')
58
 
59
  # Tokenize sentences
60
  encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')
@@ -71,55 +102,61 @@ print(sentence_embeddings)
71
  ```
72
 
73
 
74
-
75
- ## Evaluation Results
76
-
77
- <!--- Describe how your model was evaluated -->
78
-
79
- For an automated evaluation of this model, see the *Sentence Embeddings Benchmark*: [https://seb.sbert.net](https://seb.sbert.net?model_name={MODEL_NAME})
80
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
 
82
  ## Training
83
- The model was trained with the parameters:
84
 
85
- **DataLoader**:
86
 
87
- `torch.utils.data.dataloader.DataLoader` of length 2157 with parameters:
88
- ```
89
- {'batch_size': 8, 'sampler': 'torch.utils.data.sampler.RandomSampler', 'batch_sampler': 'torch.utils.data.sampler.BatchSampler'}
90
- ```
91
 
92
- **Loss**:
93
 
94
- `sentence_transformers.losses.CosineSimilarityLoss.CosineSimilarityLoss`
95
-
96
- Parameters of the fit()-Method:
97
- ```
98
- {
99
- "epochs": 5,
100
- "evaluation_steps": 0,
101
- "evaluator": "NoneType",
102
- "max_grad_norm": 1,
103
- "optimizer_class": "<class 'transformers.optimization.AdamW'>",
104
- "optimizer_params": {
105
- "lr": 1e-05
106
- },
107
- "scheduler": "WarmupLinear",
108
- "steps_per_epoch": null,
109
- "warmup_steps": 1079,
110
- "weight_decay": 0.01
111
- }
112
- ```
113
 
114
 
115
  ## Full Model Architecture
116
  ```
117
  SentenceTransformer(
118
- (0): Transformer({'max_seq_length': 512, 'do_lower_case': False}) with Transformer model: BertModel
119
- (1): Pooling({'word_embedding_dimension': 1024, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False})
120
  )
121
  ```
122
 
123
  ## Citing & Authors
124
 
125
- <!--- Describe where people can find more information -->
 
 
 
 
 
 
 
 
 
 
 
1
+
2
  ---
3
+ language:
4
+ - pt
5
+ thumbnail: "Portuguese BERT for the Legal Domain"
6
  pipeline_tag: sentence-similarity
7
  tags:
8
  - sentence-transformers
 
9
  - sentence-similarity
10
  - transformers
11
+ datasets:
12
+ - assin
13
+ - assin2
14
+ - stsb_multi_mt
15
+ - rufimelo/PortugueseLegalSentences-v2
16
+ widget:
17
+ - source_sentence: "O advogado apresentou as provas ao juíz."
18
+ sentences:
19
+ - "O juíz leu as provas."
20
+ - "O juíz leu o recurso."
21
+ - "O juíz atirou uma pedra."
22
+ example_title: "Example 1"
23
+ model-index:
24
+ - name: BERTimbau
25
+ results:
26
+ - task:
27
+ name: STS
28
+ type: STS
29
+ metrics:
30
+ - name: Pearson Correlation - assin Dataset
31
+ type: Pearson Correlation
32
+ value: xxxx
33
+ - name: Pearson Correlation - assin2 Dataset
34
+ type: Pearson Correlation
35
+ value: xxxxx
36
+ - name: Pearson Correlation - stsb_multi_mt pt Dataset
37
+ type: pearsonr
38
+ value: xxxxx
39
  ---
40
 
41
+ # rufimelo/Legal-BERTimbau-large-TSDAE-v4-GPL-sts
42
 
43
  This is a [sentence-transformers](https://www.SBERT.net) model: It maps sentences & paragraphs to a 1024 dimensional dense vector space and can be used for tasks like clustering or semantic search.
44
+ rufimelo/Legal-BERTimbau-large-TSDAE-v4-GPL-sts is based on Legal-BERTimbau-large which derives from [BERTimbau](https://huggingface.co/neuralmind/bert-large-portuguese-cased) large.
45
+ It is adapted to the Portuguese legal domain and trained for STS on portuguese datasets.
46
 
47
  ## Usage (Sentence-Transformers)
48
 
56
 
57
  ```python
58
  from sentence_transformers import SentenceTransformer
59
+ sentences = ["Isto é um exemplo", "Isto é um outro exemplo"]
60
 
61
+ model = SentenceTransformer('rufimelo/Legal-BERTimbau-large-TSDAE-v4-GPL-sts')
62
  embeddings = model.encode(sentences)
63
  print(embeddings)
64
  ```
66
 
67
 
68
  ## Usage (HuggingFace Transformers)
69
+
70
 
71
  ```python
72
  from transformers import AutoTokenizer, AutoModel
84
  sentences = ['This is an example sentence', 'Each sentence is converted']
85
 
86
  # Load model from HuggingFace Hub
87
+ tokenizer = AutoTokenizer.from_pretrained('rufimelo/Legal-BERTimbau-large-TSDAE-v4-GPL-sts')
88
+ model = AutoModel.from_pretrained('rufimelo/Legal-BERTimbau-large-TSDAE-v4-GPL-sts')
89
 
90
  # Tokenize sentences
91
  encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')
102
  ```
103
 
104
 
105
+ ## Evaluation Results STS
106
+
107
+ | Model| Assin | Assin2|stsb_multi_mt pt| avg|
108
+ | ---------------------------------------- | ---------- | ---------- |---------- |---------- |
109
+ | Legal-BERTimbau-sts-base| 0.71457| 0.73545 | 0.72383|0.72462|
110
+ | Legal-BERTimbau-sts-base-ma| 0.74874 | 0.79532|0.82254 |0.78886|
111
+ | Legal-BERTimbau-sts-base-ma-v2| 0.75481 | 0.80262|0.82178|0.79307|
112
+ | Legal-BERTimbau-base-TSDAE-sts|0.78814 |0.81380 |0.75777|0.78657|
113
+ | Legal-BERTimbau-sts-large| 0.76629| 0.82357 | 0.79120|0.79369|
114
+ | Legal-BERTimbau-sts-large-v2| 0.76299 | 0.81121|0.81726 |0.79715|
115
+ | Legal-BERTimbau-sts-large-ma| 0.76195| 0.81622 | 0.82608|0.80142|
116
+ | Legal-BERTimbau-sts-large-ma-v2| 0.7836| 0.8462| 0.8261| 0.81863|
117
+ | Legal-BERTimbau-sts-large-ma-v3| 0.7749| **0.8470**| 0.8364| **0.81943**|
118
+ | Legal-BERTimbau-large-v2-sts| 0.71665| 0.80106| 0.73724| 0.75165|
119
+ | Legal-BERTimbau-large-TSDAE-sts| 0.72376| 0.79261| 0.73635| 0.75090|
120
+ | Legal-BERTimbau-large-TSDAE-sts-v2| 0.81326| 0.83130| 0.786314| 0.81029|
121
+ | Legal-BERTimbau-large-TSDAE-sts-v3|0.80703 |0.82270 |0.77638 |0.80204 |
122
+ | ---------------------------------------- | ---------- |---------- |---------- |---------- |
123
+ | BERTimbau base Fine-tuned for STS|**0.78455** | 0.80626|0.82841|0.80640|
124
+ | BERTimbau large Fine-tuned for STS|0.78193 | 0.81758|0.83784|0.81245|
125
+ | ---------------------------------------- | ---------- |---------- |---------- |---------- |
126
+ | paraphrase-multilingual-mpnet-base-v2| 0.71457| 0.79831 |0.83999 |0.78429|
127
+ | paraphrase-multilingual-mpnet-base-v2 Fine-tuned with assin(s)| 0.77641|0.79831 |**0.84575**|0.80682|
128
 
129
  ## Training
 
130
 
131
+ rufimelo/Legal-BERTimbau-large-TSDAE-sts-v3 is based on rufimelo/Legal-BERTimbau-large-TSDAE-sts-v3 which derives from [BERTimbau](https://huggingface.co/neuralmind/bert-base-portuguese-cased) large.
132
 
133
+ rufimelo/Legal-BERTimbau-large-TSDAE-v4-GPL-sts was trained with TSDAE: 200000 cleaned documents (https://huggingface.co/datasets/rufimelo/PortugueseLegalSentences-v1)
134
+ 'lr': 1e-5
 
 
135
 
136
+ It was used GPL technique where batch = 4, epoch = 1, lr = 2e-5 and as to simulate the Cross-Encoder: rufimelo/Legal-BERTimbau-sts-large-v2 with dot product
137
 
138
+ It was trained for Semantic Textual Similarity, being submitted to a fine tuning stage with the [assin](https://huggingface.co/datasets/assin), [assin2](https://huggingface.co/datasets/assin2) and [stsb_multi_mt pt](https://huggingface.co/datasets/stsb_multi_mt) datasets. 'lr': 1e-5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
 
140
 
141
  ## Full Model Architecture
142
  ```
143
  SentenceTransformer(
144
+ (0): Transformer({'max_seq_length': 128, 'do_lower_case': False}) with Transformer model: BertModel
145
+ (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, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False})
146
  )
147
  ```
148
 
149
  ## Citing & Authors
150
 
151
+ If you use this work, please cite BERTimbau's work:
152
+
153
+ ```bibtex
154
+ @inproceedings{souza2020bertimbau,
155
+ author = {F{\'a}bio Souza and
156
+ Rodrigo Nogueira and
157
+ Roberto Lotufo},
158
+ title = {{BERT}imbau: pretrained {BERT} models for {B}razilian {P}ortuguese},
159
+ booktitle = {9th Brazilian Conference on Intelligent Systems, {BRACIS}, Rio Grande do Sul, Brazil, October 20-23 (to appear)},
160
+ year = {2020}
161
+ }
162
+ ```