Git Product home page Git Product logo

textclassificationbenchmark's Introduction

Text Classification Benchmark

A Benchmark of Text Classification in PyTorch

Motivation

We are trying to build a Benchmark for Text Classification including

Many Text Classification DataSet, including Sentiment/Topic Classfication, popular language(e.g. English and Chinese). Meanwhile, a basic word embedding is provided.

Implment many popular and state-of-art Models, especially in deep neural network.

Have done

We have done some dataset and models

Dataset done

  • IMDB
  • SST
  • Trec

Models done

  • FastText
  • BasicCNN (KimCNN,MultiLayerCNN, Multi-perspective CNN)
  • InceptionCNN
  • LSTM (BILSTM, StackLSTM)
  • LSTM with Attention (Self Attention / Quantum Attention)
  • Hybrids between CNN and RNN (RCNN, C-LSTM)
  • Transformer - Attention is all you need
  • ConS2S
  • Capsule
  • Quantum-inspired NN

Libary

You should have install these librarys

python3
torch
torchtext (optional)

Dataset

Dataset will be automatically configured in current path, or download manually your data in Dataset, step-by step.

including

Glove embeding
Sentiment classfication dataset IMDB

usage

Run in default setting

python main.py

CNN

python main.py --model cnn

LSTM

python main.py --model lstm

Road Map

  • Data preprossing framework
  • Models modules
  • Loss, Estimator and hyper-paramter tuning.
  • Test modules
  • More Dataset
  • More models

Organisation of the repository

The core of this repository is models and dataset.

  • dataloader/: loading all dataset such as IMDB, SST

  • models/: creating all models such as FastText, LSTM,CNN,Capsule,QuantumCNN ,Multi-Head Attention

  • opts.py: Parameter and config info.

  • utils.py: tools.

  • dataHelper: data helper

Contributor

Welcome your issues and contribution!!!

textclassificationbenchmark's People

Contributors

jaredwei01 avatar nirantk avatar rohan12345a avatar stefan-it avatar wabyking avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

textclassificationbenchmark's Issues

Saving and Loading saved models gives different results

Hi,
There is a serious problem in the current codebase. If you save a model then reload it in a DIFFERENT time (not the same execution of main.py) the accuracy is 50% on IMDB. As a sanity check if you save and reload in the execution of main.py then there is no problem. If I had to guess this is a dataloading problem where there is a mistmatch between the saved model and the newly loaded model in a second execution.

Add BERT benchmarks

Thanks for this repo. It could be very interesting to add the latest Google's BERT model that claims to be state-of-the-art in recent NLP tasks among them text classification. They have a classifier implementation to adapt, here some details.

ValueError: No objects to concatenate

屏幕截图 2024-07-02 174222

Sorry to interrupt, but when I run the main.py, I get an error message in the picture.
I use the cmd "python main.py --model lstm -- dataset imdb"
屏幕截图 2024-07-02 174509

Benchmark results in README

Hi, would it be possible for the authors to add the accuracy results that they're getting to the README? Right now I'm seeing numbers which are mid 80's for certain models when I know certain people have reported 89/90 with Deep Learning methods on IMDB.

I am so sad it's not use straight.

we I want use trec dataset to test ,it cant run ,and dataSet file cant find i have to said,it NOT friendly to me.I just want quickly iterator,IT waste my time.

Difference performance between the following results

Windows/Pytorch 0.3/Python3
linux/pytorch 0.2/Python2
Results on windows:
0 ieration 0 epoch with loss : 1.11731
0 ieration 100 epoch with loss : 0.95308
0 ieration 200 epoch with loss : 0.50708
0 ieration 300 epoch with loss : 0.75614
0 ieration with percision 0.8398
1 ieration 0 epoch with loss : 0.16429
1 ieration 100 epoch with loss : 0.10894
1 ieration 200 epoch with loss : 0.05845
1 ieration 300 epoch with loss : 0.34559
1 ieration with percision 0.8438
2 ieration 0 epoch with loss : 0.09230
2 ieration 100 epoch with loss : 0.01140
2 ieration 200 epoch with loss : 0.23463
2 ieration 300 epoch with loss : 0.00004
2 ieration with percision 0.8346
3 ieration 0 epoch with loss : 0.05743
3 ieration 100 epoch with loss : 0.40399
3 ieration 200 epoch with loss : 0.01134
3 ieration 300 epoch with loss : 0.30481
3 ieration with percision 0.8086
4 ieration 0 epoch with loss : 0.03121
4 ieration 100 epoch with loss : 0.00000
4 ieration 200 epoch with loss : 0.36847
4 ieration 300 epoch with loss : 0.07362
4 ieration with percision 0.7786
5 ieration 0 epoch with loss : 0.10139
5 ieration 100 epoch with loss : 0.02151
5 ieration 200 epoch with loss : 0.00000
5 ieration 300 epoch with loss : 0.00000
5 ieration with percision 0.8099

Linux results:
0 ieration 0 epoch with loss : 1.09381
0 ieration 100 epoch with loss : 0.69792
0 ieration 200 epoch with loss : 0.69200
0 ieration 300 epoch with loss : 0.67666
0 ieration with percision 0.6022
1 ieration 0 epoch with loss : 0.66189
1 ieration 100 epoch with loss : 0.61229
1 ieration 200 epoch with loss : 0.50442
1 ieration 300 epoch with loss : 0.48552
1 ieration with percision 0.7489
2 ieration 0 epoch with loss : 0.24260
2 ieration 100 epoch with loss : 0.14823
2 ieration 200 epoch with loss : 0.22468
2 ieration 300 epoch with loss : 0.27329
2 ieration with percision 0.6626
3 ieration 0 epoch with loss : 0.06171
3 ieration 100 epoch with loss : 0.05115
3 ieration 200 epoch with loss : 0.04176
3 ieration 300 epoch with loss : 0.03525
3 ieration with percision 0.6915
4 ieration 0 epoch with loss : 0.01683
4 ieration 100 epoch with loss : 0.01829
4 ieration 200 epoch with loss : 0.00905
4 ieration 300 epoch with loss : 0.02068
4 ieration with percision 0.6919
5 ieration 0 epoch with loss : 0.00466
5 ieration 100 epoch with loss : 0.00262
5 ieration 200 epoch with loss : 0.00331
5 ieration 300 epoch with loss : 0.00265
5 ieration with percision 0.6734
6 ieration 0 epoch with loss : 0.00100
6 ieration 100 epoch with loss : 0.00166
6 ieration 200 epoch with loss : 0.02555
6 ieration 300 epoch with loss : 0.00685
6 ieration with percision 0.6747
7 ieration 0 epoch with loss : 0.00118
7 ieration 100 epoch with loss : 0.00065
7 ieration 200 epoch with loss : 0.00031
7 ieration 300 epoch with loss : 0.00016
7 ieration with percision 0.6703
8 ieration 0 epoch with loss : 0.00030
8 ieration 100 epoch with loss : 0.00029
8 ieration 200 epoch with loss : 0.00029
8 ieration 300 epoch with loss : 0.00006
8 ieration with percision 0.6694
9 ieration 0 epoch with loss : 0.00016
9 ieration 100 epoch with loss : 0.00093
9 ieration 200 epoch with loss : 0.00020
9 ieration 300 epoch with loss :

Automatically download embeddings

Hi,

thanks creating this text classification benchmark!

I wanted to run the basic example python3 main.py --model cnn and I could see that the GloVe embeddings were not downloaded automatically.

The dataHelper.loadData(opt) never calls the Glove constructor, so the embeddings won't be downloaded. But when I change from_torchtext = False to from_torchtext = True the utils.loadData(opt) method calls the Glove constructor.

I guess calling the Glove constructor would be enough to call it before the glove_file declaration (from here)?

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.