rufimelo commited on
Commit
37ae048
1 Parent(s): f3d5311

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +56 -49
README.md CHANGED
@@ -1,17 +1,32 @@
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 +40,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 +50,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 +68,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 +86,47 @@ 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 204 with parameters:
88
- ```
89
- {'batch_size': 32, 'sampler': 'torch.utils.data.sampler.SequentialSampler', '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": 1,
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": 20.400000000000002,
110
- "weight_decay": 0.01
111
- }
112
- ```
113
 
 
 
 
114
 
115
  ## Full Model Architecture
116
  ```
117
  SentenceTransformer(
118
- (0): Transformer({'max_seq_length': 256, '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
+
14
+ widget:
15
+ - source_sentence: "O advogado apresentou as provas ao juíz."
16
+ sentences:
17
+ - "O juíz leu as provas."
18
+ - "O juíz leu o recurso."
19
+ - "O juíz atirou uma pedra."
20
+ example_title: "Example 1"
21
+ metrics:
22
+ - bleu
23
  ---
24
 
25
+ # rufimelo/Legal-SBERTimbau-nli-base
26
 
27
+ 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.
28
+ Legal-SBERTimbau-base is based on Legal-BERTimbau-base which derives from [BERTimbau](https://huggingface.co/neuralmind/bert-base-portuguese-cased) Large.
29
+ It is adapted to the Portuguese legal domain.
30
 
31
  ## Usage (Sentence-Transformers)
32
 
 
40
 
41
  ```python
42
  from sentence_transformers import SentenceTransformer
43
+ sentences = ["Isto é um exemplo", "Isto é um outro exemplo"]
44
 
45
+ model = SentenceTransformer('rufimelo/Legal-SBERTimbau-nli-base')
46
  embeddings = model.encode(sentences)
47
  print(embeddings)
48
  ```
 
50
 
51
 
52
  ## Usage (HuggingFace Transformers)
53
+
54
 
55
  ```python
56
  from transformers import AutoTokenizer, AutoModel
 
68
  sentences = ['This is an example sentence', 'Each sentence is converted']
69
 
70
  # Load model from HuggingFace Hub
71
+ tokenizer = AutoTokenizer.from_pretrained('rufimelo/Legal-SBERTimbau-nli-base')
72
+ model = AutoModel.from_pretrained('rufimelo/Legal-SBERTimbau-nli-base}')
73
 
74
  # Tokenize sentences
75
  encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')
 
86
  ```
87
 
88
 
89
+ ## Evaluation Results STS
90
 
91
+ | Model| Dataset | PearsonCorrelation |
92
+ | ---------------------------------------- | ---------- | ---------- |
93
+ | Legal-SBERTimbau-large| Assin | 0.766293861 |
94
+ | Legal-SBERTimbau-large| Assin2| 0.823565322 |
95
+ | Legal-SBERTimbau-base| Assin | 0.71457 |
96
+ | Legal-SBERTimbau-base| Assin2| 0.73545|
97
+ | ---------------------------------------- | ---------- |---------- |
98
+ | paraphrase-multilingual-mpnet-base-v2| Assin | 0.7145698631948073 |
99
+ | paraphrase-multilingual-mpnet-base-v2| Assin2| 0.79831 |
100
+ | paraphrase-multilingual-mpnet-base-v2| stsb_multi_mt pt| 0.83999 |
101
+ | paraphrase-multilingual-mpnet-base-v2 Fine tuned with assin(s)| Assin | 0.77641 |
102
+ | paraphrase-multilingual-mpnet-base-v2 Fine tuned with assin(s)| Assin2| 0.79831 |
103
+ | paraphrase-multilingual-mpnet-base-v2 Fine tuned with assin(s)| stsb_multi_mt pt| 0.84575 |
104
 
105
  ## Training
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
 
107
+ Legal-SBERTimbau-base is based on Legal-BERTimbau-base which derives from [BERTimbau](https://huggingface.co/neuralmind/bert-base-portuguese-cased) Large.
108
+ It was trained for Natural Language Inference (NLI). This was chosen due to the lack of Portuguese available data.
109
+ In addition to that, it was submitted to a fine tuning stage with the [assin](https://huggingface.co/datasets/assin) and [assin2](https://huggingface.co/datasets/assin2) datasets.
110
 
111
  ## Full Model Architecture
112
  ```
113
  SentenceTransformer(
114
+ (0): Transformer({'max_seq_length': 75, 'do_lower_case': False}) with Transformer model: BertModel
115
+ (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, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False})
116
  )
117
  ```
118
 
119
  ## Citing & Authors
120
 
121
+ If you use this work, please cite BERTimbau's work:
122
+
123
+ ```bibtex
124
+ @inproceedings{souza2020bertimbau,
125
+ author = {F{\'a}bio Souza and
126
+ Rodrigo Nogueira and
127
+ Roberto Lotufo},
128
+ title = {{BERT}imbau: pretrained {BERT} models for {B}razilian {P}ortuguese},
129
+ booktitle = {9th Brazilian Conference on Intelligent Systems, {BRACIS}, Rio Grande do Sul, Brazil, October 20-23 (to appear)},
130
+ year = {2020}
131
+ }
132
+ ```