Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve math magics behavior #662

Open
startakovsky opened this issue Mar 1, 2024 · 5 comments
Open

Improve math magics behavior #662

startakovsky opened this issue Mar 1, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@startakovsky
Copy link
Contributor

Desired behavior is to get something legible. . .

Content in the cell to reproduce. (See Image below).

%%ai -f math gpt4

write a kalman filter
image
@startakovsky startakovsky added the bug Something isn't working label Mar 1, 2024
@JasonWeill
Copy link
Collaborator

@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.

@startakovsky
Copy link
Contributor Author

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.

@JasonWeill
Copy link
Collaborator

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.

@startakovsky
Copy link
Contributor Author

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?

@JasonWeill
Copy link
Collaborator

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!

@dlqqq dlqqq changed the title %%ai -f math gpt4 seems to work poorly Improve default math magics prompt template Mar 4, 2024
@dlqqq dlqqq changed the title Improve default math magics prompt template Improve math magics behavior Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants