Code Monkey home page Code Monkey logo

rgat-absa's Introduction

Investigating Typed Syntactic Dependencies for Targeted Sentiment Classification Using Graph Attention Neural Network

This repository contains the code for the paper "Investigating Typed Syntactic Dependencies for Targeted Sentiment Classification Using Graph Attention Neural Network", IEEE/ACM Transactions on Audio, Speech, and Language Processing (TASLP)

Setup

This code runs Python 3.6 with the following libraries:

  • Pytorch 1.2.0
  • Transformers 2.9.1
  • GTX 1080 Ti

You can also create an virtual environments with conda by run

conda env create -f requirements.yaml

Get start

  1. Prepare data

    • Restaurants, Laptop, Tweets and MAMS dataset. (We provide the parsed data at directory dataset)

    • Downloading Glove embeddings (available at here), then run

      awk '{print $1}' glove.840B.300d.txt > glove_words.txt
      

      to get glove_words.txt.

  2. Build vocabulary

    bash build_vocab.sh
    
  3. Training

    Go to Corresponding directory and run scripts:

    bash run-MAMS-glove.sh
    bash run-MAMS-BERT.sh
    
  4. The saved model and training logs will be stored at directory saved_models

  5. Evaluating trained models (optional)

    bash eval.sh path/to/check_point path/to/dataset
    bash eval-BERT.sh path/to/check_point path/to/dataset
    

Results

GloVe-based Model

Setting Acc F1 Log Pretrained model
Res14 83.55 75.99 log model
Laptop 78.02 74.00 log model
Tweets 75.37 74.15 log model
MAMS 82.02 80.99 log model

BERT-based Model

Setting Acc F1 Log Pretrained model
Res14 86.68 80.92 log model
Laptop 82.34 78.94 log model
Tweets 76.28 75.41 log model
MAMS 84.52 83.74 log model

References

@ARTICLE{bai21syntax,  
	author={Xuefeng Bai and Pengbo Liu and Yue Zhang},  
	journal={IEEE/ACM Transactions on Audio, Speech, and Language Processing},   
	title={Investigating Typed Syntactic Dependencies for Targeted Sentiment Classification Using Graph Attention Neural Network},   
	year={2021},  
	volume={29}, 
	pages={503-514},  
	doi={10.1109/TASLP.2020.3042009}
}

rgat-absa's People

Contributors

goodbai-nlp avatar pengboliu 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  avatar  avatar

rgat-absa's Issues

about label_matrix

作者您好,关于
https://github.com/muyeby/RGAT-ABSA/blob/4c63891fa8eeda582b57629949b99aa9ff68d82f/common/tree.py#L8中的head_to_adj方法,我理解是为了生成两个矩阵,其中adj_matrix是一个0/1矩阵,代表token与token之间是否连通(其中token自身存在的自环边也置为1),另一个label_matrix是一个0/n矩阵(n < deprel_vocab_size),代表token与token之间的delrel_stoi,不知道我的理解是否正确呢?如果我的理解有误,还请您指明,谢谢啦~
如果我的理解是对的,那我有一个疑问,就是该文件的第35行:
label_matrix[idx, idx] = 2
为什么对label_matrix添加自环边时,对应的delrel_stoi为2呢?我查看了RGAT-ABSA/prepare_vocab.py 文件中的第62行:
dep_vocab = Vocab(dep_counter, specials=["", "", ""])
如果按照specials的顺序(0、 1、 2、),那么label_matrix[idx, idx] = 2不就代表自环边对应的label是了吗?也就是说,我认为对label_matrix添加自环边时,应该将主对角线赋值为在vocab中的index,不知道我的理解是否有误呢?
烦请作者解答我的疑惑,谢谢啦~

glove_words.txt

作者您好,祝您新年快乐,请问您的代码中glove_words.txt在哪里能下载呢?如有打扰,非常抱歉,祝您生活愉快!

how to prove orthogonal?

As you mentioned in your article,
"Our method is orthogonal to the implicit use of knowledge in BERT, and can be combined with contextualized embeddings."

How could you prove that these two are orthogonal? 😁

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.