fendiprime commited on
Commit
b6b2eef
·
verified ·
1 Parent(s): 8341925

Upload folder using huggingface_hub

Browse files
README.md CHANGED
@@ -1,3 +1,142 @@
1
  ---
 
 
2
  license: cc-by-sa-4.0
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ language: en
3
+ pipeline_tag: fill-mask
4
  license: cc-by-sa-4.0
5
+ thumbnail: https://i.ibb.co/p3kQ7Rw/Screenshot-2020-10-06-at-12-16-36-PM.png
6
+ tags:
7
+ - legal
8
+ widget:
9
+ - text: "The applicant submitted that her husband was subjected to treatment amounting to [MASK] whilst in the custody of police."
10
  ---
11
+
12
+ # LEGAL-BERT: The Muppets straight out of Law School
13
+
14
+ <img align="left" src="https://i.ibb.co/p3kQ7Rw/Screenshot-2020-10-06-at-12-16-36-PM.png" width="100"/>
15
+
16
+ LEGAL-BERT is a family of BERT models for the legal domain, intended to assist legal NLP research, computational law, and legal technology applications. To pre-train the different variations of LEGAL-BERT, we collected 12 GB of diverse English legal text from several fields (e.g., legislation, court cases, contracts) scraped from publicly available resources. Sub-domain variants (CONTRACTS-, EURLEX-, ECHR-) and/or general LEGAL-BERT perform better than using BERT out of the box for domain-specific tasks. A light-weight model (33% the size of BERT-BASE) pre-trained from scratch on legal data with competitive performance is also available.
17
+ <br/><br/>
18
+
19
+ ---
20
+
21
+ I. Chalkidis, M. Fergadiotis, P. Malakasiotis, N. Aletras and I. Androutsopoulos. "LEGAL-BERT: The Muppets straight out of Law School". In Findings of Empirical Methods in Natural Language Processing (EMNLP 2020) (Short Papers), to be held online, 2020. (https://aclanthology.org/2020.findings-emnlp.261)
22
+
23
+ ---
24
+
25
+ ## Pre-training corpora
26
+
27
+ The pre-training corpora of LEGAL-BERT include:
28
+
29
+ * 116,062 documents of EU legislation, publicly available from EURLEX (http://eur-lex.europa.eu), the repository of EU Law running under the EU Publication Office.
30
+
31
+ * 61,826 documents of UK legislation, publicly available from the UK legislation portal (http://www.legislation.gov.uk).
32
+
33
+ * 19,867 cases from the European Court of Justice (ECJ), also available from EURLEX.
34
+
35
+ * 12,554 cases from HUDOC, the repository of the European Court of Human Rights (ECHR) (http://hudoc.echr.coe.int/eng).
36
+
37
+ * 164,141 cases from various courts across the USA, hosted in the Case Law Access Project portal (https://case.law).
38
+
39
+ * 76,366 US contracts from EDGAR, the database of US Securities and Exchange Commission (SECOM) (https://www.sec.gov/edgar.shtml).
40
+
41
+ ## Pre-training details
42
+
43
+ * We trained BERT using the official code provided in Google BERT's GitHub repository (https://github.com/google-research/bert).
44
+ * We released a model similar to the English BERT-BASE model (12-layer, 768-hidden, 12-heads, 110M parameters).
45
+ * We chose to follow the same training set-up: 1 million training steps with batches of 256 sequences of length 512 with an initial learning rate 1e-4.
46
+ * We were able to use a single Google Cloud TPU v3-8 provided for free from [TensorFlow Research Cloud (TFRC)](https://www.tensorflow.org/tfrc), while also utilizing [GCP research credits](https://edu.google.com/programs/credits/research). Huge thanks to both Google programs for supporting us!
47
+ * Part of LEGAL-BERT is a light-weight model pre-trained from scratch on legal data, which achieves comparable performance to larger models, while being much more efficient (approximately 4 times faster) with a smaller environmental footprint.
48
+
49
+ ## Models list
50
+
51
+ | Model name | Model Path | Training corpora |
52
+ | ------------------- | ------------------------------------ | ------------------- |
53
+ | CONTRACTS-BERT-BASE | `nlpaueb/bert-base-uncased-contracts` | US contracts |
54
+ | EURLEX-BERT-BASE | `nlpaueb/bert-base-uncased-eurlex` | EU legislation |
55
+ | ECHR-BERT-BASE | `nlpaueb/bert-base-uncased-echr` | ECHR cases |
56
+ | LEGAL-BERT-BASE * | `nlpaueb/legal-bert-base-uncased` | All |
57
+ | LEGAL-BERT-SMALL | `nlpaueb/legal-bert-small-uncased` | All |
58
+
59
+ \* LEGAL-BERT-BASE is the model referred to as LEGAL-BERT-SC in Chalkidis et al. (2020); a model trained from scratch in the legal corpora mentioned below using a newly created vocabulary by a sentence-piece tokenizer trained on the very same corpora.
60
+
61
+ \*\* As many of you expressed interest in the LEGAL-BERT-FP models (those relying on the original BERT-BASE checkpoint), they have been released in Archive.org (https://archive.org/details/legal_bert_fp), as these models are secondary and possibly only interesting for those who aim to dig deeper in the open questions of Chalkidis et al. (2020).
62
+
63
+ ## Load Pretrained Model
64
+
65
+ ```python
66
+ from transformers import AutoTokenizer, AutoModel
67
+
68
+ tokenizer = AutoTokenizer.from_pretrained("nlpaueb/legal-bert-base-uncased")
69
+ model = AutoModel.from_pretrained("nlpaueb/legal-bert-base-uncased")
70
+ ```
71
+
72
+ ## Use LEGAL-BERT variants as Language Models
73
+
74
+ | Corpus | Model | Masked token | Predictions |
75
+ | --------------------------------- | ---------------------------------- | ------------ | ------------ |
76
+ | | **BERT-BASE-UNCASED** |
77
+ | (Contracts) | This [MASK] Agreement is between General Motors and John Murray . | employment | ('new', '0.09'), ('current', '0.04'), ('proposed', '0.03'), ('marketing', '0.03'), ('joint', '0.02')
78
+ | (ECHR) | The applicant submitted that her husband was subjected to treatment amounting to [MASK] whilst in the custody of Adana Security Directorate | torture | ('torture', '0.32'), ('rape', '0.22'), ('abuse', '0.14'), ('death', '0.04'), ('violence', '0.03')
79
+ | (EURLEX) | Establishing a system for the identification and registration of [MASK] animals and regarding the labelling of beef and beef products . | bovine | ('farm', '0.25'), ('livestock', '0.08'), ('draft', '0.06'), ('domestic', '0.05'), ('wild', '0.05')
80
+ | | **CONTRACTS-BERT-BASE** |
81
+ | (Contracts) | This [MASK] Agreement is between General Motors and John Murray . | employment | ('letter', '0.38'), ('dealer', '0.04'), ('employment', '0.03'), ('award', '0.03'), ('contribution', '0.02')
82
+ | (ECHR) | The applicant submitted that her husband was subjected to treatment amounting to [MASK] whilst in the custody of Adana Security Directorate | torture | ('death', '0.39'), ('imprisonment', '0.07'), ('contempt', '0.05'), ('being', '0.03'), ('crime', '0.02')
83
+ | (EURLEX) | Establishing a system for the identification and registration of [MASK] animals and regarding the labelling of beef and beef products . | bovine | (('domestic', '0.18'), ('laboratory', '0.07'), ('household', '0.06'), ('personal', '0.06'), ('the', '0.04')
84
+ | | **EURLEX-BERT-BASE** |
85
+ | (Contracts) | This [MASK] Agreement is between General Motors and John Murray . | employment | ('supply', '0.11'), ('cooperation', '0.08'), ('service', '0.07'), ('licence', '0.07'), ('distribution', '0.05')
86
+ | (ECHR) | The applicant submitted that her husband was subjected to treatment amounting to [MASK] whilst in the custody of Adana Security Directorate | torture | ('torture', '0.66'), ('death', '0.07'), ('imprisonment', '0.07'), ('murder', '0.04'), ('rape', '0.02')
87
+ | (EURLEX) | Establishing a system for the identification and registration of [MASK] animals and regarding the labelling of beef and beef products . | bovine | ('live', '0.43'), ('pet', '0.28'), ('certain', '0.05'), ('fur', '0.03'), ('the', '0.02')
88
+ | | **ECHR-BERT-BASE** |
89
+ | (Contracts) | This [MASK] Agreement is between General Motors and John Murray . | employment | ('second', '0.24'), ('latter', '0.10'), ('draft', '0.05'), ('bilateral', '0.05'), ('arbitration', '0.04')
90
+ | (ECHR) | The applicant submitted that her husband was subjected to treatment amounting to [MASK] whilst in the custody of Adana Security Directorate | torture | ('torture', '0.99'), ('death', '0.01'), ('inhuman', '0.00'), ('beating', '0.00'), ('rape', '0.00')
91
+ | (EURLEX) | Establishing a system for the identification and registration of [MASK] animals and regarding the labelling of beef and beef products . | bovine | ('pet', '0.17'), ('all', '0.12'), ('slaughtered', '0.10'), ('domestic', '0.07'), ('individual', '0.05')
92
+ | | **LEGAL-BERT-BASE** |
93
+ | (Contracts) | This [MASK] Agreement is between General Motors and John Murray . | employment | ('settlement', '0.26'), ('letter', '0.23'), ('dealer', '0.04'), ('master', '0.02'), ('supplemental', '0.02')
94
+ | (ECHR) | The applicant submitted that her husband was subjected to treatment amounting to [MASK] whilst in the custody of Adana Security Directorate | torture | ('torture', '1.00'), ('detention', '0.00'), ('arrest', '0.00'), ('rape', '0.00'), ('death', '0.00')
95
+ | (EURLEX) | Establishing a system for the identification and registration of [MASK] animals and regarding the labelling of beef and beef products . | bovine | ('live', '0.67'), ('beef', '0.17'), ('farm', '0.03'), ('pet', '0.02'), ('dairy', '0.01')
96
+ | | **LEGAL-BERT-SMALL** |
97
+ | (Contracts) | This [MASK] Agreement is between General Motors and John Murray . | employment | ('license', '0.09'), ('transition', '0.08'), ('settlement', '0.04'), ('consent', '0.03'), ('letter', '0.03')
98
+ | (ECHR) | The applicant submitted that her husband was subjected to treatment amounting to [MASK] whilst in the custody of Adana Security Directorate | torture | ('torture', '0.59'), ('pain', '0.05'), ('ptsd', '0.05'), ('death', '0.02'), ('tuberculosis', '0.02')
99
+ | (EURLEX) | Establishing a system for the identification and registration of [MASK] animals and regarding the labelling of beef and beef products . | bovine | ('all', '0.08'), ('live', '0.07'), ('certain', '0.07'), ('the', '0.07'), ('farm', '0.05')
100
+
101
+
102
+ ## Evaluation on downstream tasks
103
+
104
+ Consider the experiments in the article "LEGAL-BERT: The Muppets straight out of Law School". Chalkidis et al., 2020, (https://aclanthology.org/2020.findings-emnlp.261)
105
+
106
+ ## Author - Publication
107
+
108
+ ```
109
+ @inproceedings{chalkidis-etal-2020-legal,
110
+ title = "{LEGAL}-{BERT}: The Muppets straight out of Law School",
111
+ author = "Chalkidis, Ilias and
112
+ Fergadiotis, Manos and
113
+ Malakasiotis, Prodromos and
114
+ Aletras, Nikolaos and
115
+ Androutsopoulos, Ion",
116
+ booktitle = "Findings of the Association for Computational Linguistics: EMNLP 2020",
117
+ month = nov,
118
+ year = "2020",
119
+ address = "Online",
120
+ publisher = "Association for Computational Linguistics",
121
+ doi = "10.18653/v1/2020.findings-emnlp.261",
122
+ pages = "2898--2904"
123
+ }
124
+ ```
125
+
126
+ ## About Us
127
+
128
+ [AUEB's Natural Language Processing Group](http://nlp.cs.aueb.gr) develops algorithms, models, and systems that allow computers to process and generate natural language texts.
129
+
130
+ The group's current research interests include:
131
+ * question answering systems for databases, ontologies, document collections, and the Web, especially biomedical question answering,
132
+ * natural language generation from databases and ontologies, especially Semantic Web ontologies,
133
+ text classification, including filtering spam and abusive content,
134
+ * information extraction and opinion mining, including legal text analytics and sentiment analysis,
135
+ * natural language processing tools for Greek, for example parsers and named-entity recognizers,
136
+ machine learning in natural language processing, especially deep learning.
137
+
138
+ The group is part of the Information Processing Laboratory of the Department of Informatics of the Athens University of Economics and Business.
139
+
140
+ [Ilias Chalkidis](https://iliaschalkidis.github.io) on behalf of [AUEB's Natural Language Processing Group](http://nlp.cs.aueb.gr)
141
+
142
+ | Github: [@ilias.chalkidis](https://github.com/iliaschalkidis) | Twitter: [@KiddoThe2B](https://twitter.com/KiddoThe2B) |
config.json ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "BertForPreTraining"
4
+ ],
5
+ "attention_probs_dropout_prob": 0.1,
6
+ "bos_token_id": 0,
7
+ "do_sample": false,
8
+ "eos_token_ids": 0,
9
+ "finetuning_task": null,
10
+ "hidden_act": "gelu",
11
+ "hidden_dropout_prob": 0.1,
12
+ "hidden_size": 768,
13
+ "id2label": {
14
+ "0": "LABEL_0",
15
+ "1": "LABEL_1"
16
+ },
17
+ "initializer_range": 0.02,
18
+ "intermediate_size": 3072,
19
+ "is_decoder": false,
20
+ "label2id": {
21
+ "LABEL_0": 0,
22
+ "LABEL_1": 1
23
+ },
24
+ "layer_norm_eps": 1e-12,
25
+ "length_penalty": 1.0,
26
+ "max_length": 20,
27
+ "max_position_embeddings": 512,
28
+ "model_type": "bert",
29
+ "num_attention_heads": 12,
30
+ "num_beams": 1,
31
+ "num_hidden_layers": 12,
32
+ "num_labels": 2,
33
+ "num_return_sequences": 1,
34
+ "output_attentions": false,
35
+ "output_hidden_states": false,
36
+ "output_past": true,
37
+ "pad_token_id": 0,
38
+ "pruned_heads": {},
39
+ "repetition_penalty": 1.0,
40
+ "temperature": 1.0,
41
+ "top_k": 50,
42
+ "top_p": 1.0,
43
+ "torchscript": false,
44
+ "type_vocab_size": 2,
45
+ "use_bfloat16": false,
46
+ "vocab_size": 30522
47
+ }
huggingface-metadata.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ url: https://huggingface.co/nlpaueb/legal-bert-base-uncased
2
+ branch: main
3
+ download date: 2024-01-27 19:11:09
4
+ sha256sum:
5
+ 6b4f1da798ff101a66ad5cb11c6daa7f99cd41e7909277e01398576e8bd789bd pytorch_model.bin
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6b4f1da798ff101a66ad5cb11c6daa7f99cd41e7909277e01398576e8bd789bd
3
+ size 440474526
special_tokens_map.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]"}
tokenizer_config.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"do_lower_case": true, "model_max_length": 512}
vocab.txt ADDED
The diff for this file is too large to render. See raw diff