Inspiration
Why are you trying to make it do creative things? Seems so difficult.
Choose your own adventure books I read as a kid.
Interactive story writing tools:
- Twine
- Ink
LLMs are well suited to generate Choose Your Own Adventure stories. But, their streams of consciousness can produce incoherent plots.
Proposed solution: A Hybrid appoach.
Humans (or classic algorithms like story grammars), generate plots. LLMs then bring them to life.
I think that Interactive fiction seems especially well suited to benefit from LLMs.
Interactive fiction writers use all kinds of tools to enhance interactivity -- straight up programming, writing niche macros, simply brute forcing every possible scenario etc. Examples of things that complicate interactive fiction could be keeping track of character names and other traits, and having previous choices affect future events in their stories, etc.
Having an LLM look at previously generated text and generate new text that is consistent in style and plot would be an excellent tool. Especially, if it follows the author's planned plot outlines to the letter, which, it turns out, is quite challenging!
Inspired by Mark Riedl's excellent article introducing story generation.
What it does
Turns YAML interactive story outline spec like the following:
story_outline:
title: Abandoned Ship
pov: third person
setting: ancient abandoned ship in an asteroid belt
nodes:
start:
plot: Derek, a space miner, finds an abandoned ship. ship looks like ancient human tech
links:
closer: get closer
closer:
plot: he sees that the hull says NASA Hermes Mission 2500. He searches for a door, finds two locked ones.
links:
door1: enter door 1
door2: enter door 2
door1:
plot: big explosion. luckily Derek is rescued by other miners. ship wreck is lost.
door2:
plot: He finds a working ancient databank. Archaeologists in the nearest university thank Derek.
Into twee3 format for interactive fiction, by generating text for each story "node" in each path through the story:
:: StoryTitle
Abandoned Ship
:: start
As I floated through the asteroid belt, scanning for valuable minerals, my trusty spacesuit crackling with static, I spotted something that made my heart race - an ancient, abandoned ship, its metal hull rusted and pitted from years of exposure to the harsh void.
[[get closer|start__closer]]
:: start__closer
As I approached the ancient abandoned ship, its rusted metal hull bearing the faded letters "NASA Hermes Mission 2500," my heart raced with excitement and trepidation. With sweaty hands, I searched for a door, finding two locked ones that barred my way into the unknown depths of the ship's dark interior.
[[enter door 1|start__closer__door1]]
[[enter door 2|start__closer__door2]]
:: start__closer__door1
As the asteroid belt was rocked by a massive explosion, Derek's heart pounded in his chest as he clung to the remains of his spaceship, desperately trying to stay afloat among the debris. It seemed like hours before other miners finally spotted him and pulled him from the wreckage, their voices blurred together in a haze of relief and adrenaline. Despite their efforts, the ship was lost forever, consumed by the flames that raged across the belt. Derek knew he had been lucky to escape with his life, but as he floated away from the disaster, he couldn't help but feel a pang of loss for the ship that had been his home for so long.
:: start__closer__door2
As he floated through the asteroid belt, scanning for valuable minerals, his trusty spacesuit crackling with static, Derek stumbled upon something that would change his life forever - a working ancient databank, its glowing lights and whirring mechanisms a stark contrast to the dark void of space around it. With shaking hands, he accessed the database, discovering information about a long-lost mission from centuries ago. Excitement coursed through him as he realized what he had found - evidence of an ancient civilization that had long since vanished. He knew he couldn't keep this discovery to himself, and with a sense of purpose, he steered his spaceship towards the nearest university, where archaeologists would thank Derek for bringing them one step closer to unlocking the secrets of the past.
How we built it
I built a library called spinayarn with a (hopefully) easy interface:
from spinayarn import InteractiveStory, SpinAYarn
from spinayarn.utils import get_llamacpp_llm
hermes = get_llamacpp_llm(<PATH TO HERMES BIN>)
outline = InteractiveStory.from_outline_yarml("examples/restaurant/restaurant.yml")
story = spinayarn.generate_story()
story.to_twee3_file("examples/restaurant/restaurant.twee")
I also wrote some notebooks to test it with various LLMs.
Please skim the README in the github repo for more details.
Challenges we ran into
It's so difficult to get exactly what you want from the models I tried. ChatGPT 3.5, on the other hand, seems so much better at understanding exactly what I mean. Getting open source models to do the same is quite challenging, but seems definitely worth the trouble!
There are so many open source LLM models! (Which is a good thing but time intensive to try them all!) This also means that, we'd need a lot of prompts, each of which work well only with certain models, to take advantage of the ecosystem.
Latency: too much time spent waiting for results.
Accomplishments that we're proud of
Got it kind of working.
And, learned a lot about the LLM ecosystem.
What we learned
A lot about the open source LLM ecosystems, the tools available, and how to use them.
Awesome projects like
- ggml and llamacpp
- langchain
How much more there is to learn!!
What's next for Spin A Yarn
It'd be interesting to test other models trained for story writing. Off the to of my head, Chronos and MPT-7B Storywriter. Chronos Hermes is interesting -- the author somehow "mixed" Chronos into Hermes to get better (?), or atleast different, results for creative writing.
In a similar vein, it'd be interesting if you could mix and match models -- an ensemble of LLMs, each good at something else, delegating tasks to each other.
I'm wondering if there is a way to place replit model as a copilot for llama models somehow, to automatically offload coding tasks to it like it's a sidekick https://twitter.com/Teknium1/status/1666745058618646529
I think it'd be interesting to experiment with interactive documents with other AI generated text e.g. non-fiction, tutorials etc especially combined with VectorDBs. E.g. a "non-fiction roleplay" as a energy investments advisor choosing between nuclear fission or fusion for long term energy.
Interactively recording selected chat conversations in order to replay as "interactive fiction" using one of the many Twine formats, might also be an interesting extension.
Built With
- hermes
- huggingface
- langchain
- llamacpp
- python
Log in or sign up for Devpost to join the conversation.