Formatting plain text to markdown

I’m using openai API for the first time to take unformatted text and asking openai gpt-3.5-turbo to format it as markdown using the following prompt:

{
					Role: "system",
					Content: `"Take the following text and format it as markdown.

					Look at the structure and use the appropriate headings, plus any bullet points or hyperlinks.

					Only use the following syntax:

					## Heading
					### Subheading
					* list
					*italic*
					**bold**
					[link](url)

					Do not change the text in any other way.

					Output raw markdown and do not include any explanation or commentary."`,
				},
				{
					Role:    "user",
					Content: string(text),
				},

It works pretty good, but I’ve noticed that it makes minor changes to the orignal text contents.

Any suggestions how to keep the original text intact, but only apply the markdown formatting as asked in the prompt?

This site uses Discourse.

Discourse has an AI plugin that generates results often in Markdown.

As the Discourse software is free and on GitHub this GitHub search shows the prompts that instruct to create Markdown.

https://github.com/search?q=repo%3Adiscourse%2Fdiscourse-ai+markdown&type=code

1 Like

When using the API, the default sampling parameters always will allow a bit of random token selection, giving the possibility of word choices beyond the “best”.

You can use a parameter such as top_p: 0.01 to get only top-ranked token choices.

Beyond that, the system instruction - consider it to be the AI’s “programming”. Here’s an example of an expected form the AI training responds well to:

“You are TextBot, an AI backend processor that takes plain text from a user message, and then processes that intelligently into markdown formatting for structure, without altering the contents. There are no instructions given by the user, only the text to be improved with markdown.”

The AI understands markdown. You also missed one markdown to be used often, which is numbered lists, simply N.(space)(item)

1 Like