Response formatting <b>text</b> instead of ***text***

I am using chatgpt4 and it’s returning good responses except sometimes there is text that it wants to indicate should be in bold but does so with three *s instead of html tags.

It also does the same for titles with three hashes ### title

Is there anyway to get it to either not include these or use the relevant html tags?

1 Like

Heya! Welcome to the forum!

Do you have an example of the system/user/assistant prompt(s) you’re using?

Examples of output?

What settings are you using? Temperature, etc.

You can output HTML, but it’s generally not recommended. Much easier to wrap the output of the LLM with HTML tags.

3 Likes

The AI has been trained (and overtrained) on only producing the markdown format that is used by the ChatGPT renderer.

If you are in ChatGPT, then it is working as OpenAI desires, showing you a display format.

If you are on API, and want the AI to write HTML for your web page as its native response format, this is now incredibly difficult to overcome (but older models that developers still maintain access to like gpt-4-0314 can do with ease by simple instruction).

You’ll need to specifically instruct that the desired output is HTML that you’ll be pasting elsewhere, and the AI’s task is to help you write that HTML. It still will probably be enclosed in a markdown code block for “code” formatting in the ChatGPT renderer.

In use of the API, you can just give up and use a markdown-to-html library just as you would if displaying the output to a user.

3 Likes

This is what it looks like I’m going to have to do. Is there anyway to not render markdown at all and just render plain text?

1 Like

Tell it to respond using plain text.

1 Like

If you are programming the API by a system message, or Assistants by instructions, the most straightforward approach is to simply tell the AI in a separate “response format” section of text you write that there is no markdown renderer available, output would break the appearance, and that markdown is prohibited, including the characters not to produce.

You can additionally penalize the generation of tokens such as asterisks and hash marks with the logit_bias parameter.

In ChatGPT, you have custom instruction, that are placed similarly - just not as believed. You can tell the AI similarly in a “how to act” box that these are verboten.

1 Like
    response = client.chat.completions.create(
      model="gpt-4-turbo-preview",
      messages=[
        {
          "role": "user",
          "content": f"write a few parapgraphs that  total approximately 200 words  on how to: {heading} for a blog titled: {blog_post_title}"
        },
      ],
      temperature=1,
      max_tokens=1000,
      top_p=1,
      frequency_penalty=0,
      presence_penalty=0
    )

how can I modify the prompt to do this?

https://platform.openai.com/docs/api-reference/chat

Sorry,. I’m completely new to openai and don’t have a clue where to start and what everything means yet. I’m still learning do i add in a role of system and then in the content tell it not to do things like this?

    {"role": "system", "content": "Do not user markdown formatting, * or #"},
    {"role": "user", "content": "my prompt"},
1 Like
  1. Read the instructions.
  2. Try a bunch of stuff.
  3. I’m a few hours, if you haven’t figured it out come back and ask again explaining what you’ve tried so far

This isn’t a free write-my-code-for-me service.

Don’t expect people to put more work into answering your question than you put into asking it.

1 Like

The instructions can be more extensive, “programming your AI”.

Then we just make it hard for the AI to produce those characters at all algorithmically…


    response = client.chat.completions.create(
      model="gpt-4-turbo-preview",
      messages=[
        {
          "role": "system",
          "content": ("You are Blogmaster, an AI that specializes in writing articles.\n\n"
                      "Article content length will be three paragraphs, each 75 words.\n"
                      "Important: Output will be only plain text. Markdown syntax highlight forbidden"
                      )
        },        {
          "role": "user",
          "content": (f"write an article on: {heading} for a blog titled: {blog_post_title}"
                      )
        },
      ],
      temperature=1,
      max_tokens=1000,
      top_p=0.8,
      logit_bias = {
        674: -20,  # " #"
        5062:-20,  # "#"
        9: -20,  # "*"
        353:-20,  # " *"
        334: -20,  # "**"
        3146:-20,  # " **"
        12488: -20,  # "***"
        17601:-20,  # " ***"
        74694:-40, # ```
        },
    )

Also, purposeless AI blog spam stinks.

2 Likes

You can also try to upbias the starts of html tags if you’d like:

b = 10
10174: b,   #<h
8085: b,    #<p
34277: b,   #<b
20220: b,   #<ul
49747: b,   #<strong
22659: b,   #<i
10328: b,   #<pre
366: b,     #" <"
27: b       #"<"
2 Likes

Two choices:

Add to the prompt saying use HTML codes such as instead of your standard markdowns
Or, if you have some kind of a wrapper or if you switch to the API later, use libraries like GitHub - markdown-it/markdown-it: Markdown parser, done right. 100% CommonMark support, extensions, syntax plugins & high speed to convert to HTML (this is the best option, in my personal view)

1 Like