Message Boards Message Boards

StephenBot is (a)live!

Posted 1 year ago

enter image description here

Hello, Wolfram Community!

I’ve developed StephenBot to honor Stephen Wolfram's innovations and his significant influence in computational science and technology. It celebrates his dedication to public education and his commitment to sharing his knowledge with the world. StephenBot has access to Stephen’s public presentations, writings and live streams.

You can now head over to


StephenBot.com


and ask anything, from his first computer or favourite movie to his ideas on Observer Theory and Ruliad, or his current understanding of the Second Law of Thermodynamics!

I'm happy to answer your questions and would love to get everyone’s feedback.

If you're interested in the technical details, read on!

How does it work? Context is all you need!

LLMs, trained on large amounts of data (public or private), have a general understanding of patterns in natural language and are trained to produce convincing, human-like responses. However, due to their lack of deep understanding like humans, and limitations and biases in their training data, they often suffer from what’s now the 2023 word of the year, “hallucinate”! It refers to generating information that is incorrect, irrelevant or nonsensical. So, any useful application of LLMs needs more than just prompt engineering.

Suppose you want your LLM to answer questions based on a specific PDF or Word document. You can now upload that to GPT-4 or copy-paste the content into ChatGPT and ask questions about the document. If the content is small enough, ChatGPT will remember it and, based on the given document, attempt to answer your questions. This given data is now part of the context.

Context is the information embedded in the prompt for the LLM to draw from and have a conversation with you. Normally, the context contains all previous messages (yours and the AI’s) in a single chat session.

Now, imagine your PDF or Word document is quite large, or you have hundreds of documents you want the LLM to remember and answer questions based on. You can't copy & paste all the content into the prompt box. It won’t remember all of that as it can only accept a limited number of characters (or tokens, to be technically correct). This is known as context size limitations. To deal with these limitations, we need to include only relevant documents based on the user's question. We need a retrieval mechanism to find, rank and package only the most relevant parts of the documents into the interactions with the LLM.

Context Retrieval

Context retrieval is the classic problem of data retrieval in computer science and NLP, where techniques from TF-IDF to similarity matching based on vector embeddings have been developed to find the most relevant information or document for a given query. When applied to LLMs, it’s often referred to as “Retrieval-Augmented Generation” or RAG, aiming to “augment” the LLM's context with relevant, specific information or otherwise, reduce the impact of hallucination.

How is StephenBot built?

Data

The data is gathered from Stephen Wolfram’s extensive public writings and presentations, and most importantly, his inspiring livestreams on Science and Technology, which I have been a fan of since they started back in 2020.

Each of these writings and livestreams, let's call them documents, is divided into smaller chunks so that the most relevant pieces can be found and fed into the LLM’s context.

Data Store

We use a vector database to store the document chunks, their embeddings and metadata about each document. For each query, relevant parts of the documents are retrieved and added to the context in the background.

So far, it's loaded with 250+ writings, 220+ livestreams and a few webpages, with the ability to continuously ingest new content and documents.

LLM

We are using OpenAI’s GPT-3.5-Turbo but can easily transition to GPT-4, Llama 2 or another LLM, though the embeddings may need to be recalculated when switching vendors.

Technology

I started building this using Wolfram Language and Mathematica in early 2023 with versions 13 and 13.1. I experimented with embedding models available at the time (TF/IDF and GPT2 Transformer), however, I wasn't able to achieve sufficiently accurate results. So I ended up developing it in Python with OpenAI's embedding and LLM models. But I’d love to build and streamline everything in Wolfram Language at some point.

Personality and Identity

It believes that it is Stephen Wolfram, and StephenBot is an AI model emulating him! This is the more stable version of its personality. In previous experiments, it could fall into an identity crisis between StephenBot, Stephen Wolfram and its past origin as being developed by OpenAI!

No, I am not StephenBot. I am Stephen Wolfram. StephenBot is an AI model created to simulate my mannerisms and knowledge.

And don’t ask it to unplug itself!

Enjoy!

POSTED BY: Rouz Mey
5 Replies
Posted 1 year ago

Thanks for taking the time to write this.

Yes, personalised education should be the future. Being self-taught myself and having taught several subjects over and over, I do believe that bots like this, as part of a structured learning path personalised to individual students' learning styles, paces and needs, can be more effective. They could be equipped with superpowers such as integration with Wolfram Alpha, access to the Internet and the ability to write and execute code, much like GPT-4, to provide support at each step.

I think it did quite well, considering it did not have any special training on Wolfram Language, nor was it given access to Mathematica documentations. So its knowledge of Wolfram Language might be slightly more advanced than ChatGPT. It should however know about various versions of Mathematica and several functions that Stephen has discussed in his blog posts. It could of course be given access to Wolfram Language documentations or even fine-tuned to better answer programming questions.

LLMs can easily mimic various characters and personas, so I don't think it would be very hard for them to replicate a specific programming style or follow a set of best practices and guidelines. This could be achieved through few-shot learning or fine-tuning, where many more examples of the desired output are provided to the LLM. This would then assist the model in recognising patterns and aligning with the preferred styles and guidelines.

Yeah, it's a great idea to use LLM bots like this to serve as a search engine over a one's archive of documented or undocumented knowledge.

The GPT-3.5 and the embeddings costs were not expensive at all.

Thank you again for your comment. Glad that you enjoyed it.

POSTED BY: Rouz Mey
Posted 1 year ago

Thanks for the great suggestions.

There are a few options for custom voice cloning. I chose ElevenLabs as it sounded more natural, but it tends to reach its monthly character limits quite quickly. For applications like this, an open source solution may be a better choice.

POSTED BY: Rouz Mey

Fantastic post! Thanks a lot!

I am wondering how readily this could be used as a personal tutor/teacher at Universities. I have been teaching the Wolfram Language, Data Science, and Mathematical modelling for many years, and due to University regulations I had to record each and every session (there should be more than 1000 probably 2000 videos; each video should be 2 hours or so. Additionally there are lots of notebooks, and other texts that are relevant.

GPT-4 is able to help a great deal writing and debugging code, as well as interpreting data and building ideas for modelling.

The way we teach is not really tailored to an individual student due to class sizes. We also have many online students in different time zones. It would be great if this technology could give students a 24/7 personal lecturer - and replace me?

Here is an example (we need to keep in mind that GPT3.5 is not that good at programming....):

My question to StephenBot: "Can you show me some Wolfram Language code to compute the first 20 Fibonacci Numbers, then fit an exponential curve to it, and finally plot the data points in red and the fit in black in the same plot?"

enter image description here

The suggested code does not actually fit an exponential curve, but does quite well:

fibonacci[n_] := If[n <= 1, n, fibonacci[n - 1] + fibonacci[n - 2]]
fibonacciNumbers = Table[fibonacci[i], {i, 20}]
exponentialCurve = Fit[fibonacciNumbers, {1, x, x^2}, x]
plot = ListPlot[fibonacciNumbers, PlotStyle -> Red]
fitPlot = Plot[exponentialCurve, {x, 0, 20}, PlotStyle -> Black]
Show[plot, fitPlot]

enter image description here

I wonder if there is enough data available, whether the Bot would take the special programming style the lecturer promotes into consideration. For example, I very much prefer Functional programming style rather than procedural. Would it be able to mimic the "tricks of the trade"?

In a next step, of course one could think about the ideal combination of lecturers.

Once again: Thanks a lot for the great post.

Cheers, Marco

PS: Interestingly I have been collecting data of all sorts for many years. Apart from work related recordings, I also have months worth of recordings of everything I have said.

PPS: There are different projects to keep memories of historical events even after eye witnesses have passed away. How expensive was the training and especially the embedding?

POSTED BY: Marco Thiel

Wonderful, thanks for sharing!

Why don't we share our favorite questions / responses? I start below.

Also, a wish list, if possible:

  • Easy sharing on social media could be nice and help you to promote your work
  • It'd be nice to retain the question itself too (currently it disappears after being entered)

And a question:

  • How did you generate the voice?

enter image description here

POSTED BY: Vitaliy Kaurov

enter image description here -- you have earned Featured Contributor Badge enter image description here Your exceptional post has been selected for our editorial column Staff Picks http://wolfr.am/StaffPicks and Your Profile is now distinguished by a Featured Contributor Badge and is displayed on the Featured Contributor Board. Thank you!

POSTED BY: EDITORIAL BOARD
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract