zoukankan      html  css  js  c++  java
  • 中文多分类 BERT

    直接把自己的工作文档导入的,由于是在外企工作,所以都是英文写的

    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/

         

       

  • 相关阅读:
    自动生成接口文档
    Haystack全文搜索
    redis操作
    缓存及跨域问题
    url控制器、解析器、响应器、分页器
    频率组件
    序列化、认证、权限、视图回顾
    认证、权限、视图组件
    序列化组件
    Rest Framework
  • 原文地址:https://www.cnblogs.com/wuxiangli/p/10432160.html
Copyright © 2011-2022 走看看