Open RomneyDa opened 1 week ago
Some thoughts and tinkering on this
latex expression start/end delimiters:
recognized by remarkMath:
$
end $
$$
end $$
causes truncation issues in remarkMath:
$$\n
end $$\n
not recognized by remarkMath:
square brackets: start [ end ]
parentheses: start ( end (
\begin{equation} ... \end{equation}
\begin{align} ... \end{align}
\begin{gather} ... \end{gather}
\begin{math} ... \end{math}
\begin{displaymath} ... \end{displaymath}
a robust output solution could be to add a message to the system prompt requesting to use "double inline dollar sign syntax for all latex math output", and then disable single dollar sign support in the remarkMath plugin (its only option) downsides:
will probably make the model way more likely to unnecessarily output latex
not very what-you-see-is-what-you-get
adds tokens
a safer parsing solution might be to replace all delimiters except brackets and parentheses with inline $$ and only replace single $ in the case that they are closed with another $ inline downsides
perhaps the best overall solution would be to add a config.ui boolean enableLatexMath (default false) that people can turn on if they are working with latex, and perhaps combine with the parsing option above. This is more what-you-see-is-what-you-get but less beautiful out of the box. Would eliminate unexpected latex output with multiple $, etc. Also would eliminate problem where awkwardness with asking model to write latex and not seeing delimiters
all being said, I think latex math output in a coding environment is somewhat edge casey, and for now I will just do a minor fix for the $$\n truncation issue, since I think the options without a UI config option are signicifant what-you-see-is-what-you-get violations
@Patrick-Erichsen mentioned:
The "robust" solution is interesting. I guess I'm uncertain how casually we want to add instructions to the system prompt for misc formatting things like this. Unnecessary latex output would also be my concern. The config option is also nice, and agreed that it's probably a small subset of people that are frequently working with latex. Overall I think I lean towards the sys prompt though just to avoid chat feeling "broken" as the default experience for folks working with latex. Worst case is we start to notice unnecessary latex output and we remove it.
Validations
Problem
Latex math isn't rendering Seems like this has been attempted before but isn't working reliably for anything more complex than e.g. x^2 See example here https://discord.com/channels/1108621136150929458/1310668425093451848/1310668425093451848
Solution
No response