Model Card for joelito/legal-swiss-longformer-base
This model is a multilingual model pretrained on legal data. It is based on XLM-R (base and large). For pretraining we used Multi Legal Pile (Niklaus et al. 2023), a multilingual dataset from various legal sources covering 24 languages.
Model Details
Model Description
- Developed by: Joel Niklaus: huggingface; email
- Model type: Transformer-based language model (Longformer)
- Language(s) (NLP): de, fr, it
- License: CC BY-SA
Uses
Direct Use and Downstream Use
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.
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.
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.
Out-of-Scope Use
For tasks such as text generation you should look at model like GPT2.
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.
Bias, Risks, and Limitations
Significant research has explored bias and fairness issues with language models (see, e.g., Sheng et al. (2021) and Bender et al. (2021)). Predictions generated by the model may include disturbing and harmful stereotypes across protected classes; identity characteristics; and sensitive, social, and occupational groups.
Recommendations
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.
How to Get Started with the Model
See huggingface tutorials. For masked word prediction see this tutorial.
Training Details
This model was pretrained on Multi Legal Pile (Niklaus et al. 2023).
Our pretraining procedure includes the following key steps:
(a) Warm-starting: We initialize our models from the original XLM-R checkpoints (base and large) of Conneau et al. (2019) to benefit from a well-trained base.
(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.
(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).
(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.
(e) Mixed Cased Models: Our models cover both upper- and lowercase letters, similar to recently developed large PLMs.
(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.
Training Data
This model was pretrained on Multi Legal Pile (Niklaus et al. 2023).
Preprocessing
For further details see Niklaus et al. 2023
Training Hyperparameters
- batche size: 512 samples
- Number of steps: 1M/500K for the base/large model
- Warm-up steps for the first 5% of the total training steps
- Learning rate: (linearly increasing up to) 1e-4
- Word masking: increased 20/30% masking rate for base/large models respectively
Evaluation
We compare joelito/legal-swiss-longformer-base with the other multilingual models. The results are based on the text classification tasks presented in Niklaus et al. (2023) which are part of LEXTREME. We provide the arithmetic mean over three seeds (1, 2, 3) based on the macro-F1-score on the test set. The highest values are in bold.
_name_or_path | SCP-BC | SCP-BF | SCP-CC | SCP-CF | SJPXL-C | SJPXL-F | SLAP-SC | SLAP-SF |
---|---|---|---|---|---|---|---|---|
ZurichNLP/swissbert-xlm-vocab | 71.36 | 57.48 | 27.33 | 23.37 | 80.81 | 61.75 | 77.89 | 71.27 |
distilbert-base-multilingual-cased | 66.56 | 56.58 | 22.67 | 21.31 | 77.26 | 60.79 | 73.54 | 72.24 |
facebook/xmod-base | 70.35 | 58.16 | 23.87 | 19.57 | 80.55 | 60.84 | 73.16 | 69.03 |
joelito/legal-swiss-longformer-base | 73.25 | 60.06 | 28.68 | 24.39 | 87.46 | 65.23 | 83.84 | 77.96 |
joelito/legal-swiss-roberta-base | 72.41 | 59.31 | 25.99 | 23.27 | 87.48 | 64.16 | 86.8 | 81.56 |
joelito/legal-swiss-roberta-large | 70.95 | 57.59 | 27.86 | 23.48 | 88.33 | 62.92 | 82.1 | 78.62 |
microsoft/Multilingual-MiniLM-L12-H384 | 67.29 | 56.56 | 24.23 | 14.9 | 79.52 | 58.29 | 63.03 | 67.57 |
microsoft/mdeberta-v3-base | 72.01 | 57.59 | 22.93 | 25.18 | 79.41 | 60.89 | 67.64 | 74.13 |
xlm-roberta-base | 68.55 | 58.48 | 25.66 | 21.52 | 80.98 | 61.45 | 79.3 | 74.47 |
xlm-roberta-large | 69.5 | 58.15 | 27.9 | 22.05 | 82.19 | 61.24 | 81.09 | 71.82 |
For more detailed insights into the performance on downstream tasks, such as LEXTREME (Niklaus et al. 2023) or LEXGLUE (Chalkidis et al. 2021), we refer to the results presented in Niklaus et al. (2023) 1, 2.
Model Architecture and Objective
It is a RoBERTa-based model. Run the following code to view the architecture:
from transformers import AutoModel
model = AutoModel.from_pretrained('joelito/legal-swiss-longformer-base')
print(model)
LongformerModel(
(embeddings): LongformerEmbeddings(
(word_embeddings): Embedding(128000, 768, padding_idx=0)
(position_embeddings): Embedding(4098, 768, padding_idx=0)
(token_type_embeddings): Embedding(1, 768)
(LayerNorm): LayerNorm((768,), eps=1e-05, elementwise_affine=True)
(dropout): Dropout(p=0.1, inplace=False)
)
(encoder): LongformerEncoder(
(layer): ModuleList(
(0-11): 12 x LongformerLayer(
(attention): LongformerAttention(
(self): LongformerSelfAttention(
(query): Linear(in_features=768, out_features=768, bias=True)
(key): Linear(in_features=768, out_features=768, bias=True)
(value): Linear(in_features=768, out_features=768, bias=True)
(query_global): Linear(in_features=768, out_features=768, bias=True)
(key_global): Linear(in_features=768, out_features=768, bias=True)
(value_global): Linear(in_features=768, out_features=768, bias=True)
)
(output): LongformerSelfOutput(
(dense): Linear(in_features=768, out_features=768, bias=True)
(LayerNorm): LayerNorm((768,), eps=1e-05, elementwise_affine=True)
(dropout): Dropout(p=0.1, inplace=False)
)
)
(intermediate): LongformerIntermediate(
(dense): Linear(in_features=768, out_features=3072, bias=True)
(intermediate_act_fn): GELUActivation()
)
(output): LongformerOutput(
(dense): Linear(in_features=3072, out_features=768, bias=True)
(LayerNorm): LayerNorm((768,), eps=1e-05, elementwise_affine=True)
(dropout): Dropout(p=0.1, inplace=False)
)
)
)
)
(pooler): LongformerPooler(
(dense): Linear(in_features=768, out_features=768, bias=True)
(activation): Tanh()
)
)
Compute Infrastructure
Google TPU.
Hardware
Google TPU v3-8
Software
pytorch, transformers.
Citation
@misc{rasiah2023scale,
title={SCALE: Scaling up the Complexity for Advanced Language Model Evaluation},
author={Vishvaksenan Rasiah and Ronja Stern and Veton Matoshi and Matthias Stürmer and Ilias Chalkidis and Daniel E. Ho and Joel Niklaus},
year={2023},
eprint={2306.09237},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
@article{Niklaus2023MultiLegalPileA6,
title={MultiLegalPile: A 689GB Multilingual Legal Corpus},
author={Joel Niklaus and Veton Matoshi and Matthias Sturmer and Ilias Chalkidis and Daniel E. Ho},
journal={ArXiv},
year={2023},
volume={abs/2306.02069}
}
Model Card Authors
Joel Niklaus: huggingface; email
Veton Matoshi: huggingface; email
Model Card Contact
Joel Niklaus: huggingface; email
Veton Matoshi: huggingface; email
- Downloads last month
- 125