File size: 1,997 Bytes
05922fb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
local env = import "../env.jsonnet";
local base = import "basic.jsonnet";

local fn_path = "data/framenet/full/full.jsonl";
local mapping_path = "data/basic/framenet2better/";

local debug = false;

# training
local lr = env.json("PT_LR", "5e-5");
local cuda_devices = base.cuda_devices;

# mapping
local min_weight = env.json("MIN_WEIGHT", '0.0');
local max_weight = env.json("MAX_WEIGHT", '5.0');

{
    dataset_reader: {
        type: "semantic_role_labeling",
        debug: debug,
        pretrained_model: base.dataset_reader.pretrained_model,
        ignore_label: false,
        [ if debug then "max_instances" ]: 128,
        ontology_mapping_path: mapping_path + '/ontology_mapping.json',
        min_weight: min_weight,
        max_weight: max_weight,
    },
    validation_dataset_reader: base.dataset_reader,
    train_data_path: fn_path,
    validation_data_path: base.validation_data_path,
    test_data_path: base.test_data_path,
    vocabulary: {
        type: "extend",
        directory: mapping_path + "/vocabulary"
    },

    datasets_for_vocab_creation: ["train"],

    data_loader: base.data_loader,
    validation_data_loader: base.validation_data_loader,

    model: base.model,

    trainer: {
        num_epochs: base.trainer.num_epochs,
        patience: base.trainer.patience,
        [if std.length(cuda_devices) == 1 then "cuda_device"]: cuda_devices[0],
        validation_metric: "+arg-c_f",
        num_gradient_accumulation_steps: base.trainer.num_gradient_accumulation_steps,
        optimizer: {
            type: "transformer",
            base: {
                type: "adam",
                lr: lr,
            },
            embeddings_lr: 0.0,
            encoder_lr: 1e-5,
            pooler_lr: 1e-5,
            layer_fix: base.trainer.optimizer.layer_fix,
        }
    },

    [if std.length(cuda_devices) > 1 then "distributed"]: {
        "cuda_devices": cuda_devices
    },
    [if std.length(cuda_devices) == 1 then "evaluate_on_test"]: true
}