Bert Multi Label Text Classification
1.0.0
이 repo에는 다 레이블 텍스트 분류를위한 사전 배치 된 버트 및 XLNET 모델의 Pytorch 구현이 포함되어 있습니다.
프로젝트의 근원에서 다음을 볼 수 있습니다.
├── pybert
| └── callback
| | └── lrscheduler.py
| | └── trainingmonitor.py
| | └── ...
| └── config
| | └── basic_config.py #a configuration file for storing model parameters
| └── dataset
| └── io
| | └── dataset.py
| | └── data_transformer.py
| └── model
| | └── nn
| | └── pretrain
| └── output #save the ouput of model
| └── preprocessing #text preprocessing
| └── train #used for training a model
| | └── trainer.py
| | └── ...
| └── common # a set of utility functions
├── run_bert.py
├── run_xlnet.py
사전 배치 된 버트 모델과 XLNET 모델을 다운로드해야합니다.
Bert : Bert-base-incased
xlnet : xlnet-base-cased
S3에서 Bert Pretrated Model을 다운로드하십시오
S3에서 Bert 구성 파일을 다운로드하십시오
S3에서 Bert Vocab 파일을 다운로드하십시오
이름 바꾸기 :
bert-base-uncased-pytorch_model.bin to pytorch_model.binbert-base-uncased-config.json to config.jsonbert-base-uncased-vocab.txt to bert_vocab.txt model , config 및 vocab 파일을 /pybert/pretrain/bert/base-uncased 디렉토리에 배치하십시오.
pip install pytorch-transformers .
Kaggle 데이터를 다운로드하고 pybert/dataset 에서 배치하십시오.
io.task_data.py 수정하여 데이터를 조정할 수 있습니다. pybert/configs/basic_config.py 에서 구성 정보를 수정하십시오 (데이터 경로 ...).
python run_bert.py --do_data 전처리 데이터로 실행하십시오.
python run_bert.py --do_train --save_best --do_lower_case 미세 튜닝 버트 모델로 실행하십시오.
run_bert.py --do_test --do_lower_case run을 예측하십시오.
[training] 8511/8511 [>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] -0.8s/step- loss: 0.0640
training result:
[2019-01-14 04:01:05]: bert-multi-label trainer.py[line:176] INFO
Epoch: 2 - loss: 0.0338 - val_loss: 0.0373 - val_auc: 0.9922
- - - - train report every label - - - - -
Label : toxic - auc : 0.9903
Label : severe_toxic - auc : 0.9913
Label : obscene - auc : 0.9951
Label : threat - auc : 0.9898
Label : insult - auc : 0.9911
Label : identity_hate - auc : 0.9910
- - - - valid report every label - - - - -
Label : toxic - auc : 0.9892
Label : severe_toxic - auc : 0.9911
Label : obscene - auc : 0.9945
Label : threat - auc : 0.9955
Label : insult - auc : 0.9903
Label : identity_hate - auc : 0.9927