Giter Club home page Giter Club logo

text-mining_assignment's Introduction

Package Requirements

Python 3.8 Before runing the code, you need to install the following packages:

pip install -r requirements.txt

Data and model preparation

Please download the data from Google Drive and put it in the ./data folder. The data can be downloaded from here

Please download the model weights from Google Drive and put it in the ./checkpoint folder. The model weights can be downloaded from here

Run the code

This project data provide two updated methods of LSTM and BERT. You can follow the instructions below to train, test and predict via run ./main.py. There are four arguments you can use for main.py:

  • --model: the model you want to use, you can choose from LSTM_UP, LSTM and BERT
  • --need_generate_data: whether you want to generate the data, you can choose from True and False
  • --run_type: the mode you want to use, you can choose from train, test and predict
  • --device: the device you want to use, you can choose from cpu, cuda and mps

For --model, you can choose LSTM_UP to use the updated version of LSTM model, LSTM to use the original version of LSTM model, and BERT to use the updated version of BERT model.

Typically, the data we provided in Googl Drive has been preprocessed, so you can set --need_generate_data to False or ignore this argument.

For example, if you want to train the LSTM model on GPU, you can run the following command:

python main.py --model LSTM --run_type train --device cuda

If you want to train the BERT model on MPS and generate the data in advance, you can run the following command:

python main.py --model BERT --need_generate_data True --run_type train --device mps

If you want to test the BERT model on CPU, you can run the following command:

python main.py --model BERT --run_type test --device cpu

If you want to predict the LSTM model on MPS, you can run the following command:

python main.py --model LSTM --run_type predict --device mps

When you run predict mode, you will be required to input the sentence you want to predict. After you input the sentence, the model will print the prediction result. In prediction result, r is the Relation Extraction result.

Possible issues

  • If you meet issues with ***.npy file not found or ***.json file not found, please run main.py with parameter --need_generate_data True to generate the data in advance.
  • Because of test set is big, it may take a long time and more memory to test the model.

Short Paper

Short paper of this project can be found in ./paper folder as latex format and the PDF format.

Acknowledgement

These code are based on the following repositories:

text-mining_assignment's People

Contributors

mvp-evan avatar 974187271 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.