forked from allenai/allennlp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqanet.jsonnet
159 lines (159 loc) · 5 KB
/
qanet.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
// Configuration for the basic QANet model from "QANet: Combining Local
// Convolution with Global Self-Attention for Reading Comprehension"
// (https://arxiv.org/abs/1804.09541).
{
"dataset_reader": {
"type": "squad",
"token_indexers": {
"tokens": {
"type": "single_id",
"lowercase_tokens": true
},
"token_characters": {
"type": "characters",
"min_padding_length": 5
}
},
"passage_length_limit": 400,
"question_length_limit": 50,
"skip_invalid_examples": true
},
"validation_dataset_reader": {
"type": "squad",
"token_indexers": {
"tokens": {
"type": "single_id",
"lowercase_tokens": true
},
"token_characters": {
"type": "characters",
"min_padding_length": 5
}
},
"passage_length_limit": 1000,
"question_length_limit": 100,
"skip_invalid_examples": false
},
"vocabulary": {
"min_count": {
"token_characters": 200
},
"pretrained_files": {
// This embedding file is created from the Glove 840B 300d embedding file.
// We kept all the original lowercased words and their embeddings. But there are also many words
// with only the uppercased version. To include as many words as possible, we lowered those words
// and used the embeddings of uppercased words as an alternative.
"tokens": "https://s3-us-west-2.amazonaws.com/allennlp/datasets/glove/glove.840B.300d.lower.converted.zip"
},
"only_include_pretrained_words": true
},
"train_data_path": "https://s3-us-west-2.amazonaws.com/allennlp/datasets/squad/squad-train-v1.1.json",
"validation_data_path": "https://s3-us-west-2.amazonaws.com/allennlp/datasets/squad/squad-dev-v1.1.json",
"model": {
"type": "qanet",
"text_field_embedder": {
"token_embedders": {
"tokens": {
"type": "embedding",
"pretrained_file": "https://s3-us-west-2.amazonaws.com/allennlp/datasets/glove/glove.840B.300d.lower.converted.zip",
"embedding_dim": 300,
"trainable": false
},
"token_characters": {
"type": "character_encoding",
"embedding": {
"embedding_dim": 64
},
"encoder": {
"type": "cnn",
"embedding_dim": 64,
"num_filters": 200,
"ngram_filter_sizes": [
5
]
}
}
}
},
"num_highway_layers": 2,
"phrase_layer": {
"type": "qanet_encoder",
"input_dim": 128,
"hidden_dim": 128,
"attention_projection_dim": 128,
"feedforward_hidden_dim": 128,
"num_blocks": 1,
"num_convs_per_block": 4,
"conv_kernel_size": 7,
"num_attention_heads": 8,
"dropout_prob": 0.1,
"layer_dropout_undecayed_prob": 0.1,
"attention_dropout_prob": 0
},
"matrix_attention_layer": {
"type": "linear",
"tensor_1_dim": 128,
"tensor_2_dim": 128,
"combination": "x,y,x*y"
},
"modeling_layer": {
"type": "qanet_encoder",
"input_dim": 128,
"hidden_dim": 128,
"attention_projection_dim": 128,
"feedforward_hidden_dim": 128,
"num_blocks": 7,
"num_convs_per_block": 2,
"conv_kernel_size": 5,
"num_attention_heads": 8,
"dropout_prob": 0.1,
"layer_dropout_undecayed_prob": 0.1,
"attention_dropout_prob": 0
},
"dropout_prob": 0.1,
"regularizer": [
[
".*",
{
"type": "l2",
"alpha": 1e-07
}
]
]
},
"iterator": {
"type": "bucket",
"sorting_keys": [
[
"passage",
"num_tokens"
],
[
"question",
"num_tokens"
]
],
"batch_size": 25,
"max_instances_in_memory": 600
},
"trainer": {
"num_epochs": 50,
"grad_norm": 5,
"patience": 10,
"validation_metric": "+em",
"cuda_device": 0,
"optimizer": {
"type": "adam",
"lr": 0.001,
"betas": [
0.8,
0.999
],
"eps": 1e-07
},
"moving_average": {
"type": "exponential",
"decay": 0.9999
}
}
}