This repository has been archived by the owner on Jul 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmulti_label_classifier.jsonnet
74 lines (73 loc) · 2.49 KB
/
multi_label_classifier.jsonnet
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// This should be a registered name in the Transformers library (see https://huggingface.co/models)
// OR a path on disk to a serialized transformer model.
local transformer_model = std.extVar("TRANSFORMER_MODEL");
// Inputs longer than this will be truncated.
// Should not be longer than the max length supported by transformer_model.
local max_length = std.parseInt(std.extVar("MAX_LENGTH"));
{
'vocabulary': {
'max_vocab_size': {
'tokens': 0
}
},
"dataset_reader": {
"type": "multi_label",
"tokenizer": {
"type": "pretrained_transformer",
"model_name": transformer_model,
// Account for special tokens (e.g. CLS and SEP), otherwise a cryptic error is thrown.
"max_length": max_length - 2,
},
"token_indexers": {
"tokens": {
"type": "pretrained_transformer",
"model_name": transformer_model,
},
},
},
"train_data_path": null,
"validation_data_path": null,
"model": {
"type": "multi_label",
"text_field_embedder": {
"token_embedders": {
"tokens": {
"type": "pretrained_transformer",
"model_name": transformer_model,
},
},
},
},
"data_loader": {
"batch_sampler": {
"type": "bucket",
"sorting_keys": ["tokens"],
"batch_size" : 16,
},
"num_workers": 1
},
"trainer": {
// Set use_amp to true to use automatic mixed-precision during training (if your GPU supports it)
"use_amp": true,
"optimizer": {
"type": "huggingface_adamw",
"lr": 2e-5,
"weight_decay": 0.0,
"parameter_groups": [
# Apply weight decay to pre-trained parameters, exlcuding LayerNorm parameters and biases
# See: https://github.com/huggingface/transformers/blob/2184f87003c18ad8a172ecab9a821626522cf8e7/examples/run_ner.py#L105
# Regex: https://regex101.com/r/ZUyDgR/3/tests
[["(?=.*transformer_model)(?=.*\\.+)(?!.*(LayerNorm|bias)).*$"], {"weight_decay": 0.1}],
],
},
"patience": 1,
"num_epochs": 5,
"checkpointer": {
"num_serialized_models_to_keep": 1,
},
"grad_norm": 1.0,
"learning_rate_scheduler": {
"type": "slanted_triangular",
},
},
}