项目作者: AnthonyMRios

项目描述 :
Few- and Zero-shot Multi-Label Learning for Structured Label Spaces
高级语言: Python
项目地址: git://github.com/AnthonyMRios/multi-label-zero-shot.git
创建时间: 2018-08-24T20:51:37Z
项目社区:https://github.com/AnthonyMRios/multi-label-zero-shot

开源协议:

下载


Few-Shot and Zero-Shot Multi-Label Learning for Structured Label Spaces

Large multi-label datasets contain labels that occur thousands of times (frequent group), those that occur only a few times (few-shot group), and labels that never appear in the training dataset (zero-shot group). Multi-label few- and zero-shot label prediction is mostly unexplored on datasets with large label spaces, especially for text classification. In this repository, we have the code for our few- and zero-shot method for multilabel text classification when there is a known structure over the label space.

Note: Examples of the data format can be found in the “data” folder.

Required Packages

  • Python 2.7
  • numpy 1.11.1+
  • scipy 0.18.0+
  • Theano
  • gensim
  • sklearn
  • nltk

Also, you will need to have a set of pretrained embeddings. You can point to your embeddings by changing line 105 of load_data.py

Usage

Training

  1. python train.py --num_epochs 25 --word_vectors 'gensim_w2v_pubmed' --model_type cnn --train_data_X './data/train_data.json' --val_data_X './data/dev_data.json' --checkpoint_dir './checkpoints' --num_feat_maps 300 --grad_clip 3 --min_df 5 --lr 0.0001 --penalty 0.0000 --dropout 0.5 --lr_decay 0.0000 --cnn_conv_size 3 4 5 --checkpoint_name my_model_name
  1. usage: train_match.py [-h] [--num_epochs NUM_EPOCHS] [--num_models NUM_MODELS]
  2. [--word_vectors WORD_VECTORS] [--labels LABELS]
  3. [--checkpoint_dir CHECKPOINT_DIR]
  4. [--checkpoint_name CHECKPOINT_NAME]
  5. [--hidden_state HIDDEN_STATE]
  6. [--learn_embeddings LEARN_EMBEDDINGS] [--min_df MIN_DF]
  7. [--lr LR] [--penalty PENALTY] [--dropout DROPOUT]
  8. [--lr_decay LR_DECAY] [--minibatch_size MINIBATCH_SIZE]
  9. [--val_minibatch_size VAL_MINIBATCH_SIZE]
  10. [--model_type MODEL_TYPE] [--train_data_X TRAIN_DATA_X]
  11. [--val_data_X VAL_DATA_X] [--seed SEED]
  12. [--grad_clip GRAD_CLIP]
  13. [--cnn_conv_size CNN_CONV_SIZE [CNN_CONV_SIZE ...]]
  14. [--num_feat_maps NUM_FEAT_MAPS] [--num_att NUM_ATT]
  15. [--num_support NUM_SUPPORT]
  16. Train Neural Network.
  17. optional arguments:
  18. -h, --help show this help message and exit
  19. --num_epochs NUM_EPOCHS
  20. Number of updates to make.
  21. --num_models NUM_MODELS
  22. Number of updates to make.
  23. --word_vectors WORD_VECTORS
  24. Word vecotors filepath.
  25. --labels LABELS All Labels.
  26. --checkpoint_dir CHECKPOINT_DIR
  27. Checkpoint directory.
  28. --checkpoint_name CHECKPOINT_NAME
  29. Checkpoint File Name.
  30. --hidden_state HIDDEN_STATE
  31. hidden layer size.
  32. --learn_embeddings LEARN_EMBEDDINGS
  33. Learn Embedding Parameters.
  34. --min_df MIN_DF Min word count.
  35. --lr LR Learning Rate.
  36. --penalty PENALTY Regularization Parameter.
  37. --dropout DROPOUT Dropout Value.
  38. --lr_decay LR_DECAY Learning Rate Decay.
  39. --minibatch_size MINIBATCH_SIZE
  40. Mini-batch Size.
  41. --val_minibatch_size VAL_MINIBATCH_SIZE
  42. Val Mini-batch Size.
  43. --model_type MODEL_TYPE
  44. Neural Net Architecutre.
  45. --train_data_X TRAIN_DATA_X
  46. Training Data.
  47. --val_data_X VAL_DATA_X
  48. Validation Data.
  49. --seed SEED Random Seed.
  50. --grad_clip GRAD_CLIP
  51. Gradient Clip Value.
  52. --cnn_conv_size CNN_CONV_SIZE [CNN_CONV_SIZE ...]
  53. CNN Covolution Sizes (widths)
  54. --num_feat_maps NUM_FEAT_MAPS
  55. Number of CNN Feature Maps.
  56. --num_att NUM_ATT Number of Heads.
  57. --num_support NUM_SUPPORT
  58. Number nearest neighbors to sample for each input
  59. instance.

Acknowledgements

Anthony Rios and Ramakanth Kavuluru. “Few-Shot and Zero-Shot Multi-Label Learning for Structured Label Spaces”. EMNLP 2018

  1. @inproceedings{arios2018emrzero,
  2. title={Few-Shot and Zero-Shot Multi-Label Learning for Structured Label Spaces},
  3. author={Rios, Anthony and Kavuluru, Ramakanth},
  4. booktitle={Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing},
  5. year={2018}
  6. }

Written by Anthony Rios (anthonymrios at gmail dot com)