Code Monkey home page Code Monkey logo

2019-bdci-financialentitydiscovery's Introduction

本代码是复赛A榜第七,B榜第五

环境

  • Python3.6
  • Pytorch 1.1.0
  • Titan V100 32G
  • pytorch_transformers

方案介绍

本代码采用了基于序列标注的实体识别和基于机器阅读理解的实体识别相结合的方式。

  • 基于序列标注的实体识别,基本结构是RoBERTa-wwm-ext(finetuned) + BiLSTM + CRF,同时拼接字特征

1

  • 基于机器阅读理解的实体识别,参考的是香侬科技的《A Unified MRC Framework for Named Entity Recognition》论文,并自己实现的,同时根据实际情况做了相应的改进。

2

具体细节可以参考我们的论文迎难而上-金融实体-说明论文

基于序列标注的实体识别

  1. 在初赛和复赛的数据上微调roberta模型(来自讯飞发布的RoBERTa-wwm-ext Chinese,下载地址,将微调的模型重命名为roberta_finetune_ab2并移动到当前目录下

2.为了和初赛代码兼容,将复赛的训练集和测试集重命名为Train_Data.csv和Test_Data.csv,并保证数据格式为UTF-8,LF结尾,放在round2_data目录下。

  1. 数据预处理:
bash scripts/create_data.sh

会在round2_inputs目录下生成训练、验证和测试集数据

  1. 训练NER模型:
bash scripts/train.sh

会在outputs目录下保存模型

  1. NER模型融合:
python merge_models.py roberta_ext_v25 best,step5000
  1. NER模型预测:
bash scripts/predict.sh
  1. NER模型后处理(需要保证submits目录存在):
python postprocess.py --crf_model=roberta_ext_v25

会在submits目录下生成roberta_ext_v25.csv 复赛A榜最终基础的模型是这个,分数是0.507

基于机器阅读理解的实体识别

  1. MRC数据预处理
bash scripts/create_mrc_data.sh
  1. 训练MRC:
bash scripts/train_mrc.sh
  1. MRC模型预测:
bash scripts/predict_mrc.sh
  1. 后处理:
python postprocess.py --crf_model=roberta_ext_m11

会在submits目录下生成roberta_ext_m11.csv

  1. 投票:
python vote_submits.py

生成11-21.csv文件作为最终结果

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.