Coder Social home page Coder Social logo

flat-ner's Introduction

English 中文

Flat-Lattice-Transformer

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.

Requirement:

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.

How to run the code?

  1. 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

  2. Modify the paths.py to add the pretrained embedding and the dataset

  3. 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.

Cite:

bibtex


运行环境:

Python: 3.7.3
PyTorch: 1.2.0
FastNLP: 0.5.0
Numpy: 1.16.4

你可以在 这里 深入了解 FastNLP 这个库.

如何运行?

  1. 请下载预训练的embedding

    Google DriveBaidu Pan 下载字和 Bigram 的 embedding (gigaword_chn.all.a2b.{'uni' or 'bi'}.ite50.vec)

    Google DriveBaidu Pan 下载词的 embedding (ctb.50d.vec)(yj)

    Baidu Pan 下载词的embedding (sgns.merge.bigram.bz2)(ls)

  2. 修改 paths.py 来添加预训练的 embedding 和你的数据集

  3. 运行下面的代码

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 这个工具

引用:

bibtex

flat-ner's People

Contributors

lawsonabs avatar leesureman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

flat-ner's Issues

未标记文本预测

你好,请问如何使用fastNLP在实体抽取中对未标记的文本进行预测?

V1 训练过程中,metric 突然大幅度下降,loss 大幅度升高

我在训练V1的版本时,20 epoch时准确率 95,但是 21 epoch时,准确率突然变成0,并且loss大幅度增加,请问是什么原因造成的呢.
我是在google colab上训练的.

Step:15300 {"metric": {"data_test": {"SpanFPreRecMetric": {"f": 0.940422, "pre": 0.936701, "rec": 0.944172}, "label_acc": {"acc": 0.954106}}}, "step": 15300, "epoch": 20} Step:16065 {"metric": {"SpanFPreRecMetric": {"f": 0.0, "pre": 0.0, "rec": 0.0}, "label_acc": {"acc": 0.263499}}, "step": 16065, "epoch": 21} Step:16065 {"metric": {"data_test": {"SpanFPreRecMetric": {"f": 0.0, "pre": 0.0, "rec": 0.0}, "label_acc": {"acc": 0.289205}}}, "step": 16065, "epoch": 21}

test结果

你好,最近在用这个代码,想请教一下如何得到test结果对应的标签呢

预测结果输出

我想使用fastNLP.core.predictor函数输出预测结果,但输出的value值为类似这种格式:{'pred': [array([[10, 14, 11, 2, 2, 2]])]},没有找到能直接输出文本结果的方法,请问作者有没有比较好的方法?

数据集请求

请问下能提供下数据集么?不是很清除里面的变化诶。。。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.