Giter VIP home page Giter VIP logo

kamigaito / slahan Goto Github PK

View Code? Open in Web Editor NEW
18.0 3.0 3.0 5.34 MB

SLAHAN is an implementation of Kamigaito et al., 2020, "Syntactically Look-A-Head Attention Network for Sentence Compression", In Proc. of AAAI2020.

License: MIT License

Perl 1.60% Python 4.35% CMake 3.10% C++ 76.75% Shell 0.85% C 2.28% Scala 0.69% SWIG 0.30% Java 0.02% TeX 0.01% Batchfile 0.04% Cuda 1.01% HTML 0.13% Fortran 8.79% JavaScript 0.05% CSS 0.04%

slahan's Introduction

SLAHAN: Syntactically Look-A-Head Attention Network for Sentence Compression

SLAHAN is an implementation of Kamigaito et al., 2020, "Syntactically Look-A-Head Attention Network for Sentence Compression", In Proc. of AAAI2020.

Citation

@article{Kamigaito2020SyntacticallyLA,
  title={Syntactically Look-Ahead Attention Network for Sentence Compression},
  author={Hidetaka Kamigaito and Manabu Okumura},
  journal={ArXiv},
  year={2020},
  volume={abs/2002.01145}}

Prerequisites

Build Instruction

Set the environment value BOOST_ROOT:

export BOOST_ROOT="/path/to/boost"

and run:

./scripts/setup.sh

Prediction & Evaluation

You can predict the test sets of Google dataset and BNC Corpus by the following commands:

### Prediction for the Google dataset ###
./scripts/predict/google/predict.sh
### Prediction for the BNC Corpus ###
./scripts/predict/bcn/predict.sh

Precisions, recalls, f-measures, and compression ratios for each model are stored in the file results/{dev or test}_{dataset type}_{evaluation metric}.csv, respectively.

You can also calculate rouge scores by using the ROUGE-1.5.5 script. After the setup of ROUGE-1.5.5 and the execution of predict.sh, you can ran the following command for obtaining rouge scores for each model:

### Calculate rouge for the Google dataset ###
./scripts/predict/google/rouge.sh
### Calculate rouge for the BNC Corpus ###
./scripts/predict/bcn/rouge.sh

Rouge scores are also stored in the file results/test_{dataset type}_{evaluation metric}.csv, respectively.

You can also calcute compression rates in characters:

### Calculate compression rates in characters for the Google dataset ###
./scripts/predict/google/char_len.sh
### Calculate compression rates in characters for the BNC Corpus ###
./scripts/predict/bcn/char_len.sh

Compression rates in characters are also stored in the file results/test_{dataset type}_char_cr.csv, respectively.

Note that the reference compression is located on dataset/, and the system compression is located on models/{dataset size}/{model name}_{process id}/comp.txt.

Compressed Sentences

The compressed sentences used for the evaluation in our paper are included in the directory share.

Retrain the Models

Before retraining the models, you should extract features of the training data set.

./scripts/train/google/extract_features.sh

Note that this step includes feature extractions of BERT, ELMo and Glove. It takes almost 1 day and 300GB of disk space. After that, you can retrain each model by the below command.

./scripts/train/google/{model name}.sh {process_id}

All trained models are saved in the directory models/{dataset name}/{model name}_{process id}/save_{epoch}. To reproduce our results, run the following commands:

### Tagger ###
./scripts/train/google/tagger.sh 0
./scripts/train/google/tagger.sh 1
./scripts/train/google/tagger.sh 2
### LSTM ###
./scripts/train/google/lstm.sh 0
./scripts/train/google/lstm.sh 1
./scripts/train/google/lstm.sh 2
### LSTM-Dep ###
./scripts/train/google/lstm-dep.sh 0
./scripts/train/google/lstm-dep.sh 1
./scripts/train/google/lstm-dep.sh 2
### Attn ###
./scripts/train/google/attn.sh 0
./scripts/train/google/attn.sh 1
./scripts/train/google/attn.sh 2
### Base ###
./scripts/train/google/base.sh 0
./scripts/train/google/base.sh 1
./scripts/train/google/base.sh 2
### Parent w syn ###
./scripts/train/google/parent_w_syn.sh 0
./scripts/train/google/parent_w_syn.sh 1
./scripts/train/google/parent_w_syn.sh 2
### Parent w/o syn ###
./scripts/train/google/parent_wo_syn.sh 0
./scripts/train/google/parent_wo_syn.sh 1
./scripts/train/google/parent_wo_syn.sh 2
### Child w syn ###
./scripts/train/google/child_w_syn.sh 0
./scripts/train/google/child_w_syn.sh 1
./scripts/train/google/child_w_syn.sh 2
### Child w/o syn ###
./scripts/train/google/child_wo_syn.sh 0
./scripts/train/google/child_wo_syn.sh 1
./scripts/train/google/child_wo_syn.sh 2
### SLAHAN w syn ###
./scripts/train/google/slahan_w_syn.sh 0
./scripts/train/google/slahan_w_syn.sh 1
./scripts/train/google/slahan_w_syn.sh 2
### SLAHAN w/o syn ###
./scripts/train/google/slahan_wo_syn.sh 0
./scripts/train/google/slahan_wo_syn.sh 1
./scripts/train/google/slahan_wo_syn.sh 2

After these processes, you can run the following prediction and evaluation scripts:

./scripts/predict/google/predict.sh
./scripts/predict/google/rouge.sh
./scripts/predict/google/char_len.sh
./scripts/predict/bcn/predict.sh
./scripts/predict/bcn/rouge.sh
./scripts/predict/bcn/char_len.sh

Finally, you can obtain results of the models in the directory ./results.

LICENSE

MIT License

slahan's People

Contributors

kamigaito avatar

Stargazers

 avatar  avatar  avatar Daniel Kaiser avatar  avatar  avatar  avatar Sriram Pingali avatar Yixue Zhao, PhD avatar UkDong Gim/김욱동 avatar Jiaxin Wen avatar  avatar Florian Cäsar avatar Binoy Dalal avatar  avatar Xiaoli (Eddie) Wu avatar  avatar Bhavesh Kumar avatar

Watchers

James Cloos avatar  avatar paper2code - bot avatar

slahan's Issues

Issues during compilation

Hey!
I tried running the setup, but for some reason, the CMake isn't working for build_compressor and build_dynet. Multiple cudnn based errors turn up.
For e.g. undefined reference to `cudnnGetConvolutionBackwardFilterAlgorithm'

I'm not able to build the required files for the predict.sh. Can you please help me?

Dockerfile with all the required libraries

Hi, I found this interesting for my ongoing experiment. I tried setting up everything but I struggle to make it work. Is it possible for you to release a Dockerfile? It would help me, everyone, to reproduce results easily.
Thanks,
Bhavesh

Errors are reported when using my own data

lstm: /root/SLAHAN-master/compressor/include/s2s/corpus/batch.hpp:268: void s2s::batch::elmo2batch(unsigned int, unsigned int, const std::vector&, const std::vector<std::vectors2s::token >&): Assertion `false' failed.

How can I fix it?

Is options.hpp missing <float.h>?

When I build, I get the error of:

[  6%] Building CXX object CMakeFiles/slahan.dir/lib/slahan.cpp.o
[ 13%] Building CXX object CMakeFiles/base.dir/lib/base.cpp.o
[ 20%] Building CXX object CMakeFiles/lstm.dir/lib/lstm.cpp.o
[ 26%] Building CXX object CMakeFiles/attn.dir/lib/attn.cpp.o
In file included from In file included from /Users/.../base.cpp::2121:
:
In file included from In file included from /Users/.../SLAHAN/compressor/include/s2s/nn/base.hpp::2323:
:
/Users/.../SLAHAN/compressor/include/s2s/corpus/options.hpp:371/Users/zacharyg/Desktop/SLAHAN/compressor/include/s2s/corpus/options.hpp:371:84: :84: error: use of undeclared identifier 'FLT_MAX'
In file included from /Users/.../SLAHAN/compressor/lib/lstm.cpperror: :21:
use of undeclared identifier 'FLT_MAX'In file included from 
        ("dummy_flt_min", po::value<float>(&(opts->dummy_flt_min))->default_value(-FLT_MAX), "minimum value of the float")
                                                                                   ^/Users/.../SLAHAN/compressor/include/s2s/nn/lstm.hpp:23
:
...

This is resolved by adding #include <float.h> to options.hpp.

...
#include <vector>
#include <string>

#include <float.h>

#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>
...

Just wanted to confirm my build is not just incomplete or occurring through a misconfiguration.
Note: I am working on MacOS Apple Silicon.

Using it for a custom dataset

Hi,

How does one use the Syntatic Compressor for Your custom dataset and maybe integrating it into another code? is there any simplified version of it that we can use?

Convert own data to Google Dataset format

Hey,
I was studying and trying to work on your model. It is really very amazing. The only problem I am facing is- I am not able to find a way to convert my input sentences in the google dataset format. Is there any code for that?
It will be really kind of you if you could provide me with the same.

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.