码迷,mamicode.com
首页 > 其他好文 > 详细

chinese multiple class classification using BERT

时间:2019-02-25 18:43:28      阅读:579      评论:0      收藏:0      [点我收藏+]

标签:hub   code   info   span   follow   tcl   odi   download   search   

Steps:

  1. git clone https://github.com/google-research/bert
  2. prepare data, download pre-trained models
  3. modify code in run_classifier.py
    1. add a new processor

      技术图片

      ? ?

    2. add the processor in main function

      ? ?

      技术图片

? ?

Train and predict

  1. train

    python run_classifier.py

    --task_name=multiclass

    --do_train=true

    --do_eval=true

    --data_dir=/home/wxl/bertProject/bertTextClassification/data

    --vocab_file=/home/wxl/bertProject/chinese_L-12_H-768_A-12/vocab.txt

    --bert_config_file=/home/wxl/bertProject/chinese_L-12_H-768_A-12/bert_config.json

    --init_checkpoint=/home/wxl/bertProject/chinese_L-12_H-768_A-12/bert_model.ckpt

    --max_seq_length=128

    --train_batch_size=16

    --learning_rate=2e-5

    --num_train_epochs=100.0

    --output_dir=/home/wxl/bertProject/bertTextClassification/outputThree/

    ? ?

    you would get the following result if success:

    技术图片

    ? ?

    ? ?

    ? ?

  2. predict

    python run_classifier.py

    --task_name=multiclass

    --do_predict=true

    --data_dir=/home/wxl/bertProject/bertTextClassification/data

    --vocab_file=/home/wxl/bertProject/chinese_L-12_H-768_A-12/vocab.txt

    --bert_config_file=/home/wxl/bertProject/chinese_L-12_H-768_A-12/bert_config.json

    --init_checkpoint=/home/wxl/bertProject/bertTextClassification/outputThreeV1

    --max_seq_length=128

    --output_dir=/home/wxl/bertProject/bertTextClassification/mulitiPredictThreeV1/

    ? ?

? ?

chinese multiple class classification using BERT

标签:hub   code   info   span   follow   tcl   odi   download   search   

原文地址:https://www.cnblogs.com/wuxiangli/p/10432160.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!