GithubHelp home page GithubHelp logo

dheeraj7596 / conwea Goto Github PK

View Code? Open in Web Editor NEW
50.0 3.0 21.0 29.79 MB

Code for the paper "Contextualized Weak Supervision for Text Classification"

License: MIT License

Python 100.00%
weakly-supervised-learning contextualized-representation contextualized-programming text-classification natural-language-processing datamining acl2020 acl

conwea's Introduction

ConWea: Contextualized Weak Supervision for Text Classification

Model

CONWEA-Framework

Training

Required inputs

Each Dataset should contain following files:

  • DataFrame pickle file
    • Example: data/nyt/coarse/df.pkl
      • This dataset should contain two columns named sentence, label
      • sentence contains text and label contains its corresponding label.
      • Must be named as df.pkl
  • Seed Words Json file
    • Example: data/nyt/coarse/seedwords.json
      • This json file contains seed words list for each label.
      • Must be named as seedwords.json

Commands

Corpus Contextualization:

The contextualize.py requires three arguments: dataset_path, which is a path to dataset containing required DataFrame and seedwords, temp_dir is a path to a temporary directory which is used for dumping intermediate files during contextualizing the corpus, and gpu_id refers to the id of the gpu. If not mentioned, the process runs on cpu. To contextualize the corpus, please run:

$ python contextualize.py --dataset_path dataset_path --temp_dir temp_dir_path --gpu_id 3

The tests/test_contextualize.py is a unittest to check the sanity of contextualization. To run this unittest, please execute:

$ python -m unittest tests/test_contextualize.py

ConWea - Iterative Framework:

The train.py requires two arguments: dataset_path, which is a path to dataset containing required contextualized corpus DataFrame dumped by contextualize.py and seed words, and gpu_id refers to the id of the gpu. If not mentioned, the process runs on cpu. To train ConWea, please run:

$ python train.py --dataset_path dataset_path --gpu_id 3

The tests/test_conwea.py is a unittest to check the sanity of framework. To run this unittest, please execute:

$ python -m unittest tests/test_conwea.py

Requirements

This project is based on python==3.7. The dependencies are as follow:

keras-contrib==2.0.8
scikit-learn==0.21.3
flair==0.4.4
scipy=1.3.1
gensim==3.8.1
numpy==1.17.2

Citation

@inproceedings{mekala-shang-2020-contextualized,
    title = "Contextualized Weak Supervision for Text Classification",
    author = "Mekala, Dheeraj  and
      Shang, Jingbo",
    booktitle = "Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics",
    month = jul,
    year = "2020",
    address = "Online",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/2020.acl-main.30",
    pages = "323--333",
    abstract = "Weakly supervised text classification based on a few user-provided seed words has recently attracted much attention from researchers. Existing methods mainly generate pseudo-labels in a context-free manner (e.g., string matching), therefore, the ambiguous, context-dependent nature of human language has been long overlooked. In this paper, we propose a novel framework ConWea, providing contextualized weak supervision for text classification. Specifically, we leverage contextualized representations of word occurrences and seed word information to automatically differentiate multiple interpretations of the same word, and thus create a contextualized corpus. This contextualized corpus is further utilized to train the classifier and expand seed words in an iterative manner. This process not only adds new contextualized, highly label-indicative keywords but also disambiguates initial seed words, making our weak supervision fully contextualized. Extensive experiments and case studies on real-world datasets demonstrate the necessity and significant advantages of using contextualized weak supervision, especially when the class labels are fine-grained.",
}

conwea's People

Contributors

dheeraj7596 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

Watchers

 avatar  avatar  avatar

conwea's Issues

contextualize.py takes long time and never stop

It runs for more than 5 hours, and keep running with info "Finished clustering words: 114100", how long will it cost to stop?

my command is python contextualize.py --dataset_path ./data/nyt/fine/ --temp_dir /content/tmp/ --gpu_id 0

4 core cpu with P100 16G

About seedwords expand

Thanks for the article, it inspired me a lot!I have a question about seedwords expand ...
When I see the code :

n1 = 5
n = min(n1 * (it), int(math.log(len(label_docs_dict[index_to_label[l]]), 1.5)))

There seems to be no explanation in the paper,I want to know why it is set up in this way.

Some question about data spilt.

Hello, I took a look at the code, it seems that you only split all the data into train/val and report the results on val, without using train/val/test settting and report the results on test. Is that true?
Thank you.

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.