Coder Social home page Coder Social logo

asgcn's Introduction

ASGCN

ASGCN - Aspect-Specific Graph Convolutional Network

Updates

  • 11/11/2020: I introduce a new ASTCN model which contains a bidirectional graph convolutional network over directed dependency trees.
  • 10/5/2020: Many of you may be faced with reproducibility issue owing to corrupted word vectors when downloading (i.e., glove.840B.300d.txt is generally too large). Thus, we have released trimmed version of word embeddings on rest14 dataset as a pickled file along with vocabulary for you to verify the reproducibility.

Requirements

  • Python 3.6
  • PyTorch 1.0.0
  • SpaCy 2.0.18
  • numpy 1.15.4

Usage

  • Install SpaCy package and language models with
pip install spacy

and

python -m spacy download en
  • Generate graph data with
python dependency_graph.py
  • Download pretrained GloVe embeddings with this link and extract glove.840B.300d.txt into glove/.
  • Train with command, optional arguments could be found in train.py
python train.py --model_name asgcn --dataset rest14 --save True

Model

we propose to build a Graph Convolutional Network (GCN) over the dependency tree of a sentence to exploit syntactical information and word dependencies. Based on it, a novel aspectspecific sentiment classification framework is raised.

An overview of our proposed model is given below

model

Citation

If you use the code in your paper, please kindly star this repo and cite our paper

@inproceedings{zhang-etal-2019-aspect, 
    title = "Aspect-based Sentiment Classification with Aspect-specific Graph Convolutional Networks", 
    author = "Zhang, Chen and Li, Qiuchi and Song, Dawei", 
    booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP)", 
    month = nov, year = "2019", 
    address = "Hong Kong, China", 
    publisher = "Association for Computational Linguistics", 
    url = "https://www.aclweb.org/anthology/D19-1464", 
    doi = "10.18653/v1/D19-1464", 
    pages = "4560--4570",
} 

Credits

  • Code of this repo heavily relies on ABSA-PyTorch, in which I am one of the contributors.
  • For any issues or suggestions about this work, don't hesitate to create an issue or directly contact me via [email protected] !

asgcn's People

Contributors

genezc 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

asgcn's Issues

迭代三次模型,指标一次不如一次?

repeat: 1
max_test_acc: 0.887987012987013, max_test_f1: 0.7024944579664142
repeat: 2
max_test_acc: 0.887987012987013, max_test_f1: 0.6555064644327216
repeat: 3
max_test_acc: 0.8814935064935064, max_test_f1: 0.5690872648781992
max_test_acc_avg: 0.8858225108225107, max_test_f1_avg: 0.642362729092445
指标一次不如一次,请问最可能的原因是什么呢?

best model的选择

您好,在这份代码里,在训练过程选择模型的时候,好像没有用到验证集,而是直接每训练一次就在测试集上跑性能,根据测试集上的性能来决定模型什么时候停止训练,想问一下这样的方式是合理的吗,谢谢~

When I changed the network to "ASCNN", the following error appeared when running train.py, how to solve it?

When I changed the network to "ASCNN", the following error appeared when running train.py, how to solve it?

Traceback (most recent call last):
File "C:/Users/3403/PycharmProjects/ASGCN-master/train.py", line 226, in
ins.run()
File "C:/Users/3403/PycharmProjects/ASGCN-master/train.py", line 149, in run
max_test_acc, max_test_f1 = self._train(criterion, optimizer)
File "C:/Users/3403/PycharmProjects/ASGCN-master/train.py", line 74, in _train
outputs = self.model(inputs)
File "C:\Anaconda\Anaconda3\envs\pt\lib\site-packages\torch\nn\modules\module.py", line 550, in call
result = self.forward(*input, **kwargs)
File "C:\Users\3403\PycharmProjects\ASGCN-master\models\ascnn.py", line 84, in forward
x = F.relu(self.conv1(self.position_weight(text_out, aspect_double_idx, text_len, aspect_len).transpose(1, 2))) #whs
File "C:\Anaconda\Anaconda3\envs\pt\lib\site-packages\torch\nn\modules\module.py", line 550, in call
result = self.forward(*input, **kwargs)
File "C:\Anaconda\Anaconda3\envs\pt\lib\site-packages\torch\nn\modules\conv.py", line 208, in forward
self.padding, self.dilation, self.groups)
RuntimeError: Expected object of scalar type Double but got scalar type Float for argument #3 'mat1' in call to th_addmm

Process finished with exit code 1

模型分享请求

您的模型是基于GloVe的极限模型中非常出众的代表,我想请问您是否有兴趣将模型移植到https://github.com/yangheng95/PyABSA/tree/release/pyabsa/tasks/glove_apc/models 中,由于目前的有些ABSA仓库维护不及时、时常报错,所以我花了点时间构建了PyABSA,这个库主要目的是解决易用性的问题。然而由于精力不够在移植模型时出了一些问题。
请问您是否愿意将您的模型移植到PyABSA? 谢谢您,祝您生活愉快!

数据集中可能有一些错误

感谢作者提供的rest15和rest16的数据集,发现数据集中存在一些错误。很多句子中会出现$ t$这个符号,发生在句子中存在多个aspect的情况,我想可能是数据集处理代码的问题。我在本地进行了修改,但不确定是否引入了其他错误。大佬有时间的话可以看看

Formulation 5 in your paper

Dear @GeneZC ,
I am sorry for disturbing you, but I wonder about the formulation 5 about the function F() in your paper. You use this function for calculating the position-aware weight. I understand that when r+1 <= i <= r+m, q_i should be 1, instead of 0 as in your paper?
Thank you very much for your time!

关于损失函数的问题

请问您论文中的损失函数的c是数据集C中的每一个评论数据吗?p(hat)是每个c的实际标签?Pp(hat) 代表第p(hat)个对应的概率?也有可能是我翻译不准确的问题。其中您代码中用的是criterion = nn.CrossEntropyLoss(),这俩公式我没有搞清楚是不是一样的。

数据集相关问题

请问下有数据处理的代码?就是将原始XML数据处理为你仓库中数据格式的预处理代码。

dataset

你好,我想请问一下dataset里的数据是怎么转换为.raw的?有点搞不太懂唉

项目中的.graph文件和.tree文件

您好我想请问一下,项目中的.graph文件和.tree文件,0代表什么意思,1代表什么意思呢?.graph文件和.tree文件的区别是什么呢?

result

您好,我按照您的步骤跑了源代码,但是结果并没有达到论文里的标准。我使用的是您提供的这个命令python train.py --model_name asgcn --dataset rest14 --save True,在执行之前,下载了glove的数据集,其他的构造图我看您已经提供了,所以直接执行了上述这个命令,请问还有什么需要改的吗?如果您方便的话,希望可以回复一下,谢谢

How should I change the data?

I noticed that your work provides data such as .raw. If I want to replace it with my own related data set, what are the requirements? How should I replace other datasets?
Looking forward to your reply, thank you

关于源码中的.graph文件

你好,论文中提到了两个模型ASGCN-DG和ASGCN-DT,它们的不同在于拥有不同的邻接矩阵,dependency_graph.py应该是用于生成并存储邻接矩阵的,同时源码当中也提供了得到的邻接矩阵文件,laptop_test.raw.graph等,我想知道它们对应了ASGCN-DG还是ASGCN-DT。

生成图

作者您好,请问您生成依赖树图用的设备是什么的,我换了其他数据集,内存需求太大了。

输入模型的文本长度

请问为什么每次输入到模型中文本的长度均不一样,是否可以通过更改代码将每次输入模型的文本长度固定

如果可以的话,请问应该修改源码中的哪部分,如果很麻烦不用太具体告知,告诉我个大概范围我自己更改就行。

谢谢大佬的解答。

针对SemEval2014数据集的疑惑

请问用SemEval2014中的laptops,restaurants两个数据集,本文做的工作是SemEval2014 Task4中的subtask2吗?

就是针对Aspect term polarity的分类,而不是针对Aspect category polarity的分类?

谢谢您的解答。

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.