How to stop chagpt from using code blocks and markdown in general?

I tried to create a chat that does nothing more than to generate code from user messages with a system message that tells it to be a code assistant, that only outputs compiler ready code and is not formatted with markdown explicit. I wonder if there is some sort of after processing that does the formatting…

You have two options,

  1. Create a fine-tuning
  2. Use few-shot, in-context learning to teach it what you want.

But, you should be aware that it’s pretty squirrelly and you’ll never be able to guarantee that it never goes rogue.

It’s a large language model fine-tuned for conversation.

1 Like

You may want to consider the markdown formatting a “feature” as it lets you easily filter GPT’s response, removing any explanation or notes about the code. Remove everything before and after the ``` symbols in your code after receiving the response.

Otherwise adding this to prompt generally gets good results for me most of the time. But again sometimes it will include a brief note, so maybe don’t fight against the markdown format and handle it in your code.

Your responses should only be code, without explanation
or try
Your responses should only be code, without explanation or formatting

I dont remember exactly, but in python you can set flags to supress post text and pretext and just retrieve code blocks.

Add to your prompt:
“Output only plain text. Do not output markdown.”

In general, negative-prompting a language model isn’t very effective.

What does work though is providing one or two concrete examples in the exact format you want.