OAI forcing the models to use LaTex for calc response, but I don't need LaTex

Hello,
The title describes the issue better. I’ve had tones of issues with INSTRUCTING the models to never use LaTex in their response but this is just a bold instruction that’ll get ignored when the model returns the output. It’s surprising the the confidence the models have in using this even when they were clearly told not to do so.

I do understand LaTex is perfect in many cases but let it not seem like the models are hard-coded to never deviate from LaTex for calculations. At one point I moved to other alternatives and am back because I was waiting for an updated Assistants API but please, however much I try, the models won’t stop answering with LaTex for calculations.

It’s like the end dev has to put in more efforts to beautify the LaTex for their clients which is added pain. How much work would that be to build it to look nicely in a WhatsApp Chat? Build the response in an Image? How much work will that be, putting into consideration is this response going to fit in one image or not etc ?. If there’s anyone who knows the system prompt that works to tell the model not to format the response in LaTex I’m more than happy to accept it, as all my attempts have failed. I’ve been suffering with this since Dec 2023.

With need for the updated Assistants API came the burden once again.

1 Like

Depending on the model you are using.

But gpt-4-turbo-2024-04-09 (currently “gpt-4-turbo” points to gpt-4-turbo-2024-04-09) seems to follow the system message better than the “gpt-4-turbo-preview” model (currently “gpt-4-turbo-preview” points to gpt-4-0125-preview), as far as we know.

In my case, I was able to avoid using LaTeX symbols with the following system message:

Use symbols such as '+ - * / ’ or ‘=’, and never use LaTeX symbols or backslashes.

1 Like

This much…

Make a bash script,

latex2png.sh

#!/bin/bash
MATH_EXPRESSION="$1"
LATEX_DOCUMENT="\documentclass{standalone}
\usepackage{amsmath}
\begin{document}
$ $MATH_EXPRESSION $
\end{document}"
echo "$LATEX_DOCUMENT" | latex -jobname=math \
&& dvipng -D 800 -o math.png math.dvi \
&& rm math.dvi math.log math.aux
echo "PNG file created: math.png"

Then, parse each math chunk individually to get the \LaTeX code for an individual math expression and pipe it through your script.

E.g. from,

\int_0^\infty e^{-x^2} dx = \frac{\sqrt{\pi}}{2}

you would extract \int_0^\infty e^{-x^2} dx = \frac{\sqrt{\pi}}{2}

and send it to your script,

./latex2png.sh "\int_0^\infty e^{-x^2} dx = \frac{\sqrt{\pi}}{2}"

to get,

Which you can resize as necessary.

1 Like