Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
50ff778
added model, sweep configs for the NER-SEAL_NCE runs
leejayyoon Nov 6, 2021
3c68483
Merge branch 'main' of github.com:dhruvdcoder/structured_prediction_b…
leejayyoon Nov 6, 2021
c758a45
adding model configs for running SEAL-NCE with NER (conll2003)
leejayyoon Nov 8, 2021
b8adfa2
merge conflict resolved
leejayyoon Nov 8, 2021
b3b8973
Added ner seal nce self_attention config
purujitgoyal Nov 10, 2021
1778abb
Merge branch 'main' of github.com:dhruvdcoder/structured_prediction_b…
leejayyoon Nov 12, 2021
d93a002
Merge branch 'main' of github.com:dhruvdcoder/structured_prediction_b…
purujitgoyal Nov 13, 2021
640930b
jsonnet additions
leejayyoon Dec 4, 2021
55f6b77
Merge branch 'dev/v1.2/jy' of github.com:dhruvdcoder/structured_predi…
purujitgoyal Dec 22, 2021
be4cbd2
Adds residual_x to seq-tag scorenn and corresponding parameter to con…
purujitgoyal Dec 29, 2021
d0749a9
merge conflict
Dec 29, 2021
feb0680
updates ontonotes seal nce bert config
Dec 29, 2021
aaa9f11
adds config for ontonotes seal with residual x
purujitgoyal Dec 29, 2021
164c129
adds grad accumulation steps
purujitgoyal Dec 31, 2021
7a21d42
variable name chanhges
purujitgoyal Jan 6, 2022
e3947de
Adds multi-task learning feature with shared tasknn (v1)
purujitgoyal Jan 9, 2022
5611b3f
fix omw test error
purujitgoyal Jan 9, 2022
6b2591b
Adds sweep for ner bilstm multi-task
purujitgoyal Jan 19, 2022
0f6ee54
corrects the config file name
purujitgoyal Jan 19, 2022
b2c0e24
Adds ner bilstm residual model config
purujitgoyal Jan 19, 2022
48807db
changes wrt to latest wandb version
purujitgoyal Jan 19, 2022
15ef24f
updates env variable names
purujitgoyal Jan 19, 2022
75f9ee4
updates env variable names
purujitgoyal Jan 19, 2022
21f97b5
Adds sweep config for ner bilstm residual
purujitgoyal Jan 20, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,240 @@
local test = std.extVar('TEST'); // a test run with small dataset
local data_dir = std.extVar('DATA_DIR');
local cuda_device = std.extVar('CUDA_DEVICE');
local use_wandb = (if test == '1' then false else true);

local dataset_name = 'bgc'; //std.parseJson(std.extVar('dataset_name'));
local dataset_metadata = (import '../datasets.jsonnet')[dataset_name];
local num_labels = dataset_metadata.num_labels;
local num_input_features = dataset_metadata.input_features;

// model variables
// // common
local ff_activation = 'softplus';
local gain = (if ff_activation == 'tanh' then 5 / 3 else 1);
local ff_linear_layers = 2;
local weight_decay = std.parseJson(std.extVar('weight_decay'));
local dropout = std.parseJson(std.extVar('dropout_10x')) / 10.0;

// // score_nn
local transformer_model = 'bert-base-uncased'; // huggingface name of the model
local transformer_dim = 768;
local transformer_vocab_size = 30522;
local score_nn_weight_decay = weight_decay;
local global_score_hidden_dim = std.parseJson(std.extVar('global_score_hidden_dim'));
local score_nn_dropout = dropout;
// // task_nn
local task_nn_dropout = dropout;
local task_nn_weight_decay = weight_decay;

// model variables
local gbi_lr = std.parseJson(std.extVar('gbi_lr'));
local gbi_optim = 'adam';

local feature_network = {
text_field_embedder: {
token_embedders: {
x: {
type: 'pretrained_transformer_with_adapter',
model_name: transformer_model,
},
},
},
seq2vec_encoder: {
type: 'bert_pooler',
pretrained_model: transformer_model,
},
final_dropout: 0,
feedforward: {
input_dim: transformer_dim,
num_layers: ff_linear_layers,
activations: ([ff_activation for i in std.range(0, ff_linear_layers - 2)] + [ff_activation]),
hidden_dims: ([transformer_dim * 2 for i in std.range(0, ff_linear_layers - 2)] + [transformer_dim]),
dropout: ([task_nn_dropout for i in std.range(0, ff_linear_layers - 2)] + [0]),
},
};

{
[if use_wandb then 'type']: 'train_test_log_to_wandb',
evaluate_on_test: true,
// Data
dataset_reader: {
type: 'bgc',
//[if test == '1' then 'max_instances']: 100,
token_indexers: {
x: {
type: 'pretrained_transformer',
model_name: transformer_model,
},
},
tokenizer: {
type: 'pretrained_transformer',
model_name: transformer_model,
max_length: 512,
},
},
train_data_path: (data_dir + '/' + dataset_metadata.dir_name + '/' +
dataset_metadata.train_file),
validation_data_path: (data_dir + '/' + dataset_metadata.dir_name + '/' +
dataset_metadata.validation_file),
test_data_path: (data_dir + '/' + dataset_metadata.dir_name + '/' +
dataset_metadata.test_file),

vocabulary: {
type: 'from_files',
directory: data_dir + '/' + dataset_metadata.dir_name + '/' + 'bert_vocab'
},
// Model
model: {
type: 'multi-label-classification',

sampler: {
type: 'appending-container',
log_key: 'sampler',
constituent_samplers: [
//GBI
{
type: 'gradient-based-inference',
log_key: 'gbi',
gradient_descent_loop: {
optimizer: {
lr: gbi_lr, //0.1
weight_decay: 0,
type: gbi_optim,
},
},
loss_fn: { type: 'multi-label-dvn-score', reduction: 'none', log_key: 'neg_dvn_score' }, //This loss can be different from the main loss // change this
output_space: { type: 'multi-label-relaxed', num_labels: num_labels, default_value: 0.0 },
stopping_criteria: 20,
sample_picker: { type: 'best' },
number_init_samples: 1,
random_mixing_in_init: 1.0,
},
// Adversarial
{
type: 'gradient-based-inference',
log_key: 'adv',
gradient_descent_loop: {
optimizer: {
lr: gbi_lr, //0.1
weight_decay: 0,
type: gbi_optim,
},
},
loss_fn: {
type: 'negative',
log_key: 'neg',
constituent_loss: { type: 'multi-label-dvn-bce', reduction: 'none', log_key: 'dvn_bce' },
reduction: 'none',
},
output_space: { type: 'multi-label-relaxed', num_labels: num_labels, default_value: 0.0 },
stopping_criteria: 20,
sample_picker: { type: 'best' },
number_init_samples: 1,
random_mixing_in_init: 1.0,
},

{ type: 'ground-truth' },
],
},
inference_module: {
type: 'gradient-based-inference',
log_key: 'inference',
gradient_descent_loop: {
optimizer: {
lr: gbi_lr, //0.1
weight_decay: 0,
type: gbi_optim,
},
},
loss_fn: { type: 'multi-label-dvn-score', reduction: 'none', log_key: 'neg_dvn_score' }, //This loss can be different from the main loss
output_space: { type: 'multi-label-relaxed', num_labels: num_labels, default_value: 0.0 },
stopping_criteria: 30,
sample_picker: { type: 'best' },
number_init_samples: 1,
random_mixing_in_init: 1.0,
},
oracle_value_function: { type: 'per-instance-f1', differentiable: false },
score_nn: {
type: 'multi-label-classification',
task_nn: {
type: 'multi-label-classification',
feature_network: feature_network,
label_embeddings: {
embedding_dim: transformer_dim,
vocab_namespace: 'labels',
},
},
global_score: {
type: 'multi-label-feedforward',
feedforward: {
input_dim: num_labels,
num_layers: 1,
activations: ff_activation,
hidden_dims: global_score_hidden_dim,
},
},
},
loss_fn: { type: 'multi-label-dvn-bce', log_key: 'dvn_bce' },
initializer: {
regexes: [
//[@'.*_feedforward._linear_layers.0.weight', {type: 'normal'}],
[@'.*_linear_layers.*weight', (if std.member(['tanh', 'sigmoid'], ff_activation) then { type: 'xavier_uniform', gain: gain } else { type: 'kaiming_uniform', nonlinearity: 'relu' })],
[@'.*linear_layers.*bias', { type: 'zero' }],
],
},
},
data_loader: {
batch_sampler: {
type: 'bucket',
batch_size: 16, // effective batch size = batch_size*num_gradient_accumulation_steps
sorting_keys: ['x'],
},
num_workers: 5,
max_instances_in_memory: if test == '1' then 10 else 1000,
start_method: 'spawn',
},
trainer: {
type: 'gradient_descent_minimax',
num_epochs: if test == '1' then 10 else 300,
grad_norm: { score_nn: 10.0 },
patience: 20,
validation_metric: '+fixed_f1',
cuda_device: std.parseInt(cuda_device),
learning_rate_schedulers: {
score_nn: {
type: 'reduce_on_plateau',
factor: 0.5,
mode: 'max',
patience: 5,
verbose: true,
},
},
optimizer: {
optimizers: {
score_nn: {
lr: 5e-5,
weight_decay: score_nn_weight_decay,
type: 'adamw',
},
},
},
checkpointer: {
keep_most_recent_by_count: 1,
},
callbacks: [
'track_epoch_callback',
'slurm',
] + (
if use_wandb then [
{
type: 'wandb_allennlp',
sub_callbacks: [{ type: 'log_best_validation_metrics', priority: 100 }],
},
]
else []
),
inner_mode: 'task_nn',
num_steps: { task_nn: 0, score_nn: 1 },
},
}
Loading