Giter Site home page Giter Site logo

pytorch_cosent's Introduction

PyTorch_CoSENT

简介

比Sentence-BERT更有效的句向量方案,复现苏神提出的CoSENT,模型细节可以参考苏神的文章:https://kexue.fm/archives/8847

数据下载

环境

pip install ark-nlp
pip install pandas

使用说明

项目目录按以下格式设置

│
├── data                                    # 数据文件夹
│   ├── source_datasets                     
│   ├── task_datasets           
│   └── output_datasets                           
│
├── checkpoint                              # 存放训练好的模型
│   ├── ...           
│   └── ...                                      
│
└── code                                    # 代码

下载数据并解压到data/source_datasets中,运行code文件夹中的.ipynb文件,最终提交文件会生成在data/output_datasets

参数设置

代码参数设置如下:

句子截断长度:64(PAWSX数据集截断长度为128)
batch_size:32
epochs:5

效果

使用spearman系数作为测评指标,ATEC、BQ、LCQMC和PAWSX使用test集进行测试实验,CHIP-STS则使用验证集

ATEC BQ LCQMC PAWSX CHIP-STS
BERT+CoSENT(ark-nlp) 49.80 72.46 79.00 59.17 76.22
BERT+CoSENT(bert4keras) 49.74 72.38 78.69 60.00
Sentence-BERT(bert4keras) 46.36 70.36 78.72 46.86

PS:上表ark-nlp展示的是5轮里最好的结果,由于没有深入了解bert4keras,所以设置参数可能还是存在差异,因此对比仅供参考

针对CHIP-STS测试数据集,选择阈值为0.6生成结果进行提交,结果如下:

Precision Recall Macro-F1
BERT+CoSENT 82.89 81.528 81.688
BERT句子对分类 84.331 83.799 83.924

Acknowledge

感谢苏神无私的分享

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.