code for ACL 2020 paper: FLAT: Chinese NER Using Flat-Lattice Transformer.
Models and results can be found at our ACL 2020 paper FLAT: Chinese NER Using Flat-Lattice Transformer.
Python: 3.7.3
PyTorch: 1.2.0
FastNLP: 0.5.0
Numpy: 1.16.4
you can go here to know more about FastNLP.
-
Download the character embeddings and word embeddings.
Character and Bigram embeddings (gigaword_chn.all.a2b.{'uni' or 'bi'}.ite50.vec) : Google Drive or Baidu Pan
Word(Lattice) embeddings:
yj, (ctb.50d.vec) : Google Drive or Baidu Pan
ls, (sgns.merge.word.bz2) : Baidu Pan
-
Modify the
paths.py
to add the pretrained embedding and the dataset -
Run following commands
python preprocess.py (add '--clip_msra' if you need to train FLAT on MSRA NER dataset)
cd V0 (without Bert) / V1 (with Bert)
python flat_main.py --dataset <dataset_name> (ontonotes, msra, weibo or resume)
If you want to record experiment result, you can use fitlog:
pip install fitlog
fitlog init V0
cd V0
fitlog log logs
then set use_fitlog = True in flat_main.py.
you can go here to know more about Fitlog.
Python: 3.7.3
PyTorch: 1.2.0
FastNLP: 0.5.0
Numpy: 1.16.4
你可以在 这里 深入了解 FastNLP 这个库.
-
请下载预训练的embedding
从Google Drive 或 Baidu Pan 下载字和 Bigram 的 embedding (gigaword_chn.all.a2b.{'uni' or 'bi'}.ite50.vec)
从Google Drive 或 Baidu Pan 下载词的 embedding (ctb.50d.vec)(yj)
从Baidu Pan 下载词的embedding (sgns.merge.bigram.bz2)(ls)
-
修改
paths.py
来添加预训练的 embedding 和你的数据集 -
运行下面的代码
python preprocess.py (add '--clip_msra' if you need to train FLAT on MSRA NER dataset)
cd V0 (without Bert) / V1 (with Bert)
python flat_main.py --dataset <dataset_name> (ontonotes, msra, weibo or resume)
如果你想方便地记录和观察实验结果, 你可以使用fitlog:
pip install fitlog
fitlog init V0
cd V0
fitlog log logs
然后把flat_main.py里的 use_fitlog 设置为 True 就行 你可以在 这里 深入了解 Fitlog 这个工具