Code Monkey home page Code Monkey logo

scratchplot-story-generation's Introduction

ScratchPlot: Story Generation by Prompting Pre-Trained Language Models

This repository contains the code for Plot Writing From Pre-Trained Language Models, to appear in INLG 2022. The paper introduces a method to first prompts a PLM to compose a content plan. Then, we generate the story’s body and ending conditioned on the content plan. Furthermore, we take a generate-and-rank approach by using additional PLMs to rank the generated (story, ending) pairs.

This repo relies heavily on DINO. Since we made some minor changes, we include the complete code for ease of use.

Usage

1. Generating plot elements

Including location, cast, genre and theme.

sh run_plot_static_gpu.sh

The content plan elements are generated once and stored. When generating the stories, the system samples from the offline-generated plot elements.

2. Generate the plot scene by scene

sh run_plot_dynamic_gpu_single.sh

3. Generate a batch of stories

sh run_plot_dynamic_gpu_batch.sh

Note

  • Some hyper-parameters are hard-coded in the bash scripts. You can modify them when needed. The most common ones are:
    • If you don't have a GPU, add --no_cuda to all the commands that calls dino.py.
    • You can modify the number of entries. If your RAM is small (< 8GB), you might receive an OOM error. In such case, reduce the number of entries (at the cost of less diverse stories).
    • You can also modify the length of each generation.
    • While this paper introduces end-to-end content plan and story generation, you can also check the format of the content plan and then either write the content plan manually or curate the system generation.

Setup

Requires Python3. Tested on Python 3.6 and 3.8.

pip3 install -r requirements.txt
import nltk
nltk.download('punkt')
nltk.download('stopwords')

📕 Citation

If you make use of the code in this repository, please cite the following paper:

@inproceedings{jin-le-2022-plot,
    title = "Plot Writing From Pre-Trained Language Models",
    author = "Jin, Yiping  and Kadam, Vishakha and Wanvarie, Dittaya",
    booktitle = "Proceedings of the 15th International Natural Language Generation conference",
    year = "2022",
    address = "Maine, USA",
    publisher = "Association for Computational Linguistics"
}

If you use DINO for other tasks, please also cite the following paper:

@article{schick2020generating,
  title={Generating Datasets with Pretrained Language Models},
  author={Timo Schick and Hinrich Schütze},
  journal={Computing Research Repository},
  volume={arXiv:2104.07540},
  url={https://arxiv.org/abs/2104.07540},
  year={2021}
}

scratchplot-story-generation's People

Contributors

yipingnus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

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.