Query - Maple Help

NaturalLanguage

 Query
 ask a large language model to answer a question in English and math

 Calling Sequence Query($s$) Query($s$, $\mathrm{mo}$)

Parameters

 $s$ - string, question for the large language model. $\mathrm{mo}$ - (optional) option of the form $\mathrm{model}=m$, where $m$ is $\mathrm{ChatGPT}$ or $\mathrm{GPT4}$.

Description

 • The Query command sends a query to a large language model, attempting to instruct the model to use both natural language and MathML. Maple tries to split the answer into MathML and non-MathML, parse the MathML, and then print the results on screen. The command does not return anything.
 • Maple can interface with OpenAI's GPT-4 and ChatGPT models. The default model is GPT-4; you can select ChatGPT by using the $\mathrm{model}=\mathrm{ChatGPT}$ option, or force use of the GPT-4 model by using the $\mathrm{model}=\mathrm{GPT4}$ option. Note that OpenAI may deprecate and disable models, so the set of models supported may change in the future.
 Note: Large language models often generate inaccurate statements. Please keep this in mind: this is not technology for building a bridge with.

Examples

 > $\mathrm{with}\left(\mathrm{NaturalLanguage}\right):$
 > $\mathrm{Query}\left("What is Pythagoras\text{'} Theorem?"\right)$
 ${"Pythagoras\text{'} Theorem states that in a right-angled triangle, the square of the length of the hypotenuse \left(the side opposite the right angle\right) is equal to the sum of the squares of the lengths of the other two sides. This can be written as: a² + b² = c² where c represents the length of the hypotenuse, and a and b represent the lengths of the other two sides. this formula can be represented as:"}$
 ${{a}}^{{2}}{+}{{b}}^{{2}}{=}{{c}}^{{2}}$ (1)
 > $\mathrm{Query}\left("How do I calculate the Sharpe ratio for financial analysis?",\mathrm{model}=\mathrm{ChatGPT}\right)$
 (2)
 > $\mathrm{Query}\left("What is the volume of a partially filled sphere?"\right)$
 ${"The volume of a partially filled sphere, also known as a spherical cap, can be found using the following formula: V = \left(\pi h^2 / 3\right)*\left(3r - h\right) where: - V is the volume of the spherical cap, - h is the depth or height of the liquid in the sphere \left(from the top of the sphere to the surface of the liquid\right), and - r is the radius of the sphere. Note that r and h must be in the same units \left(e.g., all in inches or all in centimeters\right) for the formula to work."}$
 ${V}{=}\frac{{\mathrm{\pi }}{}{{h}}^{{2}}{}\left({3}{}{r}{-}{h}\right)}{{3}}$
 ${"Remember that this formula considers that the sphere is sitting with its base on a surface and is not so appropriate if the sphere is floating in space."}$ (3)

References

 The OpenAI website.

Compatibility

 • The NaturalLanguage:-Query command was introduced in Maple 2024.