Joelito kapllan commited on
Commit
f3f012c
1 Parent(s): 70c1a9d

Created a model card (#1)

Browse files

- Created a model card (5ce3fcc53fa170b40c44b8e82ff8773d0b46e822)


Co-authored-by: kapllan <[email protected]>

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