Generating a full-length work of fiction with GPT-4

Chiara Coetzee
10 min readMar 24, 2023

--

Read the book, Echoes of Atlantis, for free:

(Google Docs) (PDF) (epub)

Research Log including all prompts and responses:

(Google Docs) (PDF)

Audiobook

Audiobook generated by ElevenLabs (partial): Audiobook

Reddit post

r/ChatGPT: I asked GPT-4 to write a book. The result: “Echoes of Atlantis”, 12 chapters, 115 pages, zero human input. (process included)

Goal

The goal of this project was to have the GPT-4 version of ChatGPT, the latest instructional large language model, generate an entire novel from scratch, including the title, genre, story, characters, settings, and all the writing, with no human input. It is impossible currently to do this using a single prompt (“write me a book”), but what is possible is to supply a series of prompts that give structure to the process and allow it to complete this large task, one step at a time. However, in order to ensure that all the creative work is done by GPT-4, prompts are not allowed to make specific references to the content of the book, only the book’s structure. The intention is that the process should be simple, mechanical and possible (in principle) to fully automate. Each time the process is repeated from the beginning, it should create another entirely new book, based solely on GPT-4’s independent creative choices.

The result: Echoes of Atlantis, a fantasy adventure novel with 12 chapters and 115 pages, written over 10 days in March 2023.

Insights/Techniques

My main insights I figured out in the course of doing this project:

  • Iterative refinement: Start with a high level outline. Make a detailed chapter outline. Then write a draft version of the full chapter (this will be much shorter than desired). Then expand each scene into a longer, more detailed scene.
  • Bounding (outside-in): GPT-4 loves to go too far ahead, writing about parts of the book that aren’t supposed to happen yet. The key to preventing this is to have it first write the first parts, then the last parts, then fill in the middle parts. The last part prevents it from going too far ahead, and the first parts in turn bound the last part of the previous section. Bounding is used at every level of refinement except the top level.
  • Single prompt: Often, by using a single large prompt, rather than a running conversation, you can flexibly determine exactly what information will be included in the input buffer, and ensure that all of it is relevant to the current task. I’ve crafted this approach to squeeze as much relevant info as I can into the token buffer. (Note: Sometimes, if you are very near the limit, even a single prompt can overrun the token buffer. In this case a little text must be removed.)
  • Continuity notes: Ask it to take notes on important details to remember for continuity and consistency as it goes. Begin with continuity notes summarized from the previous scene, and then fold in additional continuity notes from the previous continuity notes. When doing so, it’s helpful to provide limited context (only the most recent scene, and the previous scene’s continuity notes) to avoid looking forward. Continuity Notes will tend to grow over time; if they become too long, ask it to summarize them.
  • Revising outlines: In some cases, the AI improvises in its writing, for example moving some of the Chapter 5 scenes into Chapter 4, which breaks the book. To resolve this, I ask it after each chapter to go back and update its earlier, higher-level outlines and regenerate the opening and closing scenes of each chapter before continuing. This is very similar to how real authors revise their outlines over time.
  • Data cleanup: Sometimes outputs will do things a little weird, like copy labels from the input buffer like “Opening Paragraph”, or forget to number the scenes, or start numbering at zero, or add a little bit of stray text at the beginning. Currently I clean these up manually but a fully automated solution would have to cope with these.

Example prompts

These are just a few examples, and they don’t show all the data included with the prompt. For full details, see my Research Log.

Level 1: Top-level outline

Me: Please write a high-level outline for a book. Include a list of characters and a short description of each character. Include a list of chapters and a short summary of what happens in each chapter. You can pick any title and genre you want.

Level 1: Updating outline after each chapter

Me: Please edit and update the high-level outline for the book below, taking into account what has already happened in Chapter 1.

Level 2: Scenes (bounding)

Me: Please write a detailed outline describing the first scene of each chapter. It should describe what happens in that opening scene and set up the story for the rest of the chapter. Do not summarize the entire chapter, only the first scene.

Me: Write a detailed outline describing the final, last scene of each chapter. It should describe what happens at the very end of the chapter, and set up the story for the opening scene of the next chapter, which will come immediately afterwards.

Level 2: Scenes

Me: Given the following book outline, and the following opening and final scenes for Chapter 1, write a detailed chapter outline giving all the scenes in the chapter and a short description of each. Begin the outline with the Opening Scene below, and finish the outline with the Final Scene below.

Level 3: Rough draft

Me: Given the following book outline, and following detailed chapter outline for Chapter 1, write a first draft of Chapter 1. Label each of the scenes. Stop when you reach the end of Chapter 1. It should set up the story for Chapter 2, which will come immediately afterwards. It should be written in a narrative style and should be long, detailed, and engaging.

Level 4: Paragraphs (bounding)

Me: Given the following book outline, and the following draft of Chapter 1, imagine that you have expanded this draft into a longer, more detailed chapter. For each scene, give me both the first opening paragraph, and the last, final paragraph of that longer, more detailed version. Label them as Opening Paragraph and Final Paragraph. The opening paragraph should introduce the scene. The final paragraph should set up the story for the following scene, which will come immediately afterwards. The last paragraph of the final scene should set the story up for the following chapter, which will come immediately afterwards.

Level 4: Paragraphs

Me: Given the following book outline, and the following draft of Chapter 1, write a longer, more detailed version of Scene 1. The scene must begin and end with the following paragraphs: (opening and closing paragraphs here)

Continuity Notes

Me: Please briefly note any important details or facts from the scene below that you will need to remember while writing the rest of the book, in order to ensure continuity and consistency. Label these Continuity Notes.

Me: Combine and summarize these notes with the existing previous Continuity Notes below.

Reflections on the result

Although in many ways the work did come together as a coherent work of fiction, following its own outline and proceeding at the pacing that its own outline dictated, and some parts were genuinely exciting and interesting to read (particularly the earliest and latest chapters), I’d hesitate to call it a good book. It’s still got some weird and interesting problems to it:

  • Reference without introduction: Occasionally, the AI will reference things that have not really been introduced/explained yet, like Langdon knowing about Lord Malakhar in Chapter 4, or Aria having a physical pendant after her dream of Queen Neria. It feels like you must have missed something.
  • Seams around opening/closing paragraphs: Because opening and final paragraphs are written before the rest of the scene, sometimes they don’t flow smoothly from the rest, or they even end up redundant. An additional pass of some kind could help clean this up. Likewise, sometimes the transition between chapters could seem abrupt, like going from Chapter 8 to 9 (fighting Malakhar in the labyrinth to just suddenly a passage to Atlantis opening).
  • Forgetting certain details: Although certain details are maintained in the Continuity Notes or in the outline, others it decides to drop, and then they can never be referenced again, since they are no longer in the input buffer. A good example of this is the compass Aria got as a graduation present, which felt a lot like a Chekov’s gun that was never mentioned again. Another is the particular unique weapons they purchased at the outset, which were never used. The only clear solution is either a larger buffer or a long-term memory solution. I considered a better process for continuity notes where I removed items that can already be inferred from the chapter outline, leaving room for more details like this, but didn’t implement this.
  • Rearrangements: The AI moved some parts from later chapters into earlier chapters, despite my best attempts to bound it, such as the early scenes on the island which moved from Chapter 5 to Chapter 4, and the early labyrinth scenes which were moved from Chapter 6 to Chapter 5. The only real way to address this was to ask it to edit and update its high-level outlines afterwards. This is similar to what human authors do — they rarely treat their outlines as static and inviolable.
  • Pacing: To me, the labyrinth chapters felt like a bit of a slog. It was one trap chamber after another, for a very long time. These did fit the original outline, so the original outline was part of the problem, but there are also ways it could have made the labyrinth feel new and different. This feels like a creative writing mistake by GPT-4 to me.
  • Overly regular structure: Almost invariably the AI chose to write 6–8 scenes per chapter, and about 1–2 pages per scene. This feels less organic than a lot of human-written works where some scenes/chapters are short and others are longer. It might have been better to develop a dynamic expansion structure where it continues to expand until it is somehow satisfied that it has achieved the desired level of detail.
  • Varying level of detail: On a related note, some scenes were quite detailed, including dialog and minute actions, while others (even more important scenes) seemed to breeze right over big important moments with a summary. Again, I think some kind of dynamic expansion to achieve a consistent level of detail could help here.

Some fun notes

  • In Scene 3 of Chapter 5, GPT-4 spontaneously wrote an original riddle in the labyrinth that they had to solve.
    “Within my walls I hold a sea,
    Yet not a drop of water you’ll see.
    Many paths there are to roam,
    But only one will lead you home.
    What am I?”
    Alex figured it out, the answer is “a map”.
  • In at least three places, GPT-4 slipped in sly references to “the next chapter in her life” or “the next chapter in their adventure” right as the chapter was ending. Very meta.

Frequently asked questions

Q: Didn’t you exhibit a lot of authorial control in choosing which answers to keep and which ones to throw away?

Actually, regenerating responses was rare, and I only ever did it if I either found a serious problem with the process or if there was a serious logical problem in the book that I couldn’t figure out how to resolve with process changes. This happened at most 4–5 times in all. At least 95% of the time, the text in the book is the very first response I got back from GPT-4. You can see this in the notes in my research log.

Q: This book isn’t very good. I don’t think professional authors will have very much to worry about.

True, but that’s not the point. It’s a proof of concept: can an AI write an entire book, of 100+ pages, from beginning to end, while remaining coherent and following its original planned outline? Without needing humans to step in and tell it what to do with the story or the characters? The answer is yes. Moreover, I think it’s pretty enjoyable in some parts. And of course, the next GPT model will only be a better author.

Q: Isn’t there a rate limit on GPT-4 queries on ChatGPT Plus? How could you have written 100+ pages in 10 days?

Yes, and I hit it many times. However, because both my prompts and ChatGPT’s responses were very long, I was able to squeeze the absolute maximum text out of every prompt. Moreover, GPT-4 accepts a much longer prompt input than either GPT-3 or Bing did, which helps a ton for ensuring I can include as much context as possible. Also, the limit was higher in early days right after GPT-4 release.

Q: Is GPT-4 needed for this? How does it compare to GPT-3?

I tried this with GPT-3 before and encountered issues, mostly around writing too far ahead in the story and getting off-track. Bounding techniques might help, I haven’t tried yet — partly because it’s a pain to deal with the smaller input buffer. Needs further investigation.

Q: Can I use your book or your process or your prompts?

Please feel free, I did this for fun in my free time and I release all of this into the public domain under the Creative Commons Zero Waiver (CC0) and disclaim any IP rights.

Q: How should I cite this article?

Coetzee C. 2023 Mar 24. Generating a full-length work of fiction with GPT-4. Medium. https://medium.com/@chiaracoetzee/generating-a-full-length-work-of-fiction-with-gpt-4-4052cfeddef3

Q: Can I ask you some questions or collaborate with you on a book or on a research paper?

Mail questions or requests for collaboration to: chiaracoetzee@gmail.com

--

--

Responses (47)