Skip to content
This repository was archived by the owner on Dec 16, 2022. It is now read-only.

Commit 5512a8f

Browse files
authored
Add config for non-elmo constituency parser, rename existing parser config (#1965)
1 parent dedc4ce commit 5512a8f

File tree

2 files changed

+88
-14
lines changed

2 files changed

+88
-14
lines changed

training_config/constituency_parser.jsonnet

+7-14
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@
33
{
44
"dataset_reader":{
55
"type":"ptb_trees",
6-
"use_pos_tags": true,
7-
"token_indexers": {
8-
"elmo": {
9-
"type": "elmo_characters"
10-
}
11-
}
6+
"use_pos_tags": true
127
},
138
"train_data_path": std.extVar('PTB_TRAIN_PATH'),
149
"validation_data_path": std.extVar('PTB_DEV_PATH'),
@@ -17,13 +12,11 @@
1712
"type": "constituency_parser",
1813
"text_field_embedder": {
1914
"token_embedders": {
20-
"elmo": {
21-
"type": "elmo_token_embedder",
22-
"dropout": 0.2,
23-
"options_file": "https://s3-us-west-2.amazonaws.com/allennlp/models/elmo/2x4096_512_2048cnn_2xhighway/elmo_2x4096_512_2048cnn_2xhighway_options.json",
24-
"weight_file": "https://s3-us-west-2.amazonaws.com/allennlp/models/elmo/2x4096_512_2048cnn_2xhighway/elmo_2x4096_512_2048cnn_2xhighway_weights.hdf5",
25-
"do_layer_norm": false
26-
}
15+
"tokens": {
16+
"type": "embedding",
17+
"embedding_dim": 100,
18+
"trainable": true
19+
}
2720
}
2821
},
2922
"pos_tag_embedding":{
@@ -38,7 +31,7 @@
3831
],
3932
"encoder": {
4033
"type": "lstm",
41-
"input_size": 1074,
34+
"input_size": 150,
4235
"hidden_size": 250,
4336
"num_layers": 2,
4437
"bidirectional": true,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// Configuration for an Elmo-augmented constituency parser based on:
2+
// Stern, Mitchell et al. “A Minimal Span-Based Neural Constituency Parser.” ACL (2017).
3+
{
4+
"dataset_reader":{
5+
"type":"ptb_trees",
6+
"use_pos_tags": true,
7+
"token_indexers": {
8+
"elmo": {
9+
"type": "elmo_characters"
10+
}
11+
}
12+
},
13+
"train_data_path": std.extVar('PTB_TRAIN_PATH'),
14+
"validation_data_path": std.extVar('PTB_DEV_PATH'),
15+
"test_data_path": std.extVar('PTB_TEST_PATH'),
16+
"model": {
17+
"type": "constituency_parser",
18+
"text_field_embedder": {
19+
"token_embedders": {
20+
"elmo": {
21+
"type": "elmo_token_embedder",
22+
"dropout": 0.2,
23+
"options_file": "https://s3-us-west-2.amazonaws.com/allennlp/models/elmo/2x4096_512_2048cnn_2xhighway/elmo_2x4096_512_2048cnn_2xhighway_options.json",
24+
"weight_file": "https://s3-us-west-2.amazonaws.com/allennlp/models/elmo/2x4096_512_2048cnn_2xhighway/elmo_2x4096_512_2048cnn_2xhighway_weights.hdf5",
25+
"do_layer_norm": false
26+
}
27+
}
28+
},
29+
"pos_tag_embedding":{
30+
"embedding_dim": 50,
31+
"vocab_namespace": "pos"
32+
},
33+
"initializer": [
34+
["tag_projection_layer.*weight", {"type": "xavier_normal"}],
35+
["feedforward_layer.*weight", {"type": "xavier_normal"}],
36+
["encoder._module.weight_ih.*", {"type": "xavier_normal"}],
37+
["encoder._module.weight_hh.*", {"type": "orthogonal"}]
38+
],
39+
"encoder": {
40+
"type": "lstm",
41+
"input_size": 1074,
42+
"hidden_size": 250,
43+
"num_layers": 2,
44+
"bidirectional": true,
45+
"dropout": 0.2
46+
},
47+
"feedforward": {
48+
"input_dim": 500,
49+
"num_layers": 1,
50+
"hidden_dims": 250,
51+
"activations": "relu",
52+
"dropout": 0.1
53+
},
54+
"span_extractor": {
55+
"type": "bidirectional_endpoint",
56+
"input_dim": 500
57+
}
58+
},
59+
"iterator": {
60+
"type": "bucket",
61+
"sorting_keys": [["tokens", "num_tokens"]],
62+
"batch_size" : 32
63+
},
64+
"trainer": {
65+
"learning_rate_scheduler": {
66+
"type": "multi_step",
67+
"milestones": [40, 50, 60, 70, 80],
68+
"gamma": 0.8
69+
},
70+
"num_epochs": 150,
71+
"grad_norm": 5.0,
72+
"patience": 20,
73+
"validation_metric": "+evalb_f1_measure",
74+
"cuda_device": 0,
75+
"optimizer": {
76+
"type": "adadelta",
77+
"lr": 1.0,
78+
"rho": 0.95
79+
}
80+
}
81+
}

0 commit comments

Comments
 (0)