Giter VIP home page Giter VIP logo

people_relation_extract's Introduction

  运行该项目的模型训练和模型预测脚本需要准备BERT中文版的模型数据,下载网址为:https://github.com/google-research/bert/blob/master/multilingual.md

  利用笔者自己收集的2959个样本,对人物关系抽取进行尝试。人物关系共分为14类,如下:

{
  "unknown": 0,
  "夫妻": 1,
  "父母": 2,
  "兄弟姐妹": 3,
  "上下级": 4,
  "师生": 5,
  "好友": 6,
  "同学": 7,
  "合作": 8,
  "同人": 9,
  "情侣": 10,
  "祖孙": 11,
  "同门": 12,
  "亲戚": 13
}

  人物关系类别频数分布条形图如下:

  模型结构: BERT + 双向GRU + Attention + FC

  模型训练效果:

# 训练集(train), loss: 0.0260, acc: 0.9941
# 最终测试集(test),  loss: 0.9505, acc: 0.7905
# 测试集上效果最好的,  loss: 0.8277, acc: 0.7956

  在测试集上的每一类的classification_report如下:

              precision    recall  f1-score   support

     unknown       0.72      0.77      0.75       159
          夫妻       0.82      0.79      0.81        58
          父母       0.84      0.91      0.87        99
        兄弟姐妹       0.81      0.84      0.82        25
         上下级       0.62      0.67      0.64        24
          师生       0.71      0.83      0.76        29
          好友       0.82      0.67      0.73        27
          同学       0.92      0.69      0.79        16
          合作       0.83      0.77      0.80        44
          同人       1.00      0.84      0.91        25
          情侣       0.79      0.79      0.79        19
          祖孙       0.76      0.62      0.68        21
          同门       0.91      0.88      0.89        24
          亲戚       0.83      0.68      0.75        22

   micro avg       0.79      0.79      0.79       592
   macro avg       0.81      0.77      0.79       592
weighted avg       0.80      0.79      0.79       592

  利用Chinese_wwm_ext + 双向GRU + Attention + FC模型,效果如下:

# 训练集(train), loss: 0.0248, acc: 0.9941
# 最终测试集(test),  loss: 0.8795, acc: 0.7956
# 测试集上效果最好的,  loss: 0.7603, acc: 0.8176

  在测试集上的每一类的classification_report如下:

              precision    recall  f1-score   support

     unknown       0.75      0.72      0.73       159
          夫妻       0.79      0.86      0.83        58
          父母       0.84      0.94      0.89        99
        兄弟姐妹       0.72      0.92      0.81        25
         上下级       0.74      0.71      0.72        24
          师生       0.75      0.83      0.79        29
          好友       0.86      0.70      0.78        27
          同学       0.73      0.69      0.71        16
          合作       0.80      0.75      0.78        44
          同人       1.00      0.88      0.94        25
          情侣       0.84      0.84      0.84        19
          祖孙       0.74      0.67      0.70        21
          同门       0.95      0.79      0.86        24
          亲戚       0.80      0.73      0.76        22

   micro avg       0.80      0.80      0.80       592
   macro avg       0.81      0.79      0.79       592
weighted avg       0.80      0.80      0.79       592

  模型预测:

原文: 润生#润叶#不过,他对润生的姐姐润叶倒怀有一种亲切的感情。
预测人物关系: 兄弟姐妹
原文: 孙玉厚#兰花#脑子里把前后村庄未嫁的女子一个个想过去,最后选定了双水村孙玉厚的大女子兰花。
预测人物关系: 父母
原文: 金波#田福堂#每天来回二十里路,与他一块上学的金波和大队书记田福堂的儿子润生都有自行车,只有他是两条腿走路。
预测人物关系: unknown
原文: 润生#田福堂#每天来回二十里路,与他一块上学的金波和大队书记田福堂的儿子润生都有自行车,只有他是两条腿走路。
预测人物关系: 父母
原文: 周山#李自成#周山原是李自成亲手提拔的将领,闯王对他十分信任,叫他担任中军。
预测人物关系: 上下级
原文: 高桂英#李自成#高桂英是李自成的结发妻子,今年才三十岁。
预测人物关系: 夫妻
原文: 罗斯福#特德#果然,此后罗斯福的政治旅程与长他24岁的特德叔叔如出一辙——纽约州议员、助理海军部长、纽约州州长以至美国总统。
预测人物关系: 亲戚
原文: 詹姆斯#克利夫兰#詹姆斯担任了该公司的经理,作为一名**党人,他曾资助过克利夫兰的再度竞选,两人私交不错。
预测人物关系: 上下级
原文: 高剑父#关山月#高剑父是关山月在艺术道路上非常重要的导师,同时关山月也是最能够贯彻高剑父“折中中西”理念的得意门生。
预测人物关系: 师生
原文: 唐怡莹#唐石霞#唐怡莹,姓他他拉氏,名为他他拉·怡莹,又名唐石霞,隶属于满洲镶红旗。
预测人物关系: 同人

  参考文章:

https://www.cnblogs.com/jclian91/p/12328570.html

people_relation_extract's People

Contributors

jclian91 avatar percent4 avatar

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.