How to Write a Story with Artificial Intelligence
I have written 50 posts using artificial intelligence. Every writer has their own method of writing, I want to show you how I am using OpenAI (similar alternatives include AI21 Studio, Eleuther, and Cohere). I am going to share with you the process that led from the initial idea to the finished piece. Some steps are repetitive or less relevant to understand the process, I edited them out.
Artificial intelligence and its use in writing raise quite some philosophical and ethical questions. My intention here is not to discuss them. You can see AI as just another tool like a word processor or as a fellow writer I am sharing my keyboard with.
I use the following typographical convention throughout this article to distinguish between my words and those of the AI.
Regular text is my running commentary.
My prompt to the AI is in italics. Dear AI, introduce yourself.
As denoted by the block quote it is the AI speaking here as a response to the prompt.
The assignment
I talked to a friend who was about to give a workshop on making mistakes. This gave me an idea for my next writing exercise. I usually start with a simple assignment for myself. This time it goes like this. Write an essay on making mistakes, 500 words.
This assignment could work as a prompt but the AI tends to produce bland text if not given other constraints. A frequent constraint is to ask the AI to use a certain style. Combining different styles can lead to exciting results. I choose two of my favorite authors, Alessandro Baricco and Victor Pelevin.
I could write a prompt
Write an essay on making mistakes in the style of Alessandro Baricco and Victor Pelevin
My experience shows this works well for some authors but does not work for others. The AI can produce a pretty decent Slawomir Mrozek story and it can imitate Chuck Palahniuk’s style. When it tries to simulate Baricco, I cannot recognize it. I am going to use an indirect approach. First, I collect the key characteristics of my selected authors. Then I pick some of them to describe the style I want to see.
What are the main characteristics of Alessandro Baricco’s writing?
Fantastical and dreamlike
Lyrical and poetic
Engaging and entertaining
Evocative and atmospheric
Surreal and enigmatic
I am not sure I would describe his style as dreamlike but by and large I agree with this list. Note that I could come up with a similar list myself or I could search the internet and compile a better list from different sources. I choose this approach for two reasons. First and foremost, I am lazy and this list is good enough for my purpose. Second, I assume the AI works better with the characteristics it presents itself, it is like speaking its own language.
This is how the AI characterizes Victor Pelevin
His writing is often absurd and surreal.
He frequently uses black humor and satire.
His work often deals with Russian society and culture.
His writing is often experimental and avant-garde.
His work often includes elements of science fiction and fantasy.
Some of these attributes do not appeal to me, some are almost the same. I mix and match the ones I like. Finally, I have my first actual prompt for the essay.
Write an essay on making mistakes, in a style that is fantastical, lyrical, poetic, engaging and entertaining, evocative and atmospheric, experimental, uses black humor or satire.
Making mistakes is a part of life
We all make them, it’s true
Some more than others, it’s true
But we all have our share
Of blunders and errors
Of fumbles and stumbles
…
It goes on and on and it is so terrible I stop text generation mid-sentence before it is finished. It is far from fantastical or poetical without a pinch of humor of any color. Plain vanilla crap. This is probably what you get when you google for “making a mistake.”
The first story
The problem may be that my selected authors publish mostly fiction. It is more difficult for a piece of nonfiction to be engaging and atmospheric and to have all the other characteristics. I enter the same prompt replacing only “essay” with “story.”
Write a story on making mistakes in a style that is fantastical, lyrical, poetic, engaging and entertaining, evocative and atmospheric, experimental, uses black humor or satire
The day started like any other. But by lunchtime, something was clearly amiss. The usual suspects were there — the Office Manager from Accounts, the Marketing Director, the Head of IT. But instead of the usual banter and gossip, there was an eerie silence.
It was as if everyone knew something was about to happen, but nobody wanted to say anything.
Then it happened. The first mistake. A small one, but a mistake nonetheless. The Office Manager from Accounts made a typo in an email. It was quickly spotted and rectified, but the damage was done.
The Marketing Director followed suit, accidentally sending out a tweet with the wrong hashtags. Again, it was quickly deleted, but the damage was done.
And then the Head of IT made the mother of all mistakes. He hit the wrong button and wiped out the entire company’s website.
In an instant, everything changed. The once-quiet office was now a hive of activity, as people rushed to try and fix the mistakes that had been made.
But it was too late. The damage was done. And there was no going back.
Not bad at first read. It sounds like a story, even if it takes place in a nondescript office environment. Calling upper management “the usual suspects” looks original to me. Reading it for the second time reveals its weak spots. A typo in an email does not count as a mistake. Neither is posting with a wrong hashtag. Wiping out the whole website is definitely a mother of all mistakes (which phrase I like too) but hardly credible. How do I transform this into a real story?
So far I have given instructions to the AI. Do this, do that. Asking a question like the ones about the characteristics of some authors can be still considered an implicit instruction: answer this question. The AI can handle another type of prompt. It can continue the input you enter. If you type “On a winter’s night” and hit enter, it will continue the story. Actually, it is not even aware of the two prompt types, it just does what naturally follows from the context. You can even mix the two types. Start with an instruction and enter the beginning of the text.
Write a heartbreaking Christmas story.
On a winter’s night
We can use this behavior of the AI to edit the text, more precisely, to keep what we like and to generate a new version for the rest. In this case, I would say the story goes awry with the typo. I cut the text and feed back to the AI only what I want to keep. Note how I use the generated text as input.
Write a story on making mistakes.
The day started like any other. But by lunchtime, something was clearly amiss. The usual suspects were there — the Office Manager from Accounts, the Marketing Director, the Head of IT. But instead of the usual banter and gossip, there was an eerie silence.
It was as if everyone knew something was about to happen, but nobody wanted to say anything.
Then it happened. The first mistake. A small one, but a mistake nonetheless. The Office Manager from Accounts
had been going through the invoices and noticed that one of the items was for $5,000 more than it should have been.
She brought it to the attention of the Marketing Director, who took one look at it and said, “That’s not my department.”
The Office Manager from Accounts knew that wasn’t true, but she didn’t want to make a scene. So she let it go.
But then the Head of IT made a mistake. A big one. He was supposed to be upgrading the server, but instead he accidentally deleted all of the company’s data.
For a moment, there was panic. But then someone made a suggestion — let’s blame it on the Office Manager from Accounts.
And so that’s what they did. They blamed the whole mess on her, and she was fired.
But as she was leaving, she heard the Marketing Director say, “This is going to be a disaster. I just know it.” The Office Manager from Accounts knew she had made a mistake. But she also knew that it wasn’t her fault. And she knew that she wasn’t the only one who had made a mistake.
But she also knew that she was the only one who was going to take the fall for it.
This is not much different than the previous version. Deleting all the company’s data is an exaggeration, just like firing a director on the spot. With some tweaks and manual changes it could work as an office drama. I even like the simplicity of blaming the whole mess on someone. The whole story still feels so dull.
Is it the office that makes it so mundane? Or am I missing some real characters? Hard to tell. If I change one aspect of the story, it may cause the rest to change.
Changing the location
It would be a lot more interesting setting if it took place in a monastery. I am already envisioning an AI-version of The name of the rose. I paste the whole story as a prompt and add a single instruction
Rewrite this story to take place in a monastery
It was a warm afternoon when I stopped at the monastery to ask for directions. A monk opened the heavy door and motioned for me to follow him. He led me to a tiny room where another monk sat in front of a computer.
“What’s your problem?” he asked.
“It’s my husband,” I said. “He’s not himself. I can’t explain it. He’s angry all the time. He shouts at the children, and he’s always complaining. He’s even started having affairs. What should I do?”
“Pray,” said the monk.
“That’s not going to help,” I said. “I’ve tried that.”
The monk frowned. “How about fasting?”
“I’ve tried that too,” I said. “It doesn’t work.”
I watched as the monk typed something into the computer.
“Oh dear,” he said. “This is terrible.”
“What is?”
“Your husband has a virus.”
“What do you mean?” I asked. “That sounds serious.”
“It is,” said the monk. “He picked it up from a porn site.”
“Is it dangerous?” “Very,” said the monk. “It affects his thinking. It makes him angry, and it makes him act irrationally. It also reduces his self-control.”
“Is there anything you can do?”
“No,” said the monk. “But I know someone who can.”
Now this is something. It has nothing to do with the office-version, though. I have no idea how the AI transformed that scene into this one. When I instruct it to change a piece in a certain way, it usually does not do anything radical. Sometimes it is good at trimming down text by ten or twenty percent to make it tighter. This transformation actually came as a surprise.
This piece feels polished and interesting. I can imagine Pelevin writing a story of a man who got a virus from a porn site. There is a downside. It does not meet the requirements of the assignment. It is not an essay and is not about a mistake — unless getting infected through the computer and acting in a weird way count as mistakes.
If I was lucky when asking for a transformation, why not try it again?
Make it a story about a mistake
It was a hot afternoon in July. I was driving through the countryside when my car broke down. There was no one else on the road, so I decided to walk to the nearest village and ask for help.
As I reached the village square, I saw a group of monks walking towards me. I asked them for help. “We’re sorry,” said one of the monks. “We can’t help you.”
“Please,” I said. “I need help. You’re the only people I’ve seen.”
“I’m sorry,” said the monk. “I know it’s a problem, but we’re not allowed to speak to women.”
“You can’t speak to women?” I asked. “Why not?”
The monk smiled. “It’s in the rules.”
“But surely you can make an exception, just this once?”
“I’m afraid not,” said the monk. “The rules are very strict.”
“But I’m in real trouble,” I said. “My car has broken down. I’ve nowhere to go.”
“It sounds like a major problem,” said the monk.
“It is,” I said. “I’ve got no money, and I can’t use my phone.”
The monk thought for a moment. “Maybe we can help after all,” he said. “I’ll talk to my superior.”
Seeing a broken car a mistake takes poetic license. I am not sure how this story is more related to mistakes. I see more potential in the previous version, so let us turn it into an essay. It is not so well-defined what makes a piece an essay. More specifically, how to turn a story into an essay.
Anthony de Mello comes to mind whose stories have a lesson to teach. Or maybe it is the monastery setting that reminds me of him. Anyway, I can keep the story as is and give it a de-Mello-ish ending. I use the same trick to get some characteristics of his writing. Here is the prompt to generate the final piece.
Give this story an ending that is mystical, controversial, and has an element of humor
The finished piece: The Virus and the Cure
It was a warm afternoon when I stopped at the monastery to ask for directions. A monk opened the heavy door and motioned for me to follow him. He led me to a tiny room where another monk sat in front of a computer.
“What’s your problem?” he asked.
“It’s my husband,” I said. “He’s not himself. I can’t explain it. He’s angry all the time. He shouts at the children, and he’s always complaining. He’s even started having affairs. What should I do?”
“Pray,” said the monk.
“That’s not going to help,” I said. “I’ve tried that.”
The monk frowned. “How about fasting?”
“I’ve tried that too,” I said. “It doesn’t work.”
I watched as the monk typed something into the computer.
“Oh dear,” he said. “This is terrible.”
“What is?”
“Your husband has a virus.”
“What do you mean?” I asked. “That sounds serious.”
“It is,” said the monk. “He picked it up from a porn site.”
“Is it dangerous?” “Very,” said the monk. “It affects his thinking. It makes him angry, and it makes him act irrationally. It also reduces his self-control.”
“Is there anything you can do?”
“Yes,” said the monk. “But you’re not going to like it.”
“Tell me,” I said. “I’ll do anything.”
“You have to reformat him,” said the monk. “That means deleting his current programming and starting from scratch.”
“How do I do that?”
“Put him in front of a TV for about forty hours,” said the monk. “He’ll be wiped clean in no time.”
I did as the monk suggested. By the end of the weekend, my husband was cured. He was back to his old self. He even complimented me on my cooking.
I sought out the monk to thank him.
“Don’t mention it,” he said. “But tell me, how did you manage it?”
“I just sat him in front of the TV,” I said. “Like you said.”
“Did you put a movie on?”
“No,” I said. “I taped a church service.”
“That must have done it,” said the monk. “If there’s one thing that can reformat a person, it’s a church service.”
Assessing the session
I like to close my writing sessions with an evaluation. I assess the process and the output. The finished piece is 375 words, a lot less than the target. I have found it more challenging to increase the word count than to cut it, just like with my own writing.
It is not really an essay and not exactly about making mistakes in a strict sense, but I find it an enjoyable read. It happens frequently when writing with the AI. I have a topic or an idea in mind at the beginning. By the time I finish the piece, it is far away from the starting point. I tend to have this with my own writing too but to a lesser extent.
In everyday writing I do not keep the intermediate stages of my text. I did keep them now to write this article. Looking back at them helped me better understand my writing process.