GithubHelp home page GithubHelp logo

jind11 / titlestylist Goto Github PK

View Code? Open in Web Editor NEW
76.0 9.0 7.0 68.75 MB

Source code for our "TitleStylist" paper at ACL 2020

License: MIT License

Shell 4.22% Python 95.78%
natural-language-processing summarization transformer style-transfer pytorch-implementation

titlestylist's Introduction

TitleStylist

Source code for our "TitleStylist" paper at ACL 2020: Jin, Di, Zhijing Jin, Joey Tianyi Zhou, Lisa Orii, and Peter Szolovits. "Hooks in the Headline: Learning to Generate Headlines with Controlled Styles." ACL (2020).. If you use the code, please cite the paper:

@inproceedings{jin2020hooks,
  author    = {Di Jin and Zhijing Jin and Joey Tianyi Zhou and Lisa Orii and Peter Szolovits},
  title     = {Hooks in the Headline: Learning to Generate Headlines with Controlled
               Styles},
  booktitle = {Proceedings of the 58th Annual Meeting of the Association for Computational
               Linguistics, {ACL} 2020, Online, July 5-10, 2020}, pages = {5082--5093},
  publisher = {Association for Computational Linguistics}, year = {2020},
  url       = {https://www.aclweb.org/anthology/2020.acl-main.456/}
}

Here is a talk that introduces our work.

Requirements

Python packages

  • Pytorch
  • fairseq
  • blingfire

In order to install them, you can run this command:

pip install -r requirements.txt

Bash commands

In order to evaluate the generated headlines by ROUGE scores, you need to install the "files2rouge" package. To do so, run the following commands (provided by this repository):

pip install -U git+https://github.com/pltrdy/pyrouge
git clone https://github.com/pltrdy/files2rouge.git     
cd files2rouge
python setup_rouge.py
python setup.py install

Usage

  1. All data including the combination of CNN and NYT article and headline pairs, and the three style-specific corpora (humor, romance, and clickbait) mentioned in the paper have been placed in the folder "data".

  2. Please download the pretrained model parameters of MASS from this link, unzip it, and put the unzipped files into the folder "pretrained_model/MASS".

  3. To train a headline generation model that can simultaneously generated a facutal and a stylistic headline, you can run the following command:

./train_mix_CNN_NYT_X.sh --style YOUR_TARGET_STYLE

Here the arugment YOUR_TARGET_STYLE specifies any style you would like to have, in this paper, we provide three options: humor, romance, clickbait.

After running this command, the trained model parameters will be saved into the folder "tmp/exp".

  1. If you want to evaluate the trained model and generate headlines (both factual and stylistic) using this model, please run the following command:
./evaluate_mix_CNN_NYT_X.sh --style YOUR_TARGET_STYLE --model_dir MODEL_STORED_DIRCTORY

In this command, the argument MODEL_STORED_DIRCTORY specifies the directory which stores the trained model.

  1. If you want to train and evaluate the headline generation model for more than one style, run the following command:
./train_mix_CNN_NYT_multiX.sh
./evaluate_mix_CNN_NYT_multiX.sh --model_dir MODEL_STORED_DIRCTORY

Extension

For the humorous style, although we used humorous novels, you can also try the following datasets:

We suggest that the large dataset Short Jokes is likely to generate good headlines.

titlestylist's People

Contributors

jind11 avatar zhijing-jin avatar

Stargazers

 avatar  avatar Mario Filho avatar  avatar  avatar Memeda_LWW avatar Anh Nguyen avatar  avatar Xueyao Sun avatar  avatar  avatar  avatar  avatar  avatar  avatar Mr.Harddisk avatar  avatar Tingting Li avatar  avatar Dawei Li avatar  avatar  avatar Yajing Luo avatar Zheng Yilun (Jaylen) avatar  avatar Ivan Bilan avatar Amy Zeng avatar YuKai Lee avatar  avatar  avatar VC Ramesh avatar  avatar  avatar  avatar 冰茶 avatar Cinkate Ren avatar  avatar  avatar Sanders Bao avatar Hengyuan Zhang  avatar bing0037 avatar Olivia-fsm avatar 123 avatar  avatar Beizhe Hu avatar HappyGu avatar Cao_enjun avatar lxm avatar  avatar Yichuan LI avatar Harshit Joshi avatar shizhediao avatar Carol Hung avatar victorsungo avatar  avatar Alex Lau avatar Gaurav Jindal avatar Krishnapriya Vishnubhotla avatar  avatar Sergei Alonichau avatar  avatar  avatar Yong Liu avatar Yuhan Liu avatar  avatar Jason N avatar Sebastian Rodriguez avatar Kalyan Guntupalli avatar Jiwon Kang avatar WEI HAORAN avatar Yuming Yang avatar Jun Wang avatar  avatar Seder(方进) avatar 爱可可-爱生活 avatar Sheik Mohamed Imran avatar

Watchers

mingfeng.zhang avatar James Cloos avatar Peinan Zhang avatar WEI HAORAN avatar  avatar Edward Kamau avatar  avatar Yajing Luo avatar paper2code - bot avatar

titlestylist's Issues

Can not get your result

After doing the data preprocessing, training and evaluation for humorous headline generation provided by this repo, i get the following result. The BLEU score is 9.0, much lower than you have written in your paper(13.3).
Is there anything wrong?
微信图片_20210810105141

where is pretrained_model/MASS/dict.txt

Hi, thanks for your outstanding work.
Here I want to preprocess my own dataset using data_process.sh, but the srcdict and tgtdict files are missing in L24 and L25 below. Could you tell me where to find them?

fairseq-preprocess \
--user-dir mass --task masked_s2s \
--source-lang src --target-lang tgt \
--trainpref $DATA_DIR/train \
--validpref $DATA_DIR/valid \
--testpref $DATA_DIR/test \
--destdir $OUT_DIR \
--srcdict pretrained_model/MASS/dict.txt \
--tgtdict pretrained_model/MASS/dict.txt \
--workers 20

Error: module name (mass) is not globally unique

I ran sh train_mix_CNN_NYT_X.sh, and met this error.

Traceback (most recent call last):
  File "train.py", line 337, in <module>
    cli_main()
  File "train.py", line 300, in cli_main
    parser = options.get_training_parser()
  File "/root/anaconda3/envs/titlestyle/lib/python3.6/site-packages/fairseq/options.py", line 34, in get_training_parser
    parser = get_parser("Trainer", default_task)
  File "/root/anaconda3/envs/titlestyle/lib/python3.6/site-packages/fairseq/options.py", line 210, in get_parser
    utils.import_user_module(usr_args)
  File "/root/anaconda3/envs/titlestyle/lib/python3.6/site-packages/fairseq/utils.py", line 461, in import_user_module
    "something unique and try again.".format(module_path, module_name)
ImportError: Failed to import --user-dir=/home/baojunshan/TitleStylist/mass because the corresponding module name (mass) is not globally unique. Please rename the directory to something unique and try again.

I also changed the folder name but did not help.

Do you have the pretrained model?

I downloaded MASS model
Trying thing like that
./evaluate_mix_CNN_NYT_X.sh --style clickbait --model_dir ./pretrained_model
but get error: OSError: Model file not found: ./pretrained_model/checkpoint_best.pt
I agree with that, but where can I get the checkpoint for correct model?

Thank you and have a nice day!%)

4090 bug

Hello author, I would like to ask whether this model can run on the 4090 machine? When I tried to reproduce this paper, there was a bug that I can't solve at present. I guess this may be due to the problem that my pytorch version is too new. I would like to ask if anyone can run this code on the 4090 machine? Here's a failure case I'm having, it happens during the evaluation phase

e9640da0fec78e8813508af003099c67

can't generate headlines

when i use the command'./evaluate_mix_CNN_NYT_X.sh --style YOUR_TARGET_STYLE --model_dir MODEL_STORED_DIRCTORY' ,there is a problem'TypeError: init() takes 1 positional argument but 6 were given',is it a code wrong or else?

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.