kiddothe2b commited on
Commit
e4add91
1 Parent(s): 6db080f

Fine-tuning + SD penaltyin EURLEX (Level 2)

Browse files
README.md CHANGED
@@ -1,3 +1,87 @@
1
  ---
2
- license: cc-by-nc-sa-4.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ widget:
3
+ - text: "KOMMISSIONENS BESLUTNING\naf 6. marts 2006\nom klassificering af visse byggevarers ydeevne med hensyn til reaktion ved brand for så vidt angår trægulve samt vægpaneler og vægbeklædning i massivt træ\n(meddelt under nummer K(2006) 655"
4
+ datasets:
5
+ - multi_eurlex
6
+ metrics:
7
+ - f1
8
+ model-index:
9
+ - name: coastalcph/danish-legal-longformer-eurlex-sd
10
+ results:
11
+ - task:
12
+ type: text-classification
13
+ name: Danish EURLEX (Level 2)
14
+ dataset:
15
+ name: multi_eurlex
16
+ type: multi_eurlex
17
+ config: multi_eurlex
18
+ split: validation
19
+ metrics:
20
+ - name: Micro-F1
21
+ type: micro-f1
22
+ value: 0.76144
23
+ - name: Macro-F1
24
+ type: macro-f1
25
+ value: 0.52878
26
  ---
27
+
28
+ # Model description
29
+
30
+ This model is a fine-tuned version of [coastalcph/danish-legal-longformer-base](https://huggingface.co/coastalcph/danish-legal-longformer-base) on the Danish part of [MultiEURLEX](https://huggingface.co/datasets/multi_eurlex) dataset using an additional Spectral Decoupling penalty ([Pezeshki et al., 2020](https://arxiv.org/abs/2011.09468).
31
+
32
+ ## Training and evaluation data
33
+
34
+ The Danish part of [MultiEURLEX](https://huggingface.co/datasets/multi_eurlex) dataset.
35
+
36
+ ## Use of Model
37
+
38
+ ### As a text classifier:
39
+
40
+ ```python
41
+ from transformers import pipeline
42
+ import numpy as np
43
+
44
+ # Init text classification pipeline
45
+ text_cls_pipe = pipeline(task="text-classification",
46
+ model="coastalcph/danish-legal-longformer-eurlex",
47
+ use_auth_token='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')
48
+
49
+ # Encode and Classify document
50
+ predictions = text_cls_pipe("KOMMISSIONENS BESLUTNING\naf 6. marts 2006\nom klassificering af visse byggevarers "
51
+ "ydeevne med hensyn til reaktion ved brand for så vidt angår trægulve samt vægpaneler "
52
+ "og vægbeklædning i massivt træ\n(meddelt under nummer K(2006) 655")
53
+
54
+ # Print prediction
55
+ print(predictions)
56
+ # [{'label': 'building and public works', 'score': 0.9626012444496155}]
57
+ ```
58
+
59
+ ### As a feature extractor (document embedder):
60
+
61
+ ```python
62
+ from transformers import pipeline
63
+ import numpy as np
64
+
65
+ # Init feature extraction pipeline
66
+ feature_extraction_pipe = pipeline(task="feature-extraction",
67
+ model="coastalcph/danish-legal-longformer-eurlex",
68
+ use_auth_token='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')
69
+
70
+ # Encode document
71
+ predictions = feature_extraction_pipe("KOMMISSIONENS BESLUTNING\naf 6. marts 2006\nom klassificering af visse byggevarers "
72
+ "ydeevne med hensyn til reaktion ved brand for så vidt angår trægulve samt vægpaneler "
73
+ "og vægbeklædning i massivt træ\n(meddelt under nummer K(2006) 655")
74
+
75
+ # Use CLS token representation as document embedding
76
+ document_features = token_wise_features[0][0]
77
+
78
+ print(document_features.shape)
79
+ # (768,)
80
+ ```
81
+
82
+ ## Framework versions
83
+
84
+ - Transformers 4.18.0
85
+ - Pytorch 1.12.0+cu113
86
+ - Datasets 2.0.0
87
+ - Tokenizers 0.12.1
all_results.json ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "epoch": 20.0,
3
+ "eval_loss": 0.06451725959777832,
4
+ "eval_macro-f1": 0.5287864667312759,
5
+ "eval_micro-f1": 0.7614412568306012,
6
+ "eval_runtime": 85.9935,
7
+ "eval_samples": 5000,
8
+ "eval_samples_per_second": 58.144,
9
+ "eval_steps_per_second": 1.826,
10
+ "predict_loss": 0.08024133741855621,
11
+ "predict_macro-f1": 0.46986770055294413,
12
+ "predict_micro-f1": 0.6993679640782279,
13
+ "predict_runtime": 86.1285,
14
+ "predict_samples": 5000,
15
+ "predict_samples_per_second": 58.053,
16
+ "predict_steps_per_second": 1.823,
17
+ "train_loss": 0.03325878010370344,
18
+ "train_runtime": 59590.7061,
19
+ "train_samples": 55000,
20
+ "train_samples_per_second": 18.459,
21
+ "train_steps_per_second": 0.577
22
+ }
config.json ADDED
@@ -0,0 +1,308 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "coastalcph/danish-legal-longformer-base",
3
+ "architectures": [
4
+ "LongformerForSequenceClassification"
5
+ ],
6
+ "attention_mode": "longformer",
7
+ "attention_probs_dropout_prob": 0.1,
8
+ "attention_window": [
9
+ 128,
10
+ 128,
11
+ 128,
12
+ 128,
13
+ 128,
14
+ 128,
15
+ 128,
16
+ 128,
17
+ 128,
18
+ 128,
19
+ 128,
20
+ 128
21
+ ],
22
+ "bos_token_id": 1,
23
+ "classifier_dropout": null,
24
+ "cls_token_id": 1,
25
+ "eos_token_id": 2,
26
+ "finetuning_task": "eurlex-127-concepts",
27
+ "gradient_checkpointing": false,
28
+ "hidden_act": "gelu",
29
+ "hidden_dropout_prob": 0.1,
30
+ "hidden_size": 768,
31
+ "id2label": {
32
+ "0": "health",
33
+ "1": "social framework",
34
+ "10": "building and public works",
35
+ "100": "European Union law",
36
+ "101": "humanities",
37
+ "102": "natural and applied sciences",
38
+ "103": "beverages and sugar",
39
+ "104": "processed agricultural produce",
40
+ "105": "agri-foodstuffs",
41
+ "106": "plant product",
42
+ "107": "animal product",
43
+ "108": "foodstuff",
44
+ "109": "food technology",
45
+ "11": "chemistry",
46
+ "110": "regions of EU Member States",
47
+ "111": "Africa",
48
+ "112": "overseas countries and territories",
49
+ "113": "Europe",
50
+ "114": "America",
51
+ "115": "economic geography",
52
+ "116": "Asia and Oceania",
53
+ "117": "political geography",
54
+ "118": "economic analysis",
55
+ "119": "economic conditions",
56
+ "12": "electronics and electrical engineering",
57
+ "120": "economic policy",
58
+ "121": "economic structure",
59
+ "122": "national accounts",
60
+ "123": "regions and regional policy",
61
+ "124": "deterioration of the environment",
62
+ "125": "natural environment",
63
+ "126": "environmental policy",
64
+ "13": "miscellaneous industries",
65
+ "14": "wood industry",
66
+ "15": "mechanical engineering",
67
+ "16": "industrial structures and policy",
68
+ "17": "leather and textile industries",
69
+ "18": "insurance",
70
+ "19": "free movement of capital",
71
+ "2": "culture and religion",
72
+ "20": "financing and investment",
73
+ "21": "prices",
74
+ "22": "budget",
75
+ "23": "public finance and budget policy",
76
+ "24": "monetary economics",
77
+ "25": "taxation",
78
+ "26": "financial institutions and credit",
79
+ "27": "monetary relations",
80
+ "28": "tariff policy",
81
+ "29": "trade",
82
+ "3": "social protection",
83
+ "30": "trade policy",
84
+ "31": "marketing",
85
+ "32": "distributive trades",
86
+ "33": "consumption",
87
+ "34": "international trade",
88
+ "35": "accounting",
89
+ "36": "competition",
90
+ "37": "management",
91
+ "38": "business classification",
92
+ "39": "legal form of organisations",
93
+ "4": "migration",
94
+ "40": "business organisation",
95
+ "41": "defence",
96
+ "42": "international affairs",
97
+ "43": "international security",
98
+ "44": "cooperation policy",
99
+ "45": "agricultural activity",
100
+ "46": "agricultural policy",
101
+ "47": "forestry",
102
+ "48": "agricultural structures and production",
103
+ "49": "cultivation of agricultural land",
104
+ "5": "family",
105
+ "50": "means of agricultural production",
106
+ "51": "fisheries",
107
+ "52": "farming systems",
108
+ "53": "production",
109
+ "54": "research and intellectual property",
110
+ "55": "technology and technical regulations",
111
+ "56": "transport policy",
112
+ "57": "air and space transport",
113
+ "58": "organisation of transport",
114
+ "59": "land transport",
115
+ "6": "construction and town planning",
116
+ "60": "maritime and inland waterway transport",
117
+ "61": "organisation of work and working conditions",
118
+ "62": "labour law and labour relations",
119
+ "63": "employment",
120
+ "64": "personnel management and staff remuneration",
121
+ "65": "labour market",
122
+ "66": "political party",
123
+ "67": "parliament",
124
+ "68": "executive power and public service",
125
+ "69": "parliamentary proceedings",
126
+ "7": "demography and population",
127
+ "70": "electoral procedure and voting",
128
+ "71": "political framework",
129
+ "72": "politics and public safety",
130
+ "73": "sources and branches of the law",
131
+ "74": "justice",
132
+ "75": "civil law",
133
+ "76": "rights and freedoms",
134
+ "77": "international law",
135
+ "78": "criminal law",
136
+ "79": "organisation of the legal system",
137
+ "8": "social affairs",
138
+ "80": "information and information processing",
139
+ "81": "education",
140
+ "82": "organisation of teaching",
141
+ "83": "information technology and data processing",
142
+ "84": "teaching",
143
+ "85": "documentation",
144
+ "86": "communications",
145
+ "87": "world organisations",
146
+ "88": "United Nations",
147
+ "89": "extra-European organisations",
148
+ "9": "iron, steel and other metal industries",
149
+ "90": "non-governmental organisations",
150
+ "91": "European organisations",
151
+ "92": "coal and mining industries",
152
+ "93": "energy policy",
153
+ "94": "oil industry",
154
+ "95": "soft energy",
155
+ "96": "electrical and nuclear industries",
156
+ "97": "EU finance",
157
+ "98": "EU institutions and European civil service",
158
+ "99": "European construction"
159
+ },
160
+ "ignore_attention_mask": false,
161
+ "initializer_range": 0.02,
162
+ "intermediate_size": 3072,
163
+ "label2id": {
164
+ "Africa": 111,
165
+ "America": 114,
166
+ "Asia and Oceania": 116,
167
+ "EU finance": 97,
168
+ "EU institutions and European civil service": 98,
169
+ "Europe": 113,
170
+ "European Union law": 100,
171
+ "European construction": 99,
172
+ "European organisations": 91,
173
+ "United Nations": 88,
174
+ "accounting": 35,
175
+ "agri-foodstuffs": 105,
176
+ "agricultural activity": 45,
177
+ "agricultural policy": 46,
178
+ "agricultural structures and production": 48,
179
+ "air and space transport": 57,
180
+ "animal product": 107,
181
+ "beverages and sugar": 103,
182
+ "budget": 22,
183
+ "building and public works": 10,
184
+ "business classification": 38,
185
+ "business organisation": 40,
186
+ "chemistry": 11,
187
+ "civil law": 75,
188
+ "coal and mining industries": 92,
189
+ "communications": 86,
190
+ "competition": 36,
191
+ "construction and town planning": 6,
192
+ "consumption": 33,
193
+ "cooperation policy": 44,
194
+ "criminal law": 78,
195
+ "cultivation of agricultural land": 49,
196
+ "culture and religion": 2,
197
+ "defence": 41,
198
+ "demography and population": 7,
199
+ "deterioration of the environment": 124,
200
+ "distributive trades": 32,
201
+ "documentation": 85,
202
+ "economic analysis": 118,
203
+ "economic conditions": 119,
204
+ "economic geography": 115,
205
+ "economic policy": 120,
206
+ "economic structure": 121,
207
+ "education": 81,
208
+ "electoral procedure and voting": 70,
209
+ "electrical and nuclear industries": 96,
210
+ "electronics and electrical engineering": 12,
211
+ "employment": 63,
212
+ "energy policy": 93,
213
+ "environmental policy": 126,
214
+ "executive power and public service": 68,
215
+ "extra-European organisations": 89,
216
+ "family": 5,
217
+ "farming systems": 52,
218
+ "financial institutions and credit": 26,
219
+ "financing and investment": 20,
220
+ "fisheries": 51,
221
+ "food technology": 109,
222
+ "foodstuff": 108,
223
+ "forestry": 47,
224
+ "free movement of capital": 19,
225
+ "health": 0,
226
+ "humanities": 101,
227
+ "industrial structures and policy": 16,
228
+ "information and information processing": 80,
229
+ "information technology and data processing": 83,
230
+ "insurance": 18,
231
+ "international affairs": 42,
232
+ "international law": 77,
233
+ "international security": 43,
234
+ "international trade": 34,
235
+ "iron, steel and other metal industries": 9,
236
+ "justice": 74,
237
+ "labour law and labour relations": 62,
238
+ "labour market": 65,
239
+ "land transport": 59,
240
+ "leather and textile industries": 17,
241
+ "legal form of organisations": 39,
242
+ "management": 37,
243
+ "maritime and inland waterway transport": 60,
244
+ "marketing": 31,
245
+ "means of agricultural production": 50,
246
+ "mechanical engineering": 15,
247
+ "migration": 4,
248
+ "miscellaneous industries": 13,
249
+ "monetary economics": 24,
250
+ "monetary relations": 27,
251
+ "national accounts": 122,
252
+ "natural and applied sciences": 102,
253
+ "natural environment": 125,
254
+ "non-governmental organisations": 90,
255
+ "oil industry": 94,
256
+ "organisation of teaching": 82,
257
+ "organisation of the legal system": 79,
258
+ "organisation of transport": 58,
259
+ "organisation of work and working conditions": 61,
260
+ "overseas countries and territories": 112,
261
+ "parliament": 67,
262
+ "parliamentary proceedings": 69,
263
+ "personnel management and staff remuneration": 64,
264
+ "plant product": 106,
265
+ "political framework": 71,
266
+ "political geography": 117,
267
+ "political party": 66,
268
+ "politics and public safety": 72,
269
+ "prices": 21,
270
+ "processed agricultural produce": 104,
271
+ "production": 53,
272
+ "public finance and budget policy": 23,
273
+ "regions and regional policy": 123,
274
+ "regions of EU Member States": 110,
275
+ "research and intellectual property": 54,
276
+ "rights and freedoms": 76,
277
+ "social affairs": 8,
278
+ "social framework": 1,
279
+ "social protection": 3,
280
+ "soft energy": 95,
281
+ "sources and branches of the law": 73,
282
+ "tariff policy": 28,
283
+ "taxation": 25,
284
+ "teaching": 84,
285
+ "technology and technical regulations": 55,
286
+ "trade": 29,
287
+ "trade policy": 30,
288
+ "transport policy": 56,
289
+ "wood industry": 14,
290
+ "world organisations": 87
291
+ },
292
+ "layer_norm_eps": 1e-05,
293
+ "max_position_embeddings": 2050,
294
+ "model_max_length": 2048,
295
+ "model_type": "longformer",
296
+ "num_attention_heads": 12,
297
+ "num_hidden_layers": 12,
298
+ "pad_token_id": 0,
299
+ "position_embedding_type": "absolute",
300
+ "problem_type": "multi_label_classification",
301
+ "sep_token_id": 2,
302
+ "torch_dtype": "float32",
303
+ "transformers_version": "4.18.0",
304
+ "type_vocab_size": 1,
305
+ "use_cache": true,
306
+ "use_spectral_decoupling": true,
307
+ "vocab_size": 32000
308
+ }
predict_results.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "predict_loss": 0.08024133741855621,
3
+ "predict_macro-f1": 0.46986770055294413,
4
+ "predict_micro-f1": 0.6993679640782279,
5
+ "predict_runtime": 86.1285,
6
+ "predict_samples": 5000,
7
+ "predict_samples_per_second": 58.053,
8
+ "predict_steps_per_second": 1.823
9
+ }
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:053945fba8a2787fc95f1fe319950a81247425aa27a87304be439416a4f9e1af
3
+ size 532736733
special_tokens_map.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"bos_token": "<s>", "eos_token": "</s>", "unk_token": "<unk>", "sep_token": "</s>", "pad_token": "<pad>", "cls_token": "<s>", "mask_token": "<mask>"}
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"model_max_length": 2048, "bos_token": "<s>", "eos_token": "</s>", "unk_token": "<unk>", "sep_token": "</s>", "pad_token": "<pad>", "cls_token": "<s>", "mask_token": "<mask>", "special_tokens_map_file": "data/PLMs/danish-lm/danish-lex-lm-base/special_tokens_map.json", "name_or_path": "coastalcph/danish-legal-longformer-base", "tokenizer_class": "PreTrainedTokenizerFast"}