1. 克隆Bert并获取预训练模型
$ git clone https://github.com/google-research/bert.git
依赖和环境:
- Tensorflow-gpu version 1.15 (不建议使用TF2)
- Python version: 3.7
- CUDA Version: 10.2
- 预训练模型: https://github.com/google-research/bert
2. 改写自己的分类器读写函数
run_classifier.py
class MyProcessor(DataProcessor):
"""Processor for the my data set."""
def get_train_examples(self, data_dir):
"""See base class."""
return self._create_examples(
self._read_tsv(os.path.join(data_dir, "train.tsv")), "train")
def get_dev_examples(self, data_dir):
"""See base class."""
return self._cre