Utilities to use allennlp with wandb
Project description
wandb-allennlp
Utilities and boilerplate code which allows using wandb to tune the hypereparameters for any AllenNLP model without a single line of extra code!
Status
Quick start
- Install the package
pip install wandb-allennlp
- Create your model using AllenNLP along with a training configuration file. For example:
{
"dataset_reader": {
"type": "snli",
"token_indexers": {
"tokens": {
"type": "single_id",
"lowercase_tokens": true
}
}
},
"train_data_path": std.extVar("DATA_PATH")+"/snli_1.0_test/snli_1.0_train.jsonl",
"validation_data_path": std.extVar("DATA_PATH")+ "/snli_1.0_test/snli_1.0_dev.jsonl",
"model": {
"type": "nli-seq2vec",
"input_size": 50,
"hidden_size": 50,
"rnn": "LSTM",
"num_layers": 1,
"bidirectional": true,
"projection_size": 50,
"debug": false
},
"iterator": {
"type": "bucket",
"sorting_keys": [["premise", "num_tokens"],
["hypothesis", "num_tokens"]],
"batch_size": 32
},
"trainer": {
"type":"callback",
"callbacks":[
{
"type": "validate"
},
{
"type": "checkpoint",
"checkpointer":{
"num_serialized_models_to_keep":1
}
},
{
"type": "track_metrics",
"patience": 10,
"validation_metric": "+accuracy"
},
{
"type": "log_metrics_to_wandb" ###### Don't forget to include this callback.
}
],
"optimizer": {
"type": "adam",
"lr":0.01,
"weight_decay": 0.01
},
"cuda_device": -1,
"num_epochs": 10,
"shuffle": true
}
}
- Create a sweep configuration file and generate a sweep on the wandb server. For example:
name: nli_lstm
program: wandb_allennlp
method: bayes
## Do not for get to use the command keyword to specify the following command structure
command:
- ${program} #omit the interpreter as we use allennlp train command directly
- "--subcommand=train"
- "--include-package=models" # add all packages containing your registered classes here
- "--config_file=configs/lstm_nli.jsonnet"
- ${args}
metric:
name: best_validation_accuracy
goal: maximize
parameters:
# hyperparameters start with overrides
# Ranges
model.input_size:
min: 100
max: 500
distribution: q_uniform
model.hidden_size:
min: 100
max: 500
distribution: q_uniform
model.projection_size:
min: 50
max: 1000
distribution: q_uniform
model.num_layers:
values: [1,2,3]
model.bidirectional:
value: "true"
trainer.optimizer.lr:
min: -7.0
max: 0
distribution: log_uniform
trainer.optimizer.weight_decay:
min: -12.0
max: -5.0
distribution: log_uniform
model.type:
value: nli-lstm
- Set the necessary environment variables.
export DATA_DIR=./data
- Start the search agents.
wandb agent <sweep_id>
For detailed instructions and example see this tutorial.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
wandb_allennlp-0.1.0.tar.gz
(7.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wandb_allennlp-0.1.0.tar.gz.
File metadata
- Download URL: wandb_allennlp-0.1.0.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
90a93f615a1ee8843058ad3d6e76c4d7890d9a5ca603aa03f8a81cf9cbb19752
|
|
| MD5 |
8e45891818bdecc91a53a3e00ad74763
|
|
| BLAKE2b-256 |
01d0151b3429991533673362e668f76c582f9197130262086105f2a10a2413e8
|
File details
Details for the file wandb_allennlp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: wandb_allennlp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7fa316ffab1c2bf18261879cb0fc117f11999d406448adfc12b0b1b9e8cb597
|
|
| MD5 |
0f51a6e8607d0c96b60753cfc66e6681
|
|
| BLAKE2b-256 |
771bd42b04ddc4ee797eda2492b366e897b38ebaf50617e743c2d70b97c0bb33
|