GithubHelp home page GithubHelp logo

lion's Introduction

Lion

Text pair classification toolkit.

Usage

Preprocessing:

  1. Transform the dataset to the standard formation . We currently support snli, qnli and quoraqp. Please write your own transformation scripts for other dataset.
    python lion/data/dataset_utils/quoraqp.py convert-dataset --indir INDIR --outdir OUTDIR

  2. Preprocess the dataset.
    python lion/data/processor.py process-dataset --in_dir IN_DIR --out_dir OUT_DIR --splits ['train'|'dev'|'test'] --tokenizer_name [spacy/bert/xlnet] --vocab_file FILE_PATH --max_length SEQUENCE_LENGTH

Training:

  1. Create a directory for saving model and put the config file in it .
  2. Edit the config file, modifying the train file and dev file path .
  3. Run lion/training/trainer.py
    For example:
    python lion/training/trainer.py --train --output_dir experiments/QQP/esim/ .

Hyper-parameter searching

  1. Create a directory for saving model and put the config file in it .
  2. Edit the config file, modifying the train file and dev file path .
  3. Edit the tuned_params.yaml For example:
hidden_size:
    - 100
    - 200
    - 300
dropout:
    - 0.1
    - 0.2
  1. Run python lion/training/search_parameter.py --parent_dir experiments/QQP/esim/hidden_dim/

Evaluation:

python lion/training/trainer.py --evaluate --output_dir experiments/QQP/esim/ --dev_file your_dev_path

Testing:

python lion/training/trainer.py --predict --output_dir experiments/QQP/esim/ --test_file your_test_file

Models

Model Quora QP SNLI QNLI
BiMPM 86.9 86.0 80.5
Esim 88.4 87.4 81.4
BERT 91.3 91.1 91.7
XLNET 91.5 91.6 91.9

Note: All the performance in the above table is tested on the dev set. The hyperparameter we used for these models are all in the experiments/DATASET/MODEL directory.

How to use ELMO

Just write this in your config file: use_elmo: concat or only and remember to set the word_dim correctly. For example if you use ELMO embedding only, set the word_dim: 1024 or set the word_dim: 1324 if you use ELMO and GLove together.

License

Apache-2.0

lion's People

Contributors

albert-ma avatar lixinsu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

lion's Issues

[dataset error]

Traceback (most recent call last):
File "lion/training/trainer.py", line 33, in
train_model('lion/configs/test_bimpm_1.yaml')
File "lion/training/trainer.py", line 25, in train_model
model.train_epoch(train_loader)
File "/home/fanyixing/users/mxy/lion/lion/training/model.py", line 85, in train_epoch
for ex in tqdm(data_loader):
File "/home/fanyixing/users/wangsu/anaconda3/envs/pytorch/lib/python3.6/site-packages/tqdm/_tqdm.py", line 979, in iter
for obj in iterable:
File "/home/fanyixing/users/wangsu/anaconda3/envs/pytorch/lib/python3.6/site-packa
ges/torch/utils/data/dataloader.py", line 336, in next
return self._process_next_batch(batch)
File "/home/fanyixing/users/wangsu/anaconda3/envs/pytorch/lib/python3.6/site-packa
ges/torch/utils/data/dataloader.py", line 357, in _process_next_batch
raise batch.exc_type(batch.exc_msg)

TypeError: Traceback (most recent call last):
File "/home/fanyixing/users/wangsu/anaconda3/envs/pytorch/lib/python3.6/site-packa
ges/torch/utils/data/dataloader.py", line 106, in worker_loop
samples = collate_fn([dataset[i] for i in batch_indices])
File "/home/fanyixing/users/wangsu/anaconda3/envs/pytorch/lib/python3.6/site-packa
ges/torch/utils/data/dataloader.py", line 106, in
samples = collate_fn([dataset[i] for i in batch_indices])
File "/home/fanyixing/users/mxy/lion/lion/data/dataset.py", line 26, in getitem
return self.vectorize(self.examples[index])
File "/home/fanyixing/users/mxy/lion/lion/data/dataset.py", line 56, in vectorize
Bchar = torch.LongTensor([make_char(char_dict, w) for w in ex['Btokens']])
File "/home/fanyixing/users/mxy/lion/lion/data/dataset.py", line 56, in
Bchar = torch.LongTensor([make_char(char_dict, w) for w in ex['Btokens']])
File "/home/fanyixing/users/mxy/lion/lion/data/dataset.py", line 48, in make_char
return [char_dict(t
) for t
in token[:8]] + [char_dict(t_) for t_ in token[-8:]]
File "/home/fanyixing/users/mxy/lion/lion/data/dataset.py", line 48, in │
return [char_dict(t_) for t_ in token[:8]] + [char_dict(t_) for t_ in token[-8:]]
TypeError: 'Dictionary' object is not callable

Add QNLI dataset

This dataset is smaller than both QQP and SNLI, it has only 10k training data. It's more convenient to first test model performance in this dataset.

add model

support ernie, xlnet, bert, roberta 中文

Feature/unify_mask

Now, esim and bmipm model use 1 mask value, but bert use 0 mask value.
Unify the mask mechanism which use 0 mask value, this is also consistent with tf.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.