Giter VIP home page Giter VIP logo

bert_distill's Introduction

基于BERT的蒸馏实验

参考论文《Distilling Task-Specific Knowledge from BERT into Simple Neural Networks》

分别采用keras和pytorch基于textcnn和bilstm(gru)进行了实验

实验数据分割成 1(有标签训练):8(无标签训练):1(测试)

在情感2分类clothing的数据集上初步结果如下:

  • 小模型(textcnn & bilstm)准确率在 0.80 ~ 0.81

  • BERT模型 准确率在 0.90 ~ 0.91

  • 蒸馏模型 准确率在 0.87 ~ 0.88

实验结果与论文结论基本一致,与预期相符

后续将尝试其他更有效的蒸馏方案

使用方法

首先finetune BERT

python ptbert.py

然后把BERT的知识蒸馏到小模型里

需要先解压data/cache/word2vec.gz

然后

python distill.py

调整文件中的use_aug及以下的参数可以使用论文中提到的其中两种数据增强方式(masking, n-gram sampling)

bert_distill's People

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.