avatarAli Aslam

Summary

The article discusses the Infinite Generation Pattern, a method for prompt engineering that enables ChatGPT to produce continuous output based on a template with user-provided variations.

Abstract

The Infinite Generation Pattern is a technique in prompt engineering designed for scenarios where a large volume of output is needed from ChatGPT without repeated prompts. This pattern is particularly useful for tasks such as generating multiple URLs for a synonym website, where the user wants to maintain a consistent prompt template but introduce variations through additional inputs. The key elements of this pattern include instructing the language model to generate outputs indefinitely, specifying the number of outputs per cycle, and providing guidance on how to incorporate user input between cycles. The process continues until the user signals to stop. This approach is beneficial for maintaining context while allowing for dynamic input-driven variations, thus enhancing the efficiency of content generation.

Opinions

  • The author views the Infinite Generation Pattern as a practical solution for generating a large number of outputs with minimal user intervention.
  • The pattern is seen as a way to leverage ChatGPT's capabilities while managing output volume to avoid memory or limit overruns.
  • The method is considered effective for creating structured outputs, such as URLs, that require consistent formatting with dynamic content.
  • The author suggests that this pattern can be customized with a "magic word" to provide a clear stopping point for the generation process.
  • The article implies that combining the Infinite Generation Pattern with other prompt patterns, like the template pattern, can lead to more sophisticated and automated content generation.

Prompt Engineering via Prompt Patterns — Infinite Generation Pattern

The article is part of series: Prompt Engineering via Prompt Patterns

You can switch to video version of this article

There are certain use cases where you need a lot of output from ChatGPT without having to prompt it again and again with the same request. In most cases where it is required, the user is trying to keep an initial prompt template, but introduce variations to it through additional inputs prior to each generated output.

An example can be that you are creating a synonym website and want to create urls for each page, something like http://mysynonymexamplesite/SAD/synonym/UNHAPPY and http://mysynonymexamplesite/SAD/synonym/DEPRESSED and so on. Now ideally you would like to tell the LLM template to generate url one, and then you only want to provide the main word, and get a list of urls for all possible synonyms of main word in one go. The way to go about it is to use the infinite generation pattern.

The key contextual statements for this pattern look like

1. I would like you to generate output forever, X output(s) at a time

2. (Optional) Here is how to use the input I provide between outputs

3. Stop when I ask you to.

The first statement specifies that user wants LLM to generate output indefinitely, which essentially means the same prompt would be used over and over. The X output(s) at the time helps to avoid memory or limit overrun of LLM in case the outputs produced are so many that they exceed output limit. The limit can be user requirement as well.

The second statement instructs how input provided by user between outputs is going to be used. This allows user to introduce variations or custom input to alter the initial prompt in some intended way. Essentially coming up with a prompting strategy that produces desired output based on user input in between outputs. The output would still be generated in context of original input, but user input between outputs would be used to alter it in intended way.

The third statement is just providing an optional way for user to stop the infinite output process. This is strictly optional and situation dependent. If the word ‘stop’ can be interpreted as user feedback between outputs, then user should specify a magic word to put the chatgpt outputs to an end with that word or phrase.

Taking the synonym example discussed earlier, we can come up with an initial prompt which would combine the template pattern with infinite output pattern like below

From now on, you would be generating URLs for synonyms of input words I provide using a template I provide for the output. Everything in all caps is a placeholder. You would continue to prompt me for next input word until I say ‘please stop’. Please preserve the formatting and overall template that I provide. The template is

http://mysynonymexamplesite/INPUT/synonym/SYNONYM

Now ChatGPT would continue to generate urls for synonyms and prompting you for next word, until you say ‘please stop’. I deliberately introduced the word input from user to convey the user input point, otherwise you can simply modify it to generate urls for each word in dictionary say 10 at a time, until you say stop. The template would need slight change and it would work as expected.

This is it for infinite generation pattern. If you found this informative, please clap/share the article. You can also consider subscribing to our YouTube channel as well. Thank you!!!.

Next article: Prompt Engineering via Prompt Patterns — Visualization Generator Pattern

Templated Generation
Infinite Generation
ChatGPT
Prompt Engineering
Prompt Patterns
Recommended from ReadMedium