rufimelo commited on
Commit
952df31
1 Parent(s): c5f7cc1

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +61 -46
README.md CHANGED
@@ -1,17 +1,33 @@
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 768 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 +41,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 +51,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 +69,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 +87,54 @@ 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 270 with parameters:
88
- ```
89
- {'batch_size': 64, '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": 2e-05
106
- },
107
- "scheduler": "WarmupLinear",
108
- "steps_per_epoch": null,
109
- "warmup_steps": 135,
110
- "weight_decay": 0.01
111
- }
112
- ```
113
 
114
 
115
  ## Full Model Architecture
116
  ```
117
  SentenceTransformer(
118
  (0): Transformer({'max_seq_length': 128, 'do_lower_case': False}) with Transformer model: BertModel
119
- (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})
120
  )
121
  ```
122
 
123
  ## Citing & Authors
124
 
125
- <!--- Describe where people can find more information -->
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ language:
3
+ - pt
4
+ thumbnail: "Portugues SBERT for the Legal Domain"
5
  pipeline_tag: sentence-similarity
6
  tags:
7
  - sentence-transformers
 
8
  - sentence-similarity
9
  - transformers
10
+ datasets:
11
+ - assin
12
+ - assin2
13
+ - stsb_multi_mt
14
+
15
+ widget:
16
+ - source_sentence: "O advogado apresentou as provas ao juíz."
17
+ sentences:
18
+ - "O juíz leu as provas."
19
+ - "O juíz leu o recurso."
20
+ - "O juíz atirou uma pedra."
21
+ example_title: "Example 1"
22
+ metrics:
23
+ - bleu
24
  ---
25
 
26
+ # rufimelo/Legal-SBERTimbau-sts-large-v2
27
 
28
+ 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.
29
+ rufimelo/rufimelo/Legal-SBERTimbau-sts-base-ma is based on Legal-BERTimbau-base which derives from [BERTimbau](https://huggingface.co/neuralmind/bert-large-portuguese-cased) alrge.
30
+ It is adapted to the Portuguese legal domain and trained for STS on portuguese datasets.
31
 
32
  ## Usage (Sentence-Transformers)
33
 
 
41
 
42
  ```python
43
  from sentence_transformers import SentenceTransformer
44
+ sentences = ["Isto é um exemplo", "Isto é um outro exemplo"]
45
 
46
+ model = SentenceTransformer('rufimelo/Legal-SBERTimbau-sts-base-ma')
47
  embeddings = model.encode(sentences)
48
  print(embeddings)
49
  ```
 
51
 
52
 
53
  ## Usage (HuggingFace Transformers)
54
+
55
 
56
  ```python
57
  from transformers import AutoTokenizer, AutoModel
 
69
  sentences = ['This is an example sentence', 'Each sentence is converted']
70
 
71
  # Load model from HuggingFace Hub
72
+ tokenizer = AutoTokenizer.from_pretrained('rufimelo/Legal-SBERTimbau-sts-large-v2')
73
+ model = AutoModel.from_pretrained('rufimelo/Legal-SBERTimbau-sts-base-ma')
74
 
75
  # Tokenize sentences
76
  encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')
 
87
  ```
88
 
89
 
90
+ ## Evaluation Results STS
91
+
92
+ | Model| Dataset | PearsonCorrelation |
93
+ | ---------------------------------------- | ---------- | ---------- |
94
+ | Legal-SBERTimbau-sts-large| Assin | 0.76629 |
95
+ | Legal-SBERTimbau-sts-large| Assin2| 0.82357 |
96
+ | Legal-SBERTimbau-sts-base| Assin | 0.71457 |
97
+ | Legal-SBERTimbau-sts-base| Assin2| 0.73545|
98
+ | Legal-SBERTimbau-sts-large-v2| Assin | 0.76299 |
99
+ | Legal-SBERTimbau-sts-large-v2| Assin2| 0.81121 |
100
+ | Legal-SBERTimbau-sts-large-v2| stsb_multi_mt pt| 0.81726 |
101
+ | ---------------------------------------- | ---------- |---------- |
102
+ | paraphrase-multilingual-mpnet-base-v2| Assin | 0.71457|
103
+ | paraphrase-multilingual-mpnet-base-v2| Assin2| 0.79831 |
104
+ | paraphrase-multilingual-mpnet-base-v2| stsb_multi_mt pt| 0.83999 |
105
+ | paraphrase-multilingual-mpnet-base-v2 Fine tuned with assin(s)| Assin | 0.77641 |
106
+ | paraphrase-multilingual-mpnet-base-v2 Fine tuned with assin(s)| Assin2| 0.79831 |
107
+ | paraphrase-multilingual-mpnet-base-v2 Fine tuned with assin(s)| stsb_multi_mt pt| 0.84575 |
108
 
109
  ## Training
 
110
 
111
+ rufimelo/Legal-SBERTimbau-sts-base-ma is based on Legal-BERTimbau-base which derives from [BERTimbau](https://huggingface.co/neuralmind/bert-base-portuguese-cased) base.
112
 
113
+ Firstly, due to the lack of portuguese datasets, it was trained using multilingual knowledge distillation.
114
+ For the Multilingual Knowledge Distillation process, the teacher model was 'sentence-transformers/paraphrase-xlm-r-multilingual-v1', the supposed supported language as English and the language to learn was portuguese.
 
 
115
 
116
+ 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.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
 
118
 
119
  ## Full Model Architecture
120
  ```
121
  SentenceTransformer(
122
  (0): Transformer({'max_seq_length': 128, 'do_lower_case': False}) with Transformer model: BertModel
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, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False})
124
  )
125
  ```
126
 
127
  ## Citing & Authors
128
 
129
+ If you use this work, please cite BERTimbau's work:
130
+
131
+ ```bibtex
132
+ @inproceedings{souza2020bertimbau,
133
+ author = {F{\'a}bio Souza and
134
+ Rodrigo Nogueira and
135
+ Roberto Lotufo},
136
+ title = {{BERT}imbau: pretrained {BERT} models for {B}razilian {P}ortuguese},
137
+ booktitle = {9th Brazilian Conference on Intelligent Systems, {BRACIS}, Rio Grande do Sul, Brazil, October 20-23 (to appear)},
138
+ year = {2020}
139
+ }
140
+ ```