Inside the Inner Workings of CHATGPT: An Answer for Every Question You Ask Yourself About AI
Last Updated on July 15, 2023 by Editorial Team
Author(s): Maks Lunev
Originally published on Towards AI.
Dive deep into the background processes of ChatGPT to understand how it operates and find the answer to your questions about AI.
We all know that ChatGPT is a user-friendly AI chatbot that answers our questions and fulfills our commands giving us nice human-like outputs. But how many of you actually know how ChatGPT is working? How many of you are familiar with the process of generating responses? Some of you might be, but I bet there are a lot of people who donβt.
There are a lot of questions about ChatGPT. After reading a lot and informing myself, I found that the answers to some frequent questions about ChatGPT are hiding in its inner-working methods. By understanding how ChatGPT processes data and how it generates its responses, you can find the answer to the questions you always ask yourself about AI.
INNER WORKINGS
β β β β β β β β β β β β β β β β β β
Web data training
ChatGPT is trained with data coming from all over the web. This data comes from every written text that has been published on the web: books, articles, websites, text files, blogs, reviews, everything. Basically, all the publically available text data.
All this data is used to βeducateβ the model in some sort so it can have a general understanding of the world. By processing and analyzing this data, it learns about linguistic structures, grammar rules, relationships, expressions, patterns, and all kinds of stuff that help it generate more high-quality responses.
It doesnβt use this data directly to generate responses. Of course that it is using this data to present facts and answer questions, but itβs not its primary objective. This data is meant to train ChatGPT, to make it understand some things, and to give it a little bit of βstarting knowledgeβ with which it can understand and help us. To actually generate responses, ChatGPT is using another techniqueβ¦
Sentence completion
And that is how ChatGPT generates responses. Sentence completion or chat completion is the technique that it uses to create and generate the output. After analyzing the userβs input, ChatGPT predicts what words should come next in the sentence.
We all have something like that on our phones when we send messages. Iβm talking about auto-suggestions. But it isnβt exactly the same thing. Here, the algorithm is much more advanced and optimized. It can predict words, sentences, and even whole paragraphs.
This βpredictionβ is a set of complex mathematic calculations. It applies the skills it has learned from its training (context, grammar, patterns, relationships) to evaluate different probabilities and scenarios for words that could come next. After these calculations, the model comes up with some of the best results, selects one of those, and then generates its response.
Human training
The sentence completion technique isnβt enough to cover all the possible inputs that the user could write. If he writes something like: βWhat is engineering?β, then the sentence completion model should get the job done, but if the user writes something like this: βExplain to me how engineering works.β, itβs a different story.
Thatβs why ChatGPT has another trick in his pocket: human conversation training. You probably know that your conversations with ChatGPT as a user are saved as feedback from which the model learns and improves himself. This helps him a lot to perform better in future user conversations.
But thereβs also one more technique. It is called βreinforcement learningβ and it is a scenario where human AI trainers are ranking and evaluating responses generated by ChatGPT to improve its performance. Letβs say that the model provides 4 different responses to one identical input. Well, the AI trainers will rate each one of the 4 responses based on a specific scale (from 1 to 10 to make it simple), and they will load their ratings into the AI.
ANSWERS TO FREQUENT QUESTIONS
β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β
Why ChatGPT operates better with English inputs?
ChatGPT is fluent in many languages which makes it easy for people who speak only one language and have difficulties learning other languages. But the quality of ChatGPTβs responses is generally better when the inputs are written in English.
Thatβs because the data that it was trained on comes from the web as I mentioned earlier. And whatβs the most widely used language on the web? Yes, correct, English. There are more much more articles, text files, web pages, and reviews written in English than in other languages. So, ChatGPT has much more English resources available to it from which it can learn and improve its performance.
But have you noticed that I said that the quality of the responses is generally better? I did this because it depends on what you are looking for. If the subject you search information for is more language or country-specific, then you might receive better responses in other languages than English.
Let me clarify for you. Letβs say you are interested in the Spanish conquest of the Americas. Well, since it is a topic highly related to Spanish culture and history, the possibility that there is more information about that in Spanish rather than English is considerably high. If it is, the response will be better in Spanish.
Why ChatGPT makes mistakes?
Everybody knows that ChatGPT isnβt perfect, everybody knows that sometimes, it makes mistakes. You will be surprised when Iβll reveal the reason. Itβs our fault that ChatGPT makes mistakes; itβs humanβs fault, or more precisely, the fault of those who write things on the web.
Since the web data that has been used for the training of our well-known AI chatbot is written by humans like you and me, there are errors and misunderstandings about certain facts and events. Humans are the ones making mistakes; machines donβt. Unfortunately, ChatGPT hasnβt any βfalse information detectorβ which he can use to verify information, but it is what it is. Now you know the reason.
But hey, donβt take it personally when I say itβs our fault. Everyone makes mistakes. If this article that you are reading currently is used for the training of one of the future GPT models and there are mistakes in it, thereβs a chance that the chatbot gives you false information because of me. So donβt feel upset when you are writing something on the web. By the way, if this really happens, Iβm sorryU+1F607U+1F605.
Why ChatGPTβs responses are changing all the time?
Have you noticed that when you give ChatGPT a prompt, and then you give him exactly the same prompt without changing anything, the response is different than the previous one? This mechanism comes from the sentence completion model.
There is a randomness added to the sentence completion model when it chooses what the next words should be. I told you that it chooses from multiple propositions which he considers as good enough to continue the sentence. The first time, he will choose one of those propositions, and the second time another. This is being done to avoid repetitiveness.
How does ChatGPT understand and interpret context in a conversation?
Before generating a response, ChatGPT goes through the conversation by analyzing what the user said in the earlier inputs. It focuses on important parts of the conversation history. Itβs the same thing with the web data it has been trained on, but this time, it learns directly from the conversation.
This is called the βattention mechanismβ. This allows the chatbot to understand the flow of the conversation as well as the userβs intents and referrals. It also helps him in prioritizing the relevant information to give a proper response without annoying the user with unnecessary explanations and details about the context.
Conclusion
We can find the answers to a lot of questions by analyzing and understanding the inner workings of something. It is quite useful to discover the hidden processes and algorithms of the tools and technologies we use every day. ChatGPT is one of these technologies and thatβs why I made this article.
Hopefully, it wasnβt too complicated to understand and added some clarity about how ChatGPT functions and operates. Now that you know all of this go share it with someone who doesnβt so he can be as smart as you. Iβm kidding, of course.
Resources
Join thousands of data leaders on the AI newsletter. Join over 80,000 subscribers and keep up to date with the latest developments in AI. From research to projects and ideas. If you are building an AI startup, an AI-related product, or a service, we invite you to consider becoming aΒ sponsor.
Published via Towards AI