This repository has been archived by the owner on Dec 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Config file for fine-grained NER * RoBERTa based fine-grained NER * Need to specify input_dim * Adds the new fine-grained NER to the list of models * Changelog * Adds test for fine-grained NER
- Loading branch information
Showing
5 changed files
with
253 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
local data_dir = std.extVar("CONLL_DATA_PATH"); | ||
// local data_dir = "/net/nfs.corp/allennlp/dirkg/data/conll-formatted-ontonotes-5.0/data"; | ||
// local data_dir = "/Users/dirkg/Documents/data/conll-formatted-ontonotes-5.0/data"; | ||
|
||
local transformer_model = "roberta-base"; | ||
local transformer_hidden_dim = 768; | ||
local epochs = 3; | ||
local batch_size = 8; | ||
local max_length = 512; | ||
|
||
{ | ||
"dataset_reader": { | ||
"type": "ontonotes_ner", | ||
"coding_scheme": "BIOUL", | ||
"token_indexers": { | ||
"tokens": { | ||
"type": "pretrained_transformer_mismatched", | ||
"model_name": transformer_model, | ||
"max_length": max_length | ||
}, | ||
}, | ||
}, | ||
"train_data_path": data_dir + "/train", | ||
"validation_data_path": data_dir + "/development", | ||
"data_loader": { | ||
"batch_sampler": { | ||
"type": "bucket", | ||
"batch_size": batch_size | ||
} | ||
}, | ||
"model": { | ||
"type": "crf_tagger", | ||
"encoder": { | ||
"type": "pass_through", | ||
"input_dim": transformer_hidden_dim, | ||
}, | ||
"include_start_end_transitions": false, | ||
"label_encoding": "BIOUL", | ||
"text_field_embedder": { | ||
"token_embedders": { | ||
"tokens": { | ||
"type": "pretrained_transformer_mismatched", | ||
"model_name": transformer_model, | ||
"max_length": max_length | ||
} | ||
} | ||
}, | ||
"verbose_metrics": true | ||
}, | ||
"trainer": { | ||
"optimizer": { | ||
"type": "huggingface_adamw", | ||
"weight_decay": 0.0, | ||
"parameter_groups": [[["bias", "LayerNorm\\.weight", "layer_norm\\.weight"], {"weight_decay": 0}]], | ||
"lr": 1e-5, | ||
"eps": 1e-8 | ||
}, | ||
"learning_rate_scheduler": { | ||
"type": "slanted_triangular", | ||
"cut_frac": 0.05, | ||
}, | ||
"grad_norm": 1.0, | ||
"num_epochs": epochs, | ||
"cuda_device": -1, | ||
"validation_metric": "+f1-measure-overall" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
local data_dir = std.extVar("CONLL_DATA_PATH"); | ||
// local data_dir = "/net/nfs.corp/allennlp/dirkg/data/conll-formatted-ontonotes-5.0/data"; | ||
// local data_dir = "/Users/dirkg/Documents/data/conll-formatted-ontonotes-5.0/data"; | ||
|
||
{ | ||
"dataset_reader": { | ||
"type": "ontonotes_ner", | ||
"coding_scheme": "BIOUL", | ||
"token_indexers": { | ||
"elmo": { | ||
"type": "elmo_characters" | ||
}, | ||
"token_characters": { | ||
"type": "characters" | ||
}, | ||
"tokens": { | ||
"type": "single_id", | ||
"lowercase_tokens": true | ||
} | ||
} | ||
}, | ||
"train_data_path": data_dir + "/train", | ||
"validation_data_path": data_dir + "/development", | ||
"data_loader": { | ||
"batch_sampler": { | ||
"type": "bucket", | ||
"batch_size": 64 | ||
} | ||
}, | ||
"model": { | ||
"type": "crf_tagger", | ||
"dropout": 0.5, | ||
"encoder": { | ||
"type": "stacked_bidirectional_lstm", | ||
"hidden_size": 200, | ||
"input_size": 1202, | ||
"num_layers": 2, | ||
"recurrent_dropout_probability": 0.5, | ||
"use_highway": true | ||
}, | ||
"feedforward": { | ||
"activations": "tanh", | ||
"dropout": 0.5, | ||
"hidden_dims": 400, | ||
"input_dim": 400, | ||
"num_layers": 1 | ||
}, | ||
"include_start_end_transitions": false, | ||
"initializer": { | ||
"regexes": [ | ||
[ | ||
".*tag_projection_layer.*weight", | ||
{ | ||
"type": "xavier_uniform" | ||
} | ||
], | ||
[ | ||
".*tag_projection_layer.*bias", | ||
{ | ||
"type": "zero" | ||
} | ||
], | ||
[ | ||
".*feedforward.*weight", | ||
{ | ||
"type": "xavier_uniform" | ||
} | ||
], | ||
[ | ||
".*feedforward.*bias", | ||
{ | ||
"type": "zero" | ||
} | ||
], | ||
[ | ||
".*weight_ih.*", | ||
{ | ||
"type": "xavier_uniform" | ||
} | ||
], | ||
[ | ||
".*weight_hh.*", | ||
{ | ||
"type": "orthogonal" | ||
} | ||
], | ||
[ | ||
".*bias_ih.*", | ||
{ | ||
"type": "zero" | ||
} | ||
], | ||
[ | ||
".*bias_hh.*", | ||
{ | ||
"type": "lstm_hidden_bias" | ||
} | ||
] | ||
] | ||
}, | ||
"label_encoding": "BIOUL", | ||
"regularizer": { | ||
"regexes": [ | ||
[ | ||
"scalar_parameters", | ||
{ | ||
"alpha": 0.001, | ||
"type": "l2" | ||
} | ||
] | ||
] | ||
}, | ||
"text_field_embedder": { | ||
"token_embedders": { | ||
"elmo": { | ||
"type": "elmo_token_embedder", | ||
"do_layer_norm": false, | ||
"dropout": 0 | ||
}, | ||
"token_characters": { | ||
"type": "character_encoding", | ||
"embedding": { | ||
"embedding_dim": 25, | ||
"sparse": true, | ||
"vocab_namespace": "token_characters" | ||
}, | ||
"encoder": { | ||
"type": "lstm", | ||
"hidden_size": 128, | ||
"input_size": 25, | ||
"num_layers": 1 | ||
} | ||
}, | ||
"tokens": { | ||
"type": "embedding", | ||
"embedding_dim": 50, | ||
"pretrained_file": "https://allennlp.s3.amazonaws.com/datasets/glove/glove.6B.50d.txt.gz", | ||
"sparse": true, | ||
"trainable": true | ||
} | ||
} | ||
}, | ||
"verbose_metrics": true | ||
}, | ||
"trainer": { | ||
"cuda_device": -1, | ||
"grad_norm": 5, | ||
"num_epochs": 30, | ||
"optimizer": { | ||
"type": "dense_sparse_adam", | ||
"lr": 0.001 | ||
}, | ||
"patience": 25, | ||
"validation_metric": "+f1-measure-overall" | ||
} | ||
} |