Giter Site home page Giter Site logo

trellixvulnteam / bert-chinese-shorttext-classification_pk2c Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yanghan-morningstar/bert-chinese-shorttext-classification

0.0 0.0 0.0 2.84 MB

基于Bert、Pytorch的中文短文本分类任务

Python 100.00%

bert-chinese-shorttext-classification_pk2c's Introduction

Bert-Chinese-ShortText-Classification

一、简介

基于Bert的中文短文本分类,通过Pytorch深度学习框架实现,采取fine-tuning的策略,在Bert模型(ERNIE模型)后接入CNN、RNN、RCNN、DPCNN等模型(其他仓库中所实现的上述模型大部分多少与论文中的结构有所出入,如RCNN,本仓库所实现的模型除少部分超参数外均与原论文相同),附带数据集为取自THUCNews新闻数据集的65000条新闻数据。

二、说明

2.1 模型效果

  • 当选择Bert作为预训练词向量模型时,直接接全连接层和接更加复杂的深度学习模型在最终测试集f1-score相差不超过2%。后续模型不变,预词向量模型更换为ERNIE后提升4%~5%。

  • 部分模型的训练、验证、测试如下图所示

  • BertCNN

  • BertRNN

  • ERNIE-Base

2.2 数据介绍

  • THUCNews数据集的一个真子集,分为体育、娱乐、家居、房产、教育、时尚、时政、游戏、科技、财经十类。
  • 训练集:50000条,验证集:5000条,测试集:10000条。

2.3 论文

  • Bert:Pre-training of Deep Bidirectional Transformers for Language Understanding
  • ERNIE:Enhanced Representation through Knowledge Integration
  • TextCNN:Convolutional Neural Networks for Sentence Classification
  • TextRCNN:Recurrent Convolutional Neural Networks for Text Classification
  • TextDPCNN:Deep Pyramid Convolutional Neural Networks for Text Categorization

2.4 使用

  • Models文件下存储模型的py文件,每个文件中都有一个Config类,用于初始化数据路径、预训练模型路径等。
  • 使用之前需要将数据集、预训练文件放在相应目录下,详情请看cnews、bert_pretrain、ERNIE_pretrain下的readme。
  • 直接使用命令CUDA_VISIBLE_DEVICES=0 python main.py --model="模型所在的py文件名,如bert_base"即可开始训练。

bert-chinese-shorttext-classification_pk2c's People

Contributors

trellixvulnteam avatar yanghan-morningstar 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.