Skip to content

Instantly share code, notes, and snippets.

@joelgrus
Created October 22, 2018 13:59
Show Gist options
  • Save joelgrus/885ef14323ff3d6ecefb84fa59c48039 to your computer and use it in GitHub Desktop.
Save joelgrus/885ef14323ff3d6ecefb84fa59c48039 to your computer and use it in GitHub Desktop.
config file for using the openai token embedder in allennlp
{
"dataset_reader": {
"type": "conll2003",
"token_indexers": {
"tokens": {
"type": "single_id",
"lowercase_tokens": true
},
"token_characters": {
"type": "characters"
},
"openai_transformer": {
"type": "openai_transformer_byte_pair",
"model_path": "https://s3-us-west-2.amazonaws.com/allennlp/models/openai-transformer-lm-2018.07.23.tar.gz"
}
}
},
"train_data_path": std.extVar("NER_TRAIN_DATA_PATH"),
"validation_data_path": std.extVar("NER_TEST_A_PATH"),
"test_data_path": std.extVar("NER_TEST_B_PATH"),
"evaluate_on_test": true,
"model": {
"type": "crf_tagger",
"constraint_type": "BIOUL",
"dropout": 0.5,
"include_start_end_transitions": false,
"text_field_embedder": {
"allow_unmatched_keys": true,
"embedder_to_indexer_map": {
"tokens": ["tokens"],
"token_characters": ["token_characters"],
"openai_transformer": ["openai_transformer", "openai_transformer-offsets"]
},
"token_embedders": {
"tokens": {
"type": "embedding",
"embedding_dim": 50,
"pretrained_file": "https://s3-us-west-2.amazonaws.com/allennlp/datasets/glove/glove.6B.50d.txt.gz",
"trainable": true
},
"openai_transformer": {
"type": "openai_transformer_embedder",
"transformer": {
"model_path": "https://s3-us-west-2.amazonaws.com/allennlp/models/openai-transformer-lm-2018.07.23.tar.gz"
}
},
"token_characters": {
"type": "character_encoding",
"embedding": {
"embedding_dim": 16
},
"encoder": {
"type": "cnn",
"embedding_dim": 16,
"num_filters": 128,
"ngram_filter_sizes": [3],
"conv_layer_activation": "relu"
}
}
}
},
"encoder": {
"type": "lstm",
"input_size": 946,
"hidden_size": 200,
"num_layers": 2,
"dropout": 0.5,
"bidirectional": true
},
"regularizer": [
[
"scalar_parameters",
{
"type": "l2",
"alpha": 0.1
}
]
]
},
"iterator": {
"type": "basic",
"batch_size": 64
},
"trainer": {
"optimizer": {
"type": "adam",
"lr": 0.001
},
"validation_metric": "+f1-measure-overall",
"num_serialized_models_to_keep": 3,
"num_epochs": 10,
"grad_norm": 5.0,
"patience": 25,
"cuda_device": 0
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment