kapllan commited on
Commit
4ec056b
1 Parent(s): a77347f

Added model card

Browse files
Files changed (1) hide show
  1. README.md +181 -0
README.md ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc
3
+ datasets:
4
+ - MultiLegalPile
5
+ - LEXTREME
6
+ - LEXGLUE
7
+ language:
8
+ - pt
9
+ tags:
10
+ - legal
11
+ ---
12
+
13
+ # Model Card for joelito/legal-portuguese-roberta-base
14
+
15
+ This model is a monolingual model pretrained on legal data. It is based on XLM-R ([base](https://huggingface.co/xlm-roberta-base) and [large](https://huggingface.co/xlm-roberta-large)). For pretraining we used the Portuguese portion of [Multi Legal Pile](https://huggingface.co/datasets/joelito/Multi_Legal_Pile) ([Niklaus et al. 2023](https://arxiv.org/abs/2306.02069?utm_source=tldrai)), a multilingual dataset from various legal sources covering 24 languages.
16
+
17
+ ## Model Details
18
+
19
+ ### Model Description
20
+
21
+ - **Developed by:** Joel Niklaus: [huggingface](https://huggingface.co/joelito); [email](mailto:joel.niklaus.2@bfh.ch)
22
+ - **Model type:** Transformer-based language model (RoBERTa)
23
+ - **Language(s) (NLP):** Portuguese
24
+ - **License:** CC BY-SA
25
+
26
+ ## Uses
27
+
28
+ ### Direct Use and Downstream Use
29
+
30
+ You can utilize the raw model for masked language modeling since we did not perform next sentence prediction. However, its main purpose is to be fine-tuned for downstream tasks.
31
+
32
+ It's important to note that this model is primarily designed for fine-tuning on tasks that rely on the entire sentence, potentially with masked elements, to make decisions. Examples of such tasks include sequence classification, token classification, or question answering. For text generation tasks, models like GPT-2 are more suitable.
33
+
34
+ Additionally, the model is specifically trained on legal data, aiming to deliver strong performance in that domain. Its performance may vary when applied to non-legal data.
35
+
36
+ ### Out-of-Scope Use
37
+
38
+ For tasks such as text generation you should look at model like GPT2.
39
+
40
+ The model should not be used to intentionally create hostile or alienating environments for people. The model was not trained to be factual or true representations of people or events, and therefore using the models to generate such content is out-of-scope for the abilities of this model.
41
+
42
+ ## Bias, Risks, and Limitations
43
+
44
+ Significant research has explored bias and fairness issues with language models (see, e.g., [Sheng et al. (2021)](https://aclanthology.org/2021.acl-long.330.pdf) and [Bender et al. (2021)](https://dl.acm.org/doi/pdf/10.1145/3442188.3445922)). Predictions generated by the model may include disturbing and harmful stereotypes across protected classes; identity characteristics; and sensitive, social, and occupational groups.
45
+
46
+ ### Recommendations
47
+
48
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.
49
+
50
+ ## How to Get Started with the Model
51
+
52
+ See [huggingface tutorials](https://huggingface.co/learn/nlp-course/chapter7/1?fw=pt). For masked word prediction see [this tutorial](https://huggingface.co/tasks/fill-mask).
53
+
54
+ ## Training Details
55
+
56
+ This model was pretrained on [Multi Legal Pile](https://huggingface.co/datasets/joelito/Multi_Legal_Pile) ([Niklaus et al. 2023](https://arxiv.org/abs/2306.02069?utm_source=tldrai)).
57
+
58
+ Our pretraining procedure includes the following key steps:
59
+
60
+ (a) Warm-starting: We initialize our models from the original XLM-R checkpoints ([base](https://huggingface.co/xlm-roberta-base) and [large](https://huggingface.co/xlm-roberta-large)) of [Conneau et al. (2019)](https://proceedings.neurips.cc/paper/2019/file/c04c19c2c2474dbf5f7ac4372c5b9af1-Paper.pdf) to benefit from a well-trained base.
61
+
62
+ (b) Tokenization: We train a new tokenizer of 128K BPEs to cover legal language better. However, we reuse the original XLM-R embeddings for lexically overlapping tokens and use random embeddings for the rest.
63
+
64
+ (c) Pretraining: We continue pretraining on Multi Legal Pile with batches of 512 samples for an additional 1M/500K steps for the base/large model. We use warm-up steps, a linearly increasing learning rate, and cosine decay scheduling. During the warm-up phase, only the embeddings are updated, and a higher masking rate and percentage of predictions based on masked tokens are used compared to [Devlin et al. (2019)](https://aclanthology.org/N19-1423).
65
+
66
+ (d) Sentence Sampling: We employ a sentence sampler with exponential smoothing to handle disparate token proportions across cantons and languages, preserving per-canton and language capacity.
67
+
68
+ (e) Mixed Cased Models: Our models cover both upper- and lowercase letters, similar to recently developed large PLMs.
69
+
70
+ ### Training Data
71
+
72
+ This model was pretrained on the Portuguese portion of [Multi Legal Pile](https://huggingface.co/datasets/joelito/Multi_Legal_Pile) ([Niklaus et al. 2023](https://arxiv.org/abs/2306.02069?utm_source=tldrai)).
73
+
74
+ #### Preprocessing
75
+
76
+ For further details see [Niklaus et al. 2023](https://arxiv.org/abs/2306.02069?utm_source=tldrai)
77
+
78
+ #### Training Hyperparameters
79
+
80
+ - batche size: 512 samples
81
+ - Number of steps: 1M/500K for the base/large model
82
+ - Warm-up steps for the first 5\% of the total training steps
83
+ - Learning rate: (linearly increasing up to) 1e-4
84
+ - Word masking: increased 20/30\% masking rate for base/large models respectively
85
+
86
+ ## Evaluation
87
+
88
+ For more detailed insights into the performance on downstream tasks, such as [LEXTREME](https://huggingface.co/datasets/joelito/lextreme) ([Niklaus et al. 2023](https://arxiv.org/abs/2301.13126)) or [LEXGLUE](https://huggingface.co/datasets/lex_glue) ([Chalkidis et al. 2021](https://arxiv.org/abs/2110.00976)), we refer to the results presented in Niklaus et al. (2023) [1](https://arxiv.org/abs/2306.02069), [2](https://arxiv.org/abs/2306.09237).
89
+
90
+ For further insights into the evaluation, we refer to the [trainer state](https://huggingface.co/joelito/legal-xlm-roberta-large/blob/main/last-checkpoint/trainer_state.json). Additional information is available in the [tensorboard](https://huggingface.co/joelito/legal-xlm-roberta-large/tensorboard).
91
+
92
+ ### Model Architecture and Objective
93
+
94
+ It is a RoBERTa-based model. Run the following code to view the architecture:
95
+
96
+ ```
97
+ from transformers import AutoModel
98
+ model = AutoModel.from_pretrained('joelito/legal-portuguese-roberta-base')
99
+ print(model)
100
+
101
+ RobertaModel(
102
+ (embeddings): RobertaEmbeddings(
103
+ (word_embeddings): Embedding(32000, 768, padding_idx=0)
104
+ (position_embeddings): Embedding(514, 768, padding_idx=0)
105
+ (token_type_embeddings): Embedding(1, 768)
106
+ (LayerNorm): LayerNorm((768,), eps=1e-05, elementwise_affine=True)
107
+ (dropout): Dropout(p=0.1, inplace=False)
108
+ )
109
+ (encoder): RobertaEncoder(
110
+ (layer): ModuleList(
111
+ (0-11): 12 x RobertaLayer(
112
+ (attention): RobertaAttention(
113
+ (self): RobertaSelfAttention(
114
+ (query): Linear(in_features=768, out_features=768, bias=True)
115
+ (key): Linear(in_features=768, out_features=768, bias=True)
116
+ (value): Linear(in_features=768, out_features=768, bias=True)
117
+ (dropout): Dropout(p=0.1, inplace=False)
118
+ )
119
+ (output): RobertaSelfOutput(
120
+ (dense): Linear(in_features=768, out_features=768, bias=True)
121
+ (LayerNorm): LayerNorm((768,), eps=1e-05, elementwise_affine=True)
122
+ (dropout): Dropout(p=0.1, inplace=False)
123
+ )
124
+ )
125
+ (intermediate): RobertaIntermediate(
126
+ (dense): Linear(in_features=768, out_features=3072, bias=True)
127
+ (intermediate_act_fn): GELUActivation()
128
+ )
129
+ (output): RobertaOutput(
130
+ (dense): Linear(in_features=3072, out_features=768, bias=True)
131
+ (LayerNorm): LayerNorm((768,), eps=1e-05, elementwise_affine=True)
132
+ (dropout): Dropout(p=0.1, inplace=False)
133
+ )
134
+ )
135
+ )
136
+ )
137
+ (pooler): RobertaPooler(
138
+ (dense): Linear(in_features=768, out_features=768, bias=True)
139
+ (activation): Tanh()
140
+ )
141
+ )
142
+
143
+ ```
144
+
145
+ ### Compute Infrastructure
146
+
147
+ Google TPU.
148
+
149
+ #### Hardware
150
+
151
+ Google TPU v3-8
152
+
153
+ #### Software
154
+
155
+ pytorch, transformers.
156
+
157
+ ## Citation
158
+
159
+ ```
160
+
161
+ @article{Niklaus2023MultiLegalPileA6,
162
+ title={MultiLegalPile: A 689GB Multilingual Legal Corpus},
163
+ author={Joel Niklaus and Veton Matoshi and Matthias Sturmer and Ilias Chalkidis and Daniel E. Ho},
164
+ journal={ArXiv},
165
+ year={2023},
166
+ volume={abs/2306.02069}
167
+ }
168
+
169
+ ```
170
+
171
+ ## Model Card Authors
172
+
173
+ Joel Niklaus: [huggingface](https://huggingface.co/joelito); [email](mailto:joel.niklaus.2@bfh.ch)
174
+
175
+ Veton Matoshi: [huggingface](https://huggingface.co/kapllan); [email](mailto:msv3@bfh.ch)
176
+
177
+ ## Model Card Contact
178
+
179
+ Joel Niklaus: [huggingface](https://huggingface.co/joelito); [email](mailto:joel.niklaus.2@bfh.ch)
180
+
181
+ Veton Matoshi: [huggingface](https://huggingface.co/kapllan); [email](mailto:msv3@bfh.ch)