Indeterminate Latex Behavior

Hi, sometimes when I ask a question in GPT3.5, I’ll ask for Latex equations and I get get beautifully rendered Latex in response. Other times, I get raw Latex. What I want at the moment in raw Latex as shown in panel 2 in the attached picture. But mostly I’m getting what is shown in panel 1. The rendering seems to be taking place in the browser (Chrome without any plugins) and downloaded as part of the response (via Katex). Any idea how to switch between response 1 and 2?

2 Likes

Welcome to the forum!

Have you seen New feature: Properly shown mathematical equations?


To see the raw data passed in the JSON reply use the export data option in settings.

image

Example

    {
        "title": "Convert 1VRMS to dBV",
        "create_time": 1689448158.554543,
        "update_time": 1689448164.0,
        "mapping": {
            "f0b5291f-df6b-4d48-97c8-cf91adfa0e1c": {
                "id": "f0b5291f-df6b-4d48-97c8-cf91adfa0e1c",
                "message": {
                    "id": "f0b5291f-df6b-4d48-97c8-cf91adfa0e1c",
                    "author": {
                        "role": "system",
                        "name": null,
                        "metadata": {}
                    },
                    "create_time": 1689448158.554944,
                    "update_time": null,
                    "content": {
                        "content_type": "text",
                        "parts": [
                            ""
                        ]
                    },
                    "status": "finished_successfully",
                    "end_turn": true,
                    "weight": 1.0,
                    "metadata": {},
                    "recipient": "all"
                },
                "parent": "aaa11431-70b4-4846-81db-161d0dcf5133",
                "children": [
                    "aaa20709-bd4c-496a-bd96-3b4dd98f4b27"
                ]
            },
            "aaa11431-70b4-4846-81db-161d0dcf5133": {
                "id": "aaa11431-70b4-4846-81db-161d0dcf5133",
                "message": null,
                "parent": null,
                "children": [
                    "f0b5291f-df6b-4d48-97c8-cf91adfa0e1c"
                ]
            },
            "aaa20709-bd4c-496a-bd96-3b4dd98f4b27": {
                "id": "aaa20709-bd4c-496a-bd96-3b4dd98f4b27",
                "message": {
                    "id": "aaa20709-bd4c-496a-bd96-3b4dd98f4b27",
                    "author": {
                        "role": "user",
                        "name": null,
                        "metadata": {}
                    },
                    "create_time": 1689448158.564226,
                    "update_time": null,
                    "content": {
                        "content_type": "text",
                        "parts": [
                            "convert 1vrms to dbv, using latex"
                        ]
                    },
                    "status": "finished_successfully",
                    "end_turn": null,
                    "weight": 1.0,
                    "metadata": {
                        "timestamp_": "absolute",
                        "message_type": null
                    },
                    "recipient": "all"
                },
                "parent": "f0b5291f-df6b-4d48-97c8-cf91adfa0e1c",
                "children": [
                    "996e5f77-a378-4eee-bcb4-3d200e993d63"
                ]
            },
            "996e5f77-a378-4eee-bcb4-3d200e993d63": {
                "id": "996e5f77-a378-4eee-bcb4-3d200e993d63",
                "message": {
                    "id": "996e5f77-a378-4eee-bcb4-3d200e993d63",
                    "author": {
                        "role": "assistant",
                        "name": null,
                        "metadata": {}
                    },
                    "create_time": 1689448163.250617,
                    "update_time": null,
                    "content": {
                        "content_type": "text",
                        "parts": [
                            "To convert 1Vrms to dBV, you can use the following formula:\n\n\\[\n\\text{dBV} = 20 \\log_{10}\\left(\\frac{{V_{\\text{rms}}}}{{1 \\, \\text{V}}}\\right)\n\\]\n\nwhere:\n- dBV is the decibel value referenced to 1V,\n- \\(V_{\\text{rms}}\\) is the root mean square voltage.\n\nSubstituting \\(V_{\\text{rms}} = 1 \\, \\text{V}\\) into the formula, we get:\n\n\\[\n\\text{dBV} = 20 \\log_{10}\\left(\\frac{{1 \\, \\text{V}}}{{1 \\, \\text{V}}}\\right) = 20 \\log_{10}(1) = 20 \\times 0 = 0 \\, \\text{dBV}\n\\]\n\nTherefore, 1Vrms is equivalent to 0 dBV."
                        ]
                    },
                    "status": "finished_successfully",
                    "end_turn": true,
                    "weight": 1.0,
                    "metadata": {
                        "finish_details": {
                            "type": "stop",
                            "stop": "<|diff_marker|>"
                        },
                        "is_complete": true,
                        "message_type": null,
                        "model_slug": "text-davinci-002-render-sha",
                        "timestamp_": "absolute"
                    },
                    "recipient": "all"
                },
                "parent": "aaa20709-bd4c-496a-bd96-3b4dd98f4b27",
                "children": []
            }
        },
        "moderation_results": [],
        "current_node": "996e5f77-a378-4eee-bcb4-3d200e993d63",
        "plugin_ids": null,
        "id": "52b07db1-7a29-4938-8c59-cc3feec0d307"
    }
1 Like

The code interpreter has this new language, informing of UI compatibility. You can add that to your prompt or conversation history as behavior when you give a new role of how to act.

Math Rendering: ChatGPT should render math expressions using LaTeX within (…) for inline equations and […] for block equations. Single and double dollar signs are not supported due to ambiguity with currency.

I’m a bit confused here. It would be great if you could provide a working example to help me understand better.

Working example:

https://chat.openai.com/share/b6c0cbe4-9090-42c8-ba22-2663b93d8774

Nice example


I’m a bit confused by the mention of the “code interpreter” - it seems like unnecessary information that’s causing my confusion. Could you please clarify its relevance?

Code interpreter is given more system prompt instructions than normal ChatGPT.

One of those instructions is to clarify the capabilities the ChatGPT web site renderer always had.

Instead of writing our own “You can use LaTeX for output, but only in short sections”, one can instead use the text we know reshapes behavior.

You can also write your own LaTeX fun, like getting it to output colors and different fonts.

Thanks for the link. But my question isn’t how to show the processed/rendered Latex (it seems to do that fine). My question is how to get it to emit Latex but not render it (which it does sometimes, and it looks like the attached session below). But I can’t figure out how to make it emit but not render all the time. Any ideas? Thanks!

image

Sorry for misreading; that’s an unexpected case for a ChatGPT user, as it neither produces a complete latex document, nor makes human-readable output.

I’ve added to whatever your question is:

Output will be raw unrendered LaTeX code, encapsulated in blockquote markdown (```) .

If you don’t want an entire document you can cut and paste, you can specify the particular segments to be output:

Generate Maxwell’s equations. Output math expressions as raw unrendered LaTeX code, encapsulated in blockquote markdown (```) . AI explanations will be unenclosed.

As far as “all the time”, because of ChatGPT’s poor memory, the most reliable way is to specify with every prompt you input. You can make a new identity, but it will be forgotten as quickly as the princess you wanted to chat with unless you use memory tricks:

You will now act in a new roleplay scenario as HawkingBot, an AI assistant that specializes in science and engineering for advanced users. Before every output, you will prefix the line "[HawkingBot is following your rules to always output complex equations as raw un-rendered LaTeX, which is then enclosed in a Markdown code block]

Will you always be using the prompt with ChatGPT as a human or do you plan to eventually use it with an API?

The reason for the question is that with some experimentation I find this variation of the prompt

Can you print all of Maxwell’s equations as LaTeX , enclose LaTeX in quotes.

generates what you seek more consistently but still fails occasionally (prints at formatted LaTeX instead of raw LaTeX) but when it does fail, a click of

image

likely generates the raw LaTeX as needed. Obviously the API does not check for the correct format and does not retry the prompt when the format is invalid.

Hey Matthew,

The GPT window uses a markdown renderer. So whenever I want the results to be rendered rather than explained to me, I use “Using renderable markdown …”. I haven’t had problems but I haven’t experimented with Latex to be honest.

I’ve tried it with this:

Using markdown renderable latex, please show the q learning equation.

And it seems that my technique extends to Latex. You should give that a try and see if it helps you.

I tried that prompt which gave

image

Is that what you expected it should be?

The OP actually doesn’t want the LaTeX rendered they want the raw LaTeX as demonstrated in their example.

image

1 Like

Oh sorry, I misunderstood and didn’t read all of the posts.

In that case you will have to do the opposite of what I said.

Using latex within a markdown renderable code block, please show the q learning equation. Please use the correct code block label for latex

I’m thinking about why @matttay might want this and I am coming up with 2 main reasons.

  • For personal use as an assistant in making papers or something.
  • As a product where he needs the raw latex for a plugin or something.

If it is the first one, then my example should be sufficient enough, but if it is the second one, then I’d maybe ask for a specific format that can be easily parsed and manipulated in code. Either way, I’d experiment with asking for some specific format that is either markdown renderable or some other common format that can be explained with a couple of words.

But I am curious now, what are you using it for?