Giter Site home page Giter Site logo

mops's Introduction

logo

MoPS: Modular Story Premise Synthesis for Open-Ended Automatic Story Generation

Yan Ma1,3,4, Yu Qiao3, Pengfei Liu2,3,4

1Fudan University, 2Shanghai Jiao Tong University,

3Shanghai AI Laboratory, 4Generative AI Research Lab (GAIR)

โœ’๏ธ Contents

๐Ÿ‘€ Overview

"If a story is going to fail, it will do so first at the premise level." โ€“ Anatomy of a Premise Line

A story premise succinctly defines a storyโ€™s main idea, foundation, and trajectory. It serves as the initial trigger in automatic story generation.

motivation

Existing sources of story premises are limited by a lack of diversity, uneven quality, and high costs that make them difficult to scale. In response, we introduce Modular Story Premise Synthesis (MoPS) which breaks down story premises into modules like background and persona for automated design and generation. MoPS consists of three phases: (1) Precollect a consistent set of candidates for each module to form a nested dictionary. (2) Extract a key path from the nested dictionary as the premise design. (3) Instruct an LLM to integrate the design into a coherent premise sentence.

framework

๐Ÿ‘จโ€๐Ÿ’ป Getting started

Installation

git clone https://github.com/GAIR-NLP/MoPS
pip install -r requirements.txt
poetry install

We use OpenAI model as the language backend and manage environment variables in .env via python-dotenv.

Warning

After setting up, please add .env to .gitignore to prevent uploading sensitive information.

#!/usr/bin/env bash

OPENAI_API_KEY="your openai api key"

OPENAI_API_BASE="your openai api url"

OPENAI_MODEL="gpt-3.5-turbo-1106"

Resources

1. Modules

Module candidates in our paper: ./assets/modules

2. Premises

Mops & 5 baselines premises and corresponding evaluation in our paper: ./assets/premises

3. Premised-based Stories

Mops & 5 baselines stories extended from premises and the corresponding evaluation in our paper: ./assets/stories

Stories come in two genres: scripts and novels.

Scripts are generated using Dramatron, and novels are generated using RecurrentGPT.

4. Huggingface dataset

We created a huggingface dataset including three versions of the MoPS dataset: complete, moderate, and curated, with each entry containing a premise and the extented stories.

from datasets import load_dataset

dataset=load_dataset("ManTle/mops")

print(dataset)

๐ŸŽฏ Usage

Stage 1: Induce Module Candidates

>>> python mops/induce.py --help
usage: induce.py [-h] [OPTIONS]
โ•ญโ”€ options โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ -h, --help              show this help message and exit โ”‚
โ”‚ --module-dir PATH       (required)                      โ”‚
โ”‚ --step STR              (required)                      โ”‚
โ”‚ --max-backgrounds-per-theme INT                         โ”‚
โ”‚                         (default: 30)                   โ”‚
โ”‚ --max-personas-per-background INT                       โ”‚
โ”‚                         (default: 9)                    โ”‚
โ”‚ --max-events-per-persona INT                            โ”‚
โ”‚                         (default: 2)                    โ”‚
โ”‚ --max-endings-per-event INT                             โ”‚
โ”‚                         (default: 1)                    โ”‚
โ”‚ --max-twists-per-ending INT                             โ”‚
โ”‚                         (default: 1)                    โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

Step 0: Pre-collect a few themes in module_dir/theme.json.

See examples: ./data/modules/theme.json where module_dir=./data/modules

Step 1: Induce background

python mops/induce.py --module-dir ./data/modules --step background --max-backgrounds-per-theme 1

Step 2: Induce persona

python mops/induce.py --module-dir ./data/modules --step persona --max-personas-per-background 1

Step 3: Induce event

python mops/induce.py --module-dir ./data/modules --step event --max-endings-per-event 1

Step 4: Induce ending

python mops/induce.py --module-dir ./data/modules --step ending --max-endings-per-event 1

Step 5: Induce twist

python mops/induce.py --module-dir ./data/modules --step twist --max-twists-per-ending 1

Stage 2: Synthesize Premises

>>> python mops/synthesize.py --help
usage: synthesize.py [-h] [OPTIONS]

โ•ญโ”€ options โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ -h, --help              show this help message and exit                โ”‚
โ”‚ --module-dir PATH       (required)                                     โ”‚
โ”‚ --premise-dir PATH      (required)                                     โ”‚
โ”‚ --enable-verify, --no-enable-verify                                    โ”‚
โ”‚                         (default: False)                               โ”‚
โ”‚ --masks {None}|{[{theme,background,persona,event,ending,twist} [...]]} โ”‚
โ”‚                         (default: None)                                โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

For example, you can run the following command after stage 1:

python mops/synthesize.py --module_dir ./data/modules --premise_dir ./data

You can flexibly control the required modules through masks flag , and the candidates for corresponding modules in the masks will be set as empty strings.

For example, if you want to remove ending and twist during synthesis, you can run the following:

python mops/synthesize.py --module_dir ./data/modules --premise_dir ./data --masks ending twist

Stage 3: Evaluate Premises

We use the semantic Breadth and Density metrics proposed in the paper to evaluate diversity, and evaluate quality based on LLM in the three dimensions of Fascination, Completeness, and Originality.

Please refer to files in notebooks for the implementation details of evaluation.

Stage 4 [Optional]: Use your favorite premise-based automatic story generation pipeline to create long stories

We use Dramatron and RecurrentGPT in our paper.

If you are looking for more story generation work, we recommend you refer to Awesome-Story-Generation

Citation

@misc{ma2024mops,
      title={MoPS: Modular Story Premise Synthesis for Open-Ended Automatic Story Generation}, 
      author={Yan Ma and Yu Qiao and Pengfei Liu},
      booktitle={Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 3: System Demonstrations)},
      address={Bangkok, Thailand},
      publisher={Association for Computational Linguistics},
      year={2024},
      url={http://arxiv.org/abs/2406.05690}
}

mops's People

Contributors

mantle2048 avatar

Stargazers

 avatar Hongchao Gu avatar Jiwung Hyun avatar Luxi Xing avatar  avatar Qinyuan Cheng avatar Jon Chun avatar  avatar Steffi Chern avatar Yuqing Yang avatar Zhen Huang avatar Pengcheng Wen avatar Fan avatar Ethan Chern avatar Junlong Li avatar xuefengli avatar  avatar Rui Li avatar Qiming Xie avatar Shijie Xia avatar Run-Ze Fan avatar Zengzhi Wang avatar Yingpeng MA avatar  avatar

Watchers

 avatar Pengfei Liu 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.