Unveiling the Inner Workings of ChatGPT: What’s Behind the Screen? – Video

Unveiling the Inner Workings of ChatGPT: What’s Behind the Screen? – Video

ChatGPT, an AI-powered chatbot, has gained attention for its ability to provide human-like responses to user queries. What sets ChatGPT apart from other chatbots is its capacity to understand context and generate relevant responses. It utilizes natural language processing and machine learning algorithms to interact with users, making it a powerful tool for a variety of tasks.

The introduction to this video was actually written by ChatGPT, showcasing its ability to generate coherent and natural language responses. Unlike search engines like Google, ChatGPT doesn’t rely on returning search results but rather provides responses based on the context and intent behind a user’s question.

The GPT in ChatGPT stands for Generative Pre-trained Transformer, and it uses neural networking, supervised learning, and reinforcement learning to mimic human conversation. Trained on a vast dataset of books, webpages, and other sources, ChatGPT is capable of predicting words, phrases, and sentences that are likely to be associated with a given input.

While not magical, ChatGPT’s prowess lies in its ability to predict the most likely words and sentences to answer a query, generating human-like responses based on the information it has been trained on. This makes it a valuable tool for a wide range of applications, and understanding how it achieves this remarkable feat sheds light on the power of modern machine learning.

Watch the video by Arvin Ash

Video Transcript

Hello and welcome to my channel. Today,  I would like to introduce you to ChatGPT. ChatGPT is an AI-powered chatbot that  uses natural language processing and   machine learning algorithms to interact  with users. What sets ChatGPT apart from   other chatbots is its ability to understand  context and provide relevant responses. 

So why not gie it a try and  see how it can help you today?  This intro as you’ve probably  guessed was written by ChatGPT,   the topic of today’s video. It’s like a  chatbot on steroids, an internet tool that   allows you to have human-like conversations. Unlike Google which returns search results,  

A list of web pages and articles that usually  provide information related to the search queries,   ChatGPT provides a response based on the context  and intent behind a user’s question. You can’t,   for example, ask Google to write story or  write a code, but you can ask that of ChatGPT,  

And it will give you a reasonable response. The GPT stands for Generative Pre-trained   Transformer, which means it generates responses, it is pretrained by humans,  and finally the transformer is the key neural network architecture that transforms an input into a meaningful output. This model was created by an artificial  

Intelligence research company called OpenAI. How did this company create this seemingly magical   tool? And how does ChatGPT actually work? What’s going on behind the curtain? That’s coming up now!  Before we get into the details of how ChatGPT  works, I want to acknowledge that part of the  

Inspiration for this video was a 12 episode  documentary I watched on MagellanTV, today’s   sponsor, called, “Tech Talk, transforming  our planet.” It takes you inside upcoming   startup companies that are working on things  like artificial intelligence, flying cars,   robots, holographic surgery and other  innovative ideas, and the fascinating  

Stories of some of their founders. This series is just a small sample of   the thousands of documentaries on MagellanTV,  the highest rated documentary streaming app on   Google Play. And more than 20 hours of new  content are added weekly. Magellan has a  

Special offer for Arvin Ash viewers. Right  now your first month is absolutely free.  Just click the link in description, and start  enjoying the highest quality documentaries   available, including free 4K videos and never  any ads. And you’ll be supporting this channel  

When you sign up, so I can’t thank you  enough for that! Now, back to the show.  Unless you’ve been living under a rock the last  year, you have probably heard about ChatGPT. It’s a   seemingly super clever AI chat bot that seems  to know everything. It can do everything from  

Your homework, to writing a cover letter for a new  job, to giving you advice, to programming code.  While Google’s power is the ability to do  enormous database lookups and provide a series   of matches that might answer your queries.  ChatGPT’s power is the ability to interpret  

The context and meaning of a particular query  and produce a relevant answer in grammatically   correct and natural language, based on the  information that it has been trained on.  So, how does it work? Let me just dispel  a few myths first. It’s not magic. It’s  

Just math and a bunch of clever concepts.  And no it doesn’t get smarter by itself.   It cannot self-study like a human that can go  to the library and start learning new things.   ChatGPT learns from whatever it is told to study. It is also not just asking internet for an answer  

To your question. It does have a storehouse of  knowledge and uses it to answer your questions.   ChatGPT was trained on data from books, webpages, Wikipedia, news articles, scientific journals,   and other unspecified sources. The material  was collected up to about September of 2021,  

So any information newer than this, ChatGPT would be clueless about at least as of today which is around April, 2023. You would have to teach it this   new material if you want an answer to something  that become new knowledge after that time. 

The short answer to how it works is that  it uses neural networking, with supervised   learning and reinforcement learning, two  key components of modern machine learning.  What does this mean? To start off, let me describe at a very high  

Level and in a highly simplified way what ChatGPT  is doing. Then I will explain this in more detail.  Let’s say we give it an input  such as, “In two sentences,   explain quantum mechanics in very simple terms” The actual output from ChatGPT was the following: 

Quantum mechanics is a branch of physics  that deals with the behavior of tiny   particles like atoms and electrons. It  tells us that these particles can act   like both waves and particles, and can be  in many different states at the same time. 

As you can see, this is not a bad  answer. How did it come up with this? What it does fundamentally is predict what words,  phrases and sentences are likely to be associated   with the input I just made. It then chooses the  words and sentences that it deems most likely to  

Be associated with the input. So it attempts to  understand your prompt and then output words and   sentences that it predicts will best answer your  question, based on the data it was trained on. It also randomizes some outputs so that  the answers you get for the same input,   will often be different.

So, for example, when I asked it to regenerate the   response to the same question as  before, it gave me this answer: Quantum mechanics is a branch of physics  that studies the behavior of matter and   energy at a very small scale, such as  atoms and subatomic particles. It is  

Characterized by phenomena such  as superposition, entanglement,   and wave-particle duality, which are not  easily explained by classical physics. As you can see, this is a  pretty good answer as well.  Let’s simplify this further, to see  what’s going on behind the curtain.  

The first thing you should understand is that  how ChatGPT fundamentally works, is that it   tries to determine what words would most likely  be expected after having learned how your input   compares to words written on billions of webpages,  books, and other data that it has been trained on. 

A humongous dataset was used to  form a deep learning neural network.  To put it simply, this is a multi-layered,  weighted algorithm similar to the way   we believe the human brain works. It allows ChatGPT to learn patterns   and relationships in the text data. One  way that it utilizes this learning is  

Create human-like responses by predicting what  text should come next in any given sentence.  Now, I don’t want to give you the impression  that it’s like the predictive text on your   phone that’s just guessing what the word  will be based on the letters it sees.

ChatGPT attempts to create fully  coherent sentences as a response   to any input. And it doesn’t just stop  at the sentence level. It’s generating   sentences and even paragraphs  that could follow your input. Now let’s look further into the details of how  it does this: Let’s do a very simple example.

Let’s say that we ask it complete this  sentence, “Quantum mechanics is…” —   The processing that happens behind  the scenes goes something like this. It calculates from all the instances of this text,   what word comes next, and at  what fraction of the time. Now, let me qualify that it  doesn’t look literally at text,  

But it looks for matches in context and meaning. The end result is that it produces a  ranked list of words that might follow,   together with their “probabilities.”  So it’s calculations might produce   something like this for the next word  that would follow after the word “is”:

The model would then choose the next  word to complete the sentence. It’s   basically asking itself, “given the text so far,   what should the next word be?”—and  each time it asks this, it adds a word. So it keeps adding words until it completes  the output. There is a stop mechanism built  

Into the model based on a rough standard  of what the length and format should be. Now you might think it will always choose  the word with the highest probability. But   it doesn’t always do that. There is randomness  built in so that its answers can be more creative.

So for example it might choose  the word “a” as the next word,   and based on this choice, the output  sequence might look something like this: Quantum mechanics is a Quantum mechanics is a branch  Quantum mechanics is a branch of Quantum mechanics is a branch of physics

And it would keep doing this until it  presents the following full answer: But as you might imagine, if it chooses  the word “fundamentally” instead of “a”   than it might output a completely different  answer based on the subsequent choices,   for example, with the following sequence: Quantum mechanics is fundamentally Quantum mechanics is fundamentally a 

Quantum mechanics is fundamentally a probabilistic Quantum mechanics is fundamentally a   probabilistic theory. And it would keep doing this until  it presents the following answer: Both outputs are correct, but they are different. The message here is that there are many possible  next words, so the answers could be quite  

Different every time anyone makes the exact same  query. But as I said before, the model doesn’t   just come up with next words, it also works at  the sentence and paragraph level, so it can output   for example, the best sentence that might fit  the context and meaning of the first sentence.

But the important thing to understand about this  is that fundamentally, this is what the model is   doing. It is choosing what it determines is  the best response to the query step by step. Now as you might imagine, the sentence  completion model is obviously not enough.  

If we ask it something like “explain  how quantum mechanics works,” it has   to use a different strategy. If ChatGPT  only used a sentence completion model,   it’s response might be something like, “Explain  how quantum mechanics works…according to the   Schrodinger Equation.” This would not be the  kind of answer that the user was looking for.

So now the question is, how is the  model trained to respond in more   appropriate and conversational way. This  all comes down to the way it was trained. In the first stage of the training process,  Human contractors play the role of both a  

User and the ideal chatbot. Each training  consists of a conversation where the human   user and the human acting as the chatbot carrying  on a conversation. These two roles could be   the same person. The basic idea is to train  the model to have human-like conversations.

The thread history of this with real humans  is entered into the model. So this way,   the model learns to maximize the  probability of picking the correct   sequence of words and sentences in any  particular conversational exchange. Through this supervised human-taught  process, it learns to come up with  

An output that is more than just sentence  completion. It learns patterns about the   context and meaning of various inputs  so that it can respond appropriately.   This is why a chat with ChatGPT can sometimes  seem like there might be a human at the other end.  

But this is not the end of the training process.  The output from this stage is further finetuned in   a second stage, where the developers teach ChatGPT to assign a reward or ranking to each output.  For example, a trainer might ask  the model something like, “Describe  

An atom” – the potential answers could be: a) It’s the smallest part of a substance made   of electrons, neutrons, and protons. b) It’s a basic chemical element  c) It’s an object made of Subatomic particles d) It’s a ticketing service A human trainer would rank this  output from best to worst like this:

And then this data would be fed  to the model like this where  A is greater than C which is greater  than B which is greater than D  This teaches ChatGPT to critically evaluate  what the best output is likely to be.

Now the problem with solely using human  trainers as in this type of supervised learning,   is scale. Human trainers would have to  anticipate all the inputs and outputs of   any potential query that anyone  user could potentially request,   at anytime. This would be impossible to do.  And we know that ChatGPT doesn’t have this  

Kind of limitation. For example, you  can have it write a short story about   almost any subject and it will come up with  something reasonable. So how is it doing that? For this it uses a third step which  is called reinforcement learning.   This is a type of unsupervised  learning. This process trains  

The model where no specific output  is associated with any given input. Instead the model is trained to learn the  underlying context and patterns in the input data   based on its earlier human-taught pre-training.  In other words, the model uses the pre-training  

Including the ranking system, to form the basis  of its output for the unsupervised training stage. This way the model can process a huge amount of  data from various sources, and learn the patterns   from texts and sentences of a near limitless number of subjects. And it can do it on its own,  

So it can scale the human-taught  training to a much bigger dataset. And that dataset used to train ChatGPT  which is based on GPT-3.5 is huge,   about 45 terabytes of data. This might not  seem all that much by today’s standards where  

You can buy a terabyte flash drive for $20, but  this is a huge amount of text to process. Each   terabyte is equivalent to 83 million pages of  information. And it is big enough for ChatGPT   to learn patterns and relationships between  words and phrases on a massive enough scale,  

Such that it can come up with relatively  meaningful outputs for nearly any query. The astonishing part is, and maybe  it’s even scary to some of you,   that as good as ChatGPT is already, the next  version GPT-4 is trained on even more data,  

And is more fine tuned. So it  should be even more powerful. Now I did not get into the details of the  way that text information is converted   to numbers or some of the mathematics  and mechanisms of how neural networks  

Like ChatGPT work. I will make a future  video if you are interested in learning   that. So let me know in the comments if  you want me to make a follow up video. In the meantime, I hope you found this useful,  

And I am not really an AI or alien. I’ll  see you in the next video my friend.

Video “So How Does ChatGPT really work? Behind the screen!” was uploaded on 04/08/2023 to Youtube Channel Arvin Ash