GithubHelp home page GithubHelp logo

sentimentimdb's Introduction

A demo for NLP sentiment by dataset imdb using pytorch framework
Rightnow, I just realize 7 models: lstm, gru, fasttext, cnn, bert, adbert, transformer_enc


#training command line for fasttext with max seq length=512
python main.py --train --model fast --model_path model_storage/model_fast.pth --tokenizer_dump_path model_storage/tokenizer_file.dmp --tokenizer spacy --embedding_size 100 -bs 64 -d /root/myfavor/nlp/.data/imdb/aclImdb
#testing command line for fasttext(0.877)
python main.py --test --model fast --load_model --model_path model_storage/model_fast.pth --tokenizer_dump_path model_storage/tokenizer_file.dmp --tokenizer spacy --embedding_size 100 -bs 64 -d /root/myfavor/nlp/.data/imdb/aclImdb

#with bert weights it can be to 0.884
python main.py --train --model fast --model_path model_storage/model_fast.pth --tokenizer_dump_path model_storage/tokenizer_file.dmp --tokenizer bert --embedding_size 768 -bs 64 -d /root/myfavor/nlp/.data/imdb/aclImdb
python main.py --test --model fast --load_model --model_path model_storage/model_fast.pth --tokenizer_dump_path model_storage/tokenizer_file.dmp --tokenizer bert --embedding_size 768 -bs 64 -d /root/myfavor/nlp/.data/imdb/aclImdb

#training command line for cnn classifier with max seq length=512
python main.py --train --model cnn --model_path model_storage/model_cnn.pth --tokenizer_dump_path model_storage/tokenizer_file.dmp --tokenizer spacy --embedding_size 100 --ff_hidden 256 -bs 64 -e 3 -d /root/data/aclImdb
#testing command line for cnn classifier(0.894)
python main.py --test --model cnn --load_model --model_path model_storage/model_cnn.pth --tokenizer_dump_path model_storage/tokenizer_file.dmp --tokenizer spacy --embedding_size 100 --ff_hidden 256 -bs 64 -d /root/data/aclImdb

#training command line lstm
python main.py --train --model lstm --model_path model_storage/model_lstm.pth --tokenizer_dump_path model_storage/tokenizer_file.dmp --tokenizer spacy --ff_hidden 256 --drop_out 0.5 -bs 128 --rnn_layers 2 -d /root/data/aclImdb --embedding_size 100
#testing command line for lstm(0.858)
python main.py --test --model lstm --load_model --model_path model_storage/model_lstm.pth --tokenizer spacy --embedding_size 100 --ff_hidden 256 -bs 64 --rnn_layers 2 -d /root/data/aclImdb

#training command line for gru
python main.py --train --model gru --model_path model_storage/model_gru.pth --tokenizer_dump_path model_storage/tokenizer_file.dmp --tokenizer spacy --ff_hidden 256 --drop_out 0.5 -bs 128 --rnn_layers 2 -d /root/data/aclImdb --embedding_size 100
#testing command line for gru(0.855)
python main.py --test --model gru --load_model --model_path model_storage/model_gru.pth --tokenizer spacy --embedding_size 100 --ff_hidden 256 -bs 64 --rnn_layers 2 -d /root/data/aclImdb


#use bert tokenizer & pretrained weights(with max seq lengths=512, batch_size=128)
python main.py --train --model bert --model_path model_storage/model_bert.pth --tokenizer_dump_path model_storage/tokenizer_file.dmp --tokenizer bert --embedding_size 768 --ff_hidden 256 --drop_out 0.25 -bs 128 --rnn_layers 2 -d /root/myfavor/nlp/.data -e 2
#testing command for bert(0.882)
python main.py --test --model bert --model_path model_storage/model_bert.pth --tokenizer_dump_path model_storage/tokenizer_file.dmp --tokenizer bert --embedding_size 768 --ff_hidden 256 --drop_out 0.25 -bs 128 --rnn_layers 2 -d /root/myfavor/nlp/.data

#use torchtext for adbert
python main.py --train --torchtext --model adbert --model_path model_storage/model_adbert.pth --tokenizer_dump_path model_storage/tokenizer_file.dmp --tokenizer adbert --embedding_size 768 --ff_hidden 256 --drop_out 0.25 -bs 128 --rnn_layers 2 -d /root/myfavor/nlp/.data -e 3
#testing command for adbert(0.922)
python main.py --test --torchtext --model adbert --load_model --model_path model_storage/model_adbert.pth --tokenizer_dump_path model_storage/tokenizer_file.dmp --tokenizer adbert --embedding_size 768 --ff_hidden 256 --drop_out 0.25 -bs 128 --rnn_layers 2 -d /root/myfavor/nlp/.data

#training command line for transformer_enc
python main.py --train --model transformer_enc --model_path model_storage/model_transformer_enc.pth --tokenizer_dump_path model_storage/tokenizer_file.dmp --tokenizer spacy --embedding_size 100 --drop_out 0.1 --cuda -e 4 --enc_layers 6 -d /root/myfavor/nlp/.data
python main.py --test --model transformer_enc --model_path model_storage/model_transformer_enc.pth --tokenizer_dump_path model_storage/tokenizer_file.dmp --tokenizer spacy --embedding_size 100 --drop_out 0.1 --cuda -e 4 --enc_layers 6 -d /root/myfavor/nlp/.data

sentimentimdb's People

Contributors

miaohua1982 avatar

Stargazers

 avatar

Watchers

 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.