Neural_Sentiment_Analysis
在斯坦福情感树库上的情感分析任务的树木结构化LSTM和注意机制模型的实施
在此项目中,以下模型实现了:
- 线性LSTM模型(基线)
- 树结构化的LSTM模型从Kai Sheng Tai的论文中提到了参考,改善了树结构的长期记忆网络的语义表示。
- 树结构LSTM具有注意机制。
软件要求
- Pytorch深度学习库,用于实现神经模型
- Google的Tensorflow深度学习库用于神经模型的实施
- TQDM:显示进度栏
- java> = 8(对于斯坦福大学的实用程序,即斯坦福解析器)
- Python> = 3用于运行核心系统和基线
- Python 2.7用于运行预处理脚本
使用的开发和测试环境
- 操作系统:Macos Mojave和Ubuntu 18.04
- 处理器:英特尔i5 Quad Core
- RAM:8 GB DDR3
用法
首先运行脚本./fetch_and_preprocess.sh
这下载以下数据:
- 斯坦福情绪树库(情感分类任务)
- 手套词向量(常见爬网840b) –警告:这是2GB下载!
以及以下库:
- 斯坦福(Stanford Parser)
- 斯坦福POS Tagger
现在,使用cd ./baseline测试基线模型GoTO baseline目录并运行python3 baseline.py
用于测试树LSTM和注意机制的实现,请使用以下命令:
python3 sentiment.py --name <name_of_log_file> --model_name <constituency|dependency> --epochs 10 --attention_flag <True|False>
重要文件:
- baseline.py: Contains baseline implementation of Linear LSTM
- sentiment.py: Main driver file to run the system. We have changed the argument processing and model generation and processing flow
- trainer.py: This file implements training module. We have added the functionality to incorporate the trainig of the model with and without the attention mechanism.
- model.py: This file contains implementation of all the models. We implemented attention module and changed the implementation of Tree LSTM modules to sync with our requirements.
- config.py: This file contains configuration constants to control the nature of system. We added extra configuration parameters to this to control our system.
参考:
- 基线代码已从https://gith*u*b.co*m/adeshpande3/lstm-sentiment-analysis中引用
- 从https://g*i*thub.c*om/stanfordnlp/treelelstm/tree/master/master/models引用了树lstm的代码
执照
apache
