Towards AI Can Help your Team Adopt AI: Corporate Training, Consulting, and Talent Solutions.


Inside the Inner Workings of CHATGPT: An Answer for Every Question You Ask Yourself About AI
Latest   Machine Learning

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.

Source: Photo by BoliviaInteligente on Unsplash

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.


— — — — — — — — — — — — — — — — — —

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.


— — — — — — — — — — — — — — — — — — — — — — — — — — — — — —

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.


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.


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

Feedback ↓