如何训练预训练模型(BERT)?

时间:2020-03-24 03:17:15

标签: python machine-learning nlp

我想使用来自Google的经过预先训练的模型BERT创建近域问答系统。据我了解,首先,它需要在斯坦福问答数据库上训练模型。建立模型之后可以做出良好的预测。正确吗?

 !python bert/run_squad.py \
  --vocab_file=uncased_L-24_H-1024_A-16/vocab.txt \
  --bert_config_file=uncased_L-24_H-1024_A-16/bert_config.json \
  --init_checkpoint=uncased_L-24_H-1024_A-16/bert_model.ckpt \
  # after training this parameter is supposed to be turned off, is not it?
  --do_train=True \
  --train_file=train-v2.0.json \
  --do_predict=True \
  --predict_file=query.json \
  --train_batch_size=24 \
  --learning_rate=3e-5 \
  --num_train_epochs=2.0 \
  --max_seq_length=384 \
  --doc_stride=128 \
  --version_2_with_negative=True \
  --output_dir=/content

训练后的模型仍然很愚蠢。

{
"version": "v2.0",
"data": [
    {
        "title": "title",
        "paragraphs": [
            {
                "qas": [
                    {
                        "question": "When did war happen?",
                        "id": "1",
                        "is_impossible": ""
                    }
                ],
                "context": "War happened in 1939."                
             }
        ]
    }
]

}

最好的预测就是“战争”。

那么,如何为近域问答准备模型?我应该在自己的数据集而不是斯坦福数据集上训练它吗?

0 个答案:

没有答案