19
$\begingroup$

It would be great if one could come up with a interface to Mathematica documentation (or possibly this site) in the spirit of ChatGPT?

We have Wolfram alpha to answer direct mathematical questions in plain language but it is not (?) directly interfaced to the language's help system which is becoming a bit big to browse.

At some stage this is a question for Wolfram but...

can we as a community define the precise requirement of such an interface? Or write a prototype which grep within the documentation?

The output could be as extensive as Wolfram alpha.

In some sense this question is the opposite of that answer which gives details beyond what is in the (standard) documentation.

It is also the opposite of the SummarizeDefinition function


To be a bit more specific, sometimes to find information in the documentation you need to know the jargon or specific keyword that was implemented within mathematica. It would therefore be great to have a chatbot which could 'linguistically understand' the concept and find the synonyms which are actually used within the Documentation.


Note added 23/3/23: it seems some of the issues are addressed by Wolfram's blog as, I quote, "chatgpt gets its wolfram superpowers".


Update: Mathematica 13.3 provides the answer straight out of the box with a LLM code assistant

enter image description here

$\endgroup$
8
  • $\begingroup$ One of my requirements would be that the answers are correct, both in content and syntax. This seems like a rather high bar to jump at this point. $\endgroup$
    – Roman
    Mar 10, 2023 at 21:13
  • $\begingroup$ @Roman of course that would ideally be the case; but if the learning is done in the documentation and it links to the documentation it will be at best as good as the documentation (?) $\endgroup$
    – chris
    Mar 10, 2023 at 21:16
  • 3
    $\begingroup$ Is this the right site for this question? Maybe the meta site instead? $\endgroup$
    – lericr
    Mar 10, 2023 at 21:18
  • 1
    $\begingroup$ I’m voting to close this question because it takes a decade of research to come up with something such as an AI interface to another software. Questions that are typically posted and answered here are considerably limited in scope. $\endgroup$
    – Syed
    Mar 11, 2023 at 2:52
  • 2
    $\begingroup$ I would like to have a simpler feature; being able to track my own documentation usage with a history list. We all remember the time when we started searching for MS Office docs using Google and indeed it got more and more effective over the last 15 years. Something similar for Mathematica would perhaps also become a reality through external means. $\endgroup$
    – Syed
    Mar 11, 2023 at 3:19

3 Answers 3

9
$\begingroup$

This is not a full answer but a starting point, which illustrates both the strength (it looks reasonable) but also the strong limitation of present day chatbot in producing correct Mathematica code.

Indeed, using

  PacletInstall["ChristopherWolfram/OpenAILink"]
  Needs["ChristopherWolfram`OpenAILink`"]
  $OpenAIKey = "<sk-.... your key>" 

as described here, I can define a new function, ChatHelp as

ChatHelp[str_] := 
 Normal[PacletSymbol[
    "ChristopherWolfram/OpenAILink", 
     "ChristopherWolfram`OpenAILink`OpenAIChatComplete"][
    PacletSymbol[
     "ChristopherWolfram/OpenAILink", 
        "ChristopherWolfram`OpenAILink`OpenAIChatMessageObject"]
["user", str <> " in Mathematica"]]][[1, 2, 2]]
 

So that we can ask

  ChatHelp["hypergeometric functions"]

or

  ChatHelp["How to do Symbolic Integration?"]

which produces


enter image description here

One can iterate the same query, as in

ChatHelp["hypergeometric functions?"]
ChatHelp["hypergeometric functions?"]

or provide the chatbot with different details to get different answers; e.g.

ChatHelp["How to plot a graph?"]

gives a different answer than

ChatHelp["How to plot a graph with vertices?"]

Note that it can answer relatively complex queries such as:

ChatHelp["How to solve heat equations in cylindrical coordinates?"]

but the code it produces is not operational!

enter image description here


If I ask it to tell me about sines and cosines, as in

ChatHelp["sines and cosines"]

it writes:


  1. To plot the sine and cosine functions over an interval of -[Pi]
    to [Pi]:

    Plot[{Sin[x], Cos[x]}, {x, -[Pi], [Pi]}]

Output:

sine_cosine_plot


which is plain weird since the link it produces does not exist! It does suggest that the chatbot seems to have learnt from stackexchange outputs given the syntax it uses.


In closing, note that one could use such function to automatically produces tons of apparently appealing, but in practice garbage answers on mathematica.stackexchange! Something to think about!

May be one solution would be

  1. for mathematica/wolfram to parse and validate the code before the answer is produced?
  2. and/or train the chatbot on the documentation only?
$\endgroup$
2
  • 1
    $\begingroup$ Several interesting WL solutions generated by ChatGPT in this post on the Wolfram Community site. $\endgroup$ Apr 13, 2023 at 23:57
  • $\begingroup$ @RohitNamjoshi Thanks! I guess if the WolframPluggin becomes part of mathematica and the answers are full proved by mathematica it would completely answer my question! $\endgroup$
    – chris
    Apr 14, 2023 at 8:57
7
$\begingroup$

In addition to OpenAILink in the Wolfram Paclet Repository (see answer here by @chris), there is also an option via the Wolfram Function Repository. I did not want this answer to get lost in the comments, so here it is.

Function BirdChat in Wolfram Function Repository Open a notebook to chat with a cool bird Contributed by: Richard Hennigan (Wolfram Research)

and very similar:

Function AIAssistant in Wolfram Function Repository Open a notebook to chat with an AI programming assistant Contributed by: Richard Hennigan (Wolfram Research)

First of all, BirdChat requires an API key from OpenAI. Storing the API key with

SystemCredential["OPENAI_API_KEY"]="key" 

will make the key persistently available to BirdChat. Doc with examples you can find on the page I linked. I just will note that there are different modes. From simple usual expected chat

enter image description here

to using special prompt and the ChatGPT acting as kernel simulation (example under the "Neat Examples" section):

enter image description here

$\endgroup$
9
  • 1
    $\begingroup$ That's neat! I had seen the BirdChat function but misunderstood it's scope! It seems its a good assistant. $\endgroup$
    – chris
    Apr 2, 2023 at 18:42
  • $\begingroup$ Unless I am mistaken, Birdnardo is just as bad in practice: it produces codes which look even better but still do not work! I tried give me an example of NeuMannValue. $\endgroup$
    – chris
    Apr 2, 2023 at 19:14
  • 1
    $\begingroup$ @chris do you expect LLM to give you always correct answer? These are statistical models and it is very early days, it will get better, but as principle one needs to prompt ChatGPT properly to debug and then even maybe self-test which is possible with OpenAI Wolfram Plugin. Similar how you do with humans :-) At least how I understand this. Example of some debugging $\endgroup$ Apr 3, 2023 at 3:46
  • $\begingroup$ I guess I am an optimist. I find NeuMannValue formulation un intuitive so I was hoping AI would help me but it seems as confused as I am ! In any case this bird thing is going very well the packaging. At the end of the day is its as good as LLM, which is to say not good enough as far as I can tell. Thanks again! $\endgroup$
    – chris
    Apr 3, 2023 at 7:48
  • 1
    $\begingroup$ @chris the answers produced are by ChatGPT, not kernel, they are just formatted as Out[]. $\endgroup$ Apr 4, 2023 at 4:29
6
$\begingroup$

I was prompted to proclaim the paclet "OpenAIMode" here. :)

Here is a related presentation recording: "OpenAIMode demo".


Here is an example of how to find "help" within a Mathematica notebook using ChatGPT:

enter image description here

If the paclets "OpenAILink" and "OpenAIMode" are installed here is the WL code:

Needs["AntonAntonov`OpenAIMode`"]

OpenAIMode[]

SetOptions[OpenAIInputExecuteToText, OpenAITokenLimit -> 120];

Here is the OpenAI cell content:

How can use Flatten's second argument in Mathematica?

Lying with ChaptGPT

[...] The blog idea sounds controversial enough! (lying sounds strong, confused certainly!)

Using different temperature settings can produce statements that lie -- or are off-topic -- to different degrees:

enter image description here

$\endgroup$
7
  • 1
    $\begingroup$ Could you please give a bit more details in your answer? Thanks! $\endgroup$
    – chris
    Apr 2, 2023 at 19:16
  • $\begingroup$ @chris Is my update providing sufficient level of detail? :) If not, then I will make an extensive blog post titled "When ChatGPT lies about WL functions." $\endgroup$ Apr 2, 2023 at 20:54
  • $\begingroup$ Could you please specify as well how does one get the chatGPT prompt? The blog idea sounds controversial enough! (lying sounds strong, confused certainly!) $\endgroup$
    – chris
    Apr 3, 2023 at 8:02
  • $\begingroup$ @chris "Could you please specify as well how does one get the chatGPT prompt? " -- Use "Shit+|" to create a text completion cell; use "Tab" to convert a text completion cell into an image generation cell. (That is pointed out in the paclet details and in the demo video.) $\endgroup$ Apr 3, 2023 at 13:34
  • $\begingroup$ @chirs "[...] The blog idea sounds controversial enough! (lying sounds strong, confused certainly!)" -- see my update with "lying evidence" (the section "Lying with ChatGPT.") $\endgroup$ Apr 3, 2023 at 13:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.