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