Write AI prompts as if they were programs
Did you know that you can write LLM prompts as if they were programs? You can pretty much use any language you like, or make one up (pseudo-code) as long as it makes sense. The pattern matching capabilities on a language model will figure out what you are trying to direct, and it will execute (a variation) on what you have asked it to do. It will not be quite the same each time (and that might be a feature).

Did you know that you can write LLM prompts as if they were programs? You can pretty much use any language you like, or make one up (pseudo-code) as long as it makes sense. The pattern matching capabilities on a language model will figure out what you are trying to direct, and it will execute (a variation) on what you have asked it to do. It will not be quite the same each time (and that might be a feature).

 

 

Programatic Poetry

--------------------

 

For example, you could ask an LLM:

 

Write a short poem: haiku about love in English.

 

Or you could programmatically direct it to write three types of poems in three languages about three subjects. It will give you most of the combinations. Here is how you do it.

 

First, I define the poem types to produce. I imagine a variable name for this called "poem_type" and I present the types in a Json format:

 

{ "poem_type": [{ "name": "haiku" }, { "name": "lymeric" }, { "name": "sonnet" }] }

 

 

I do something similar for poem subjects and languages:

 

{ "subject_type": [{ "name": "love" }, { "name": "anger" }, { "name": "music" }] }

{ "language": [{ "name": "Japanese" }, { "name": "English" }, { "name": "Italian" }] }

 

 

 

Then you describe the logic for what to do with this data, referring to it in a logical fashion. I copied the style of mustache logic-less templates to create three levels of nested loops. If this were a program we would expect 3 x 3 x 3 = 9 different poems to be produced. But an LLM will do as many as it likes, and your output might get cut off due to context window limitations.

 

 

Write a short poem:

 

{{#poem_type}}

{{#language}}

{{#subject_type}}

 

{{poem_type.name}} about {{subject_type.name}} in {{language.name}}:

 

{{/subject_type}}

{{/language}}

{{/poem_type}}

 

 

Cut and paste all this into SkyDeck's GenStudio workspace and select an LLM like OpenAI GPT-4 or Anthropic Claude2 and you will get a result like this:

 

Certainly! Below are short poems according to your template:

 

Haiku about Love in Japanese:

 

愛の風

ふわりと舞い降り

春の日

 

(Ai no kaze

fuwari to maifuri

haru no hi)

Tags
AI
3450
Share this
Leave a comment
There are no comments about this article, let us know what you think?

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.