kapllan commited on
Commit
8c3a9c6
1 Parent(s): 47048d0

Created a model card

Browse files
Files changed (1) hide show
  1. README.md +201 -0
README.md ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc
3
+ language:
4
+ - multilingual
5
+ - bg
6
+ - cs
7
+ - da
8
+ - de
9
+ - el
10
+ - en
11
+ - es
12
+ - et
13
+ - fi
14
+ - fr
15
+ - ga
16
+ - hr
17
+ - hu
18
+ - it
19
+ - lt
20
+ - lv
21
+ - mt
22
+ - nl
23
+ - pl
24
+ - pt
25
+ - ro
26
+ - sk
27
+ - sl
28
+ - sv
29
+ tags:
30
+ - multilingual
31
+ ---
32
+ # Model Card for joelito/legal-swiss-roberta-base
33
+
34
+ This model is a multilingual 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 [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.
35
+
36
+ ## Model Details
37
+
38
+ ### Model Description
39
+
40
+ - **Developed by:** Joel Niklaus: [huggingface](https://huggingface.co/joelito); [email](mailto:joel.niklaus.2@bfh.ch)
41
+ - **Model type:** Transformer-based language model (RoBERTa)
42
+ - **Language(s) (NLP):** bg, cs, da, de, el, en, es, et, fi, fr, ga, hr, hu, it, lt, lv, mt, nl, pl, pt, ro, sk, sl, sv
43
+ - **License:** CC BY-SA
44
+
45
+ ## Uses
46
+
47
+ ### Direct Use and Downstream Use
48
+
49
+ 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.
50
+
51
+ 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.
52
+
53
+ 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.
54
+
55
+ ### Out-of-Scope Use
56
+
57
+ For tasks such as text generation you should look at model like GPT2.
58
+
59
+ 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.
60
+
61
+ ## Bias, Risks, and Limitations
62
+
63
+ 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.
64
+
65
+ ### Recommendations
66
+
67
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.
68
+
69
+ ## How to Get Started with the Model
70
+
71
+ 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).
72
+
73
+ ## Training Details
74
+
75
+ 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)).
76
+
77
+ Our pretraining procedure includes the following key steps:
78
+
79
+ (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.
80
+
81
+ (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.
82
+
83
+ (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).
84
+
85
+ (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.
86
+
87
+ (e) Mixed Cased Models: Our models cover both upper- and lowercase letters, similar to recently developed large PLMs.
88
+
89
+ (f) Long Context Training: To account for long contexts in legal documents, we train the base-size multilingual model on long contexts with windowed attention. This variant, named Legal-Swiss-LF-base, uses a 15% masking probability, increased learning rate, and similar settings to small-context models.
90
+
91
+ ### Training Data
92
+
93
+ 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)).
94
+
95
+ #### Preprocessing
96
+
97
+ For further details see [Niklaus et al. 2023](https://arxiv.org/abs/2306.02069?utm_source=tldrai)
98
+
99
+ #### Training Hyperparameters
100
+
101
+ - batche size: 512 samples
102
+ - Number of steps: 1M/500K for the base/large model
103
+ - Warm-up steps for the first 5\% of the total training steps
104
+ - Learning rate: (linearly increasing up to) $1e\!-\!4$
105
+ - Word masking: increased 20/30\% masking rate for base/large models respectively
106
+
107
+ ## Evaluation
108
+
109
+ For further insights into the evaluation, we refer to the [trainer state](https://huggingface.co/joelito/legal-swiss-roberta-base/blob/main/last-checkpoint/trainer_state.json). Additional information is available in the [tensorboard](https://huggingface.co/joelito/legal-swiss-roberta-base/tensorboard).
110
+
111
+ For 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).
112
+
113
+ ### Model Architecture and Objective
114
+
115
+ It is a RoBERTa-based model. Run the following code to view the architecture:
116
+
117
+ ```
118
+ from transformers import AutoModel
119
+ model = AutoModel.from_pretrained('joelito/legal-swiss-roberta-base')
120
+ print(model)
121
+
122
+ RobertaModel(
123
+ (embeddings): RobertaEmbeddings(
124
+ (word_embeddings): Embedding(128000, 768, padding_idx=0)
125
+ (position_embeddings): Embedding(514, 768, padding_idx=0)
126
+ (token_type_embeddings): Embedding(1, 768)
127
+ (LayerNorm): LayerNorm((768,), eps=1e-05, elementwise_affine=True)
128
+ (dropout): Dropout(p=0.1, inplace=False)
129
+ )
130
+ (encoder): RobertaEncoder(
131
+ (layer): ModuleList(
132
+ (0-11): 12 x RobertaLayer(
133
+ (attention): RobertaAttention(
134
+ (self): RobertaSelfAttention(
135
+ (query): Linear(in_features=768, out_features=768, bias=True)
136
+ (key): Linear(in_features=768, out_features=768, bias=True)
137
+ (value): Linear(in_features=768, out_features=768, bias=True)
138
+ (dropout): Dropout(p=0.1, inplace=False)
139
+ )
140
+ (output): RobertaSelfOutput(
141
+ (dense): Linear(in_features=768, out_features=768, bias=True)
142
+ (LayerNorm): LayerNorm((768,), eps=1e-05, elementwise_affine=True)
143
+ (dropout): Dropout(p=0.1, inplace=False)
144
+ )
145
+ )
146
+ (intermediate): RobertaIntermediate(
147
+ (dense): Linear(in_features=768, out_features=3072, bias=True)
148
+ (intermediate_act_fn): GELUActivation()
149
+ )
150
+ (output): RobertaOutput(
151
+ (dense): Linear(in_features=3072, out_features=768, bias=True)
152
+ (LayerNorm): LayerNorm((768,), eps=1e-05, elementwise_affine=True)
153
+ (dropout): Dropout(p=0.1, inplace=False)
154
+ )
155
+ )
156
+ )
157
+ )
158
+ (pooler): RobertaPooler(
159
+ (dense): Linear(in_features=768, out_features=768, bias=True)
160
+ (activation): Tanh()
161
+ )
162
+ )
163
+ ```
164
+
165
+ ### Compute Infrastructure
166
+
167
+ Google TPU.
168
+
169
+ #### Hardware
170
+
171
+ Google TPU v3-8
172
+
173
+ #### Software
174
+
175
+ pytorch, transformers.
176
+
177
+ ## Citation [optional]
178
+
179
+ ```
180
+
181
+ @article{Niklaus2023MultiLegalPileA6,
182
+ title={MultiLegalPile: A 689GB Multilingual Legal Corpus},
183
+ author={Joel Niklaus and Veton Matoshi and Matthias Sturmer and Ilias Chalkidis and Daniel E. Ho},
184
+ journal={ArXiv},
185
+ year={2023},
186
+ volume={abs/2306.02069}
187
+ }
188
+
189
+ ```
190
+
191
+ ## Model Card Authors
192
+
193
+ Joel Niklaus: [huggingface](https://huggingface.co/joelito); [email](mailto:joel.niklaus.2@bfh.ch)
194
+
195
+ Veton Matoshi: [huggingface](https://huggingface.co/kapllan); [email](mailto:msv3@bfh.ch)
196
+
197
+ ## Model Card Contact
198
+
199
+ Joel Niklaus: [huggingface](https://huggingface.co/joelito); [email](mailto:joel.niklaus.2@bfh.ch)
200
+
201
+ Veton Matoshi: [huggingface](https://huggingface.co/kapllan); [email](mailto:msv3@bfh.ch)