-
Notifications
You must be signed in to change notification settings - Fork 33
/
transformer_cls.jsonnet
60 lines (58 loc) · 1.9 KB
/
transformer_cls.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
// 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");
// The hidden size of the model, which can be found in its config as "hidden_size".
local transformer_dim = std.parseInt(std.extVar("TRANSFORMER_DIM"));
// This will be used to set the max/min # of tokens in the positive and negative examples.
local max_length = 512;
// Certain transformers use the last special token in the sequence to produce sequence embeddings
// (e.g XLNet).
local cls_is_last_token = false;
{
"vocabulary": {
"type": "empty"
},
"dataset_reader": {
"type": "declutr",
"lazy": true,
"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,
"model": {
"type": "declutr",
"text_field_embedder": {
"type": "mlm",
"token_embedders": {
"tokens": {
"type": "pretrained_transformer_mlm",
"model_name": transformer_model,
"masked_language_modeling": true
},
},
},
"seq2vec_encoder": {
"type": "cls_pooler",
"embedding_dim": transformer_dim,
"cls_is_last_token": cls_is_last_token
},
},
"data_loader": {
"batch_size": 16,
"num_workers": 1,
"drop_last": true,
},
"trainer": {
"type": "no_op"
},
}