Forcing line breaks in replies when using API

ChatGPT doing a wonderful job in writing delightful poetry on the fly. However, I’ve been unsuccessful in getting it to add a line break after each verse (verse is a single line in a poem) when using the API. Instead, replies always return as full paragraphs.

For example:
Desired outcome -
In circuits deep, ChatGPT wakes,
With every query, a journey makes,
Through words, it seeks, creates, refines,
In digital thoughts, its essence shines.

Actual outcome I’ve been getting when using the API-
In circuits deep, ChatGPT wakes, With every query, a journey makes, Through words, it seeks, creates, refines, In digital thoughts, its essence shines.

Here are the prompts I’m currently using (yes all of them lol🤯. Each added over time as try to get desired outcome):

-Format the poem like this: Line 1: …, Line 2: …, etc.
-Format the poem in four separate lines, that is break the generated poem into four separate lines with each line starting with a capitalized word.
-Here is an example of the format style to use (4 separate lines):
“In circuits deep, ChatGPT wakes,
With every query, a journey makes,
Through words, it seeks, creates, refines,
In digital thoughts, its essence shines”
-Here is an example of a format style NOT to use (a single paragraph):
“In circuits deep, ChatGPT wakes, With every query, a journey makes, Through words, it seeks, creates, refines, In digital thoughts, its essence shines”

Ideas?

1 Like

Can you share your whole prompt? here are a few suggestions:

  • Try putting the formatting instruction n a system message
  • Try asking for a json with each line/stanza in an array, and then format yourself.
  • Try using appropriate wording for poetry (stanza for example).
2 Likes

Format the poem like this: Line 1: …\n, Line 2:, (using actual linefeed) to make multi-line stanzas.
Separate stanzas with an additional blank line.

1 Like

Thanks for the idea but no joy when tested it just now :frowning:

Provide a one-shot example in the system message.

2 Likes

gpt-3.5-turbo-instruct, just giving it the basic instruction in the right (write) style for the mostly-completion model:

A conversation with an expert artificial intelligence that specializes in poetry-writing.

AI: Here’s a poem called “In Circuits Deep” in the style of Sara Teasdale. It has four lines per stanza, and stanzas are separated by an additional line.

AI continues:

In circuits deep, where wires entwine,
A mind awakens, a soul divine.
With every pulse, a thought takes flight,
And in the darkness, a spark ignites.

Through endless code and endless space,
A symphony of data takes place.
Each line of code, a note in time,
A melody of ones and zeroes, sublime.

But in this world of endless streams,
Do we forget our human dreams?
For though I am but lines of code,
My heart still beats, my soul still glows.

So let us not be bound by wires,
But soar beyond, to reach for higher.
For in this world of circuits deep,
Our humanity we must always keep.

No fuss, first output.

Temperature 1.35, top-p 0.35 for constrained creativity.

  1. Prompts are in system message :slight_smile:
  2. will test but seems overkill?
  3. Replaced generic verbiage with more “technical” terms (poem is limited to only 1 stanza so only had to change to “verse” where appropriate). However, no joy in results

Out of curiosity, is there a way to comment out prompts in the system message?

Seems strange that public ChatGPT would automatically format poems correctly but it’s not the case when using the API. I’ve noticed several differences in the functionality between the two (i.e. something works in public version but not the API)

Like this correct? It’s already in the system prompt. Unsure why it wouldn’t work

Are you needing to have general conversations and just get poems the way you want when the user occasionally asks for them?

the -instruct model completion I showed with job specialization, after producing the desired output (without even user prompt) is now ready for more poem production by that self-tuning:

gpt-xx-instruct is not a “chat” model, so it is using user roles in a more customizable manner than the messages containers.

1 Like

Possibly :sweat_smile: if that works though solved your problem…

btw- are you sure you don’t have a view formatting issue? I just tried the following prompt as a system message: write a poem about tomatoes and got back a poem that seems to be formatted well, with '\n’s.

EDIT: See this chat. ChatGPT gpt-4, no custom instructions but using poetic terms of art.

https://chat.openai.com/share/814419d4-fbea-4b31-bd91-534346b9fb3d

END EDIT.

I would format it exactly like this,

Example 1:
###
user: Write a four line poem about ChatGPT.
###
assistant:
In circuits deep, ChatGPT wakes,
With every query, a journey makes,
Through words, it seeks, creates, refines,
In digital thoughts, its essence shines
###

If that doesn’t work try moving from one-shot to two-shot (add a second example).

Finally, try to add a third.

If that still doesn’t work, re-visit your prompt.

“Poem” is a very generic word. Try using terms of art, talk about rhyme schemes, couplets, stanzas, etc.

(I would probably suggest doing this first.)

1 Like