非官方的AMR解析程序包
unofficial-stog的Python项目详细描述
AMR解析作为序列到图的转换
这是以下研究论文的非正式文件包,仅供研究实验使用。在
AMR解析器的代码 在我们的ACL 2019论文“AMR Parsing as Sequence-to-Graph Transduction”中。在
如果您发现我们的代码有用,请引用:
@inproceedings{zhang-etal-2018-stog,
title = "{AMR Parsing as Sequence-to-Graph Transduction}",
author = "Zhang, Sheng and
Ma, Xutai and
Duh, Kevin and
Van Durme, Benjamin",
booktitle = "Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)",
month = jul,
year = "2019",
address = "Florence, Italy",
publisher = "Association for Computational Linguistics"
}
1。环境设置
该代码已经在^{str1}$python3.6和^{str1}$PyTorch 0.4.1上进行了测试。 所有其他依赖项都列在requirements.txt中。在
通过康达:
^{pr2}$2。资料准备
下载工件:
./scripts/download_artifacts.sh
假设您正在使用amr2.0(LDC2017T10),
将语料库解压缩到data/AMR/LDC2017T10
,并确保它具有以下结构:
(stog)$ tree data/AMR/LDC2017T10 -L 2 data/AMR/LDC2017T10 ├── data │ ├── alignments │ ├── amrs │ └── frames ├── docs │ ├── AMR-alignment-format.txt │ ├── amr-guidelines-v1.2.pdf │ ├── file.tbl │ ├── frameset.dtd │ ├── PropBank-unification-notes.txt │ └── README.txt └── index.html
准备培训/开发/测试数据:
./scripts/prepare_data.sh -v 2 -p data/AMR/LDC2017T10
3。特征注释
我们使用Stanford CoreNLP(版本3.9.2)进行词素化、词性标记等
首先,在API documentation后面启动一个CoreNLP服务器。在
然后,注释AMR句子:
./scripts/annotate_features.sh data/AMR/amr_2.0
4。数据预处理
./scripts/preprocess_2.0.sh
5。培训
确保至少有两个GeForce GTX TITAN X GPU来训练完整的模型。在
python -u -m stog.commands.train params/stog_amr_2.0.yaml
6。预测
python -u -m stog.commands.predict \ --archive-file ckpt-amr-2.0 \ --weights-file ckpt-amr-2.0/best.th \ --input-file data/AMR/amr_2.0/test.txt.features.preproc \ --batch-size 32\ --use-dataset-reader \ --cuda-device 0\ --output-file test.pred.txt \ --silent \ --beam-size 5\ --predictor STOG
7。数据后处理
./scripts/postprocess_2.0.sh test.pred.txt
8。评价
请注意,评估工具对python2
有效,因此请确保python2
在{
./scripts/compute_smatch.sh test.pred.txt data/AMR/amr_2.0/test.txt
预先培训的模型
以下是预先培训的模型: ckpt-amr-2.0.tar.gz 和ckpt-amr-1.0.tar.gz。 要使用它们进行预测,只需下载并解压缩它们,然后运行Step 6-8。在
如果您只需要预先训练的模型预测(例如,test.pred.txt
),您可以在下载中找到它。在
致谢
我们采用了AllenNLP中的一些模块或代码片段, OpenNMT-py 和NeuroNLP2。 多亏了这些开源项目!在
许可证
- 项目
标签: