jupyter-ai
jupyter-ai copied to clipboard
Improve math magics behavior
Desired behavior is to get something legible. . .
Content in the cell to reproduce. (See Image below).
%%ai -f math gpt4
write a kalman filter
@startakovsky Thanks for opening this issue! The -f math option presumes that the response is entirely in LaTeX format. Descriptive text, as you've seen, is not rendered properly in LaTeX mode. What do you see if you run your prompt without the format option (example 1 below) or with more prompting hints (example 2 below)?
Example 1
%%ai gpt4
write a kalman filter in LaTeX format
Example 2
%%ai -f math gpt4
write a kalman filter. Only include mathematical expressions in LaTeX format. Do not include any explanatory text before or after the expressions.
Yes, I see what you're saying @JasonWeill , but I am confused because Latex natively supports normal non-math expression text, as the example below indicates.
\documentclass{article}
\begin{document}
The well known Pythagorean theorem \(x^2 + y^2 = z^2\) was
proved to be invalid for other exponents.
Meaning the next equation has no integer solutions:
\[ x^n + y^n = z^n \]
\end{document}
But also even when working with strictly math mode, which I think you meant:
$$\[
x = 4 \text{ or it's also possible to make sentences that aren't squished together and italicized } x = 5
\]$$
$$[ x = 4 \text{ or it's also possible to make sentences that aren't squished together and italicized } x = 5 ]$$
So really what I'm getting at, is I think there can be a modification to the prompt template to be super explicit about using \text or something to that effect, perhaps with an example or something. This will greatly improve the user experience, if you can make it happen.
Thanks for clarifying! Prompt templates are now customizable, now that #581 has been merged in, so if you find a template for math mode that yields better-quality mixed math and text output, as you've shown above, please open up a pull request. Note that a prompt template can be at the level of a single model provider.
Very cool. Thanks, why don't we go ahead and close this then unless you're saying there is a clean way I can provide an idea around a prompt template and submit it to the core repo?
Let's leave this open; it may be possible to solve this with prompt engineering related to the prompt template, and we would consider pull requests related to this. Thanks again for your contribution!