Chatting with ChatGPT3: Unpacking the Mysteries of its Magic Architecture

Sangamesh Davey
Developer Community SASTRA
10 min readFeb 7, 2023

As technology continues to advance, it’s no surprise that Artificial Intelligence (AI) is being integrated into various aspects of our lives including education. One of the most powerful AI models- ChatGPT developed by OpenAI, has the potential to revolutionize the way students learn and study. In this article we will explore the various ways in which ChatGPT can be utilized to make our lives easier. From helping with research, language learning, and even creating codes from scratch, ChatGPT has the potential to streamline many aspects of student life and improve the learning experience. It’s an exciting time for education as we begin to see the true potential of AI in the classroom. We will delve into the details of how ChatGPT can be used to benefit students and how it could change the future of education.

Architecture explained :

ChatGPT is a language model that uses machine learning to generate text based on a user prompt. The model is trained on a large dataset of text which allows it to produce realistic and coherent responses. The model can also be fine-tuned on specific tasks such as avoiding non-factual statements or non-toxic language to improve its performance in those areas. Additionally, it is continuously updating its training datasets for better performance and to mitigate bias as well.

ChatGPT built on top of the GPT (Generative Pre-trained Transformer) is a type of language model developed by OpenAI. The GPT model uses a transformer neural network architecture, which is known for its ability to handle large amounts of sequential data such as text.

ChatGPT is a variation of the GPT model that is specifically designed for conversational contexts. It can take an initial prompt, or the previous message in a conversation, and generate a contextually appropriate response. This is achieved by using specific techniques from reinforcement learning to enhance the performance of the language model.

INDIVIDUAL COMPONENTS/CONCEPTS OF THE CHAT GPT EXPLAINED

1. Language model :

A Language Model is a type of AI that has been trained to predict the next word or words in a text, based on the preceding words. It is used to complete sentences or phrases as you type, and it does this without needing any specific labels or instructions, instead, it learns from a large amount of text. This type of learning is called self-supervised learning.

2. Transformer neural network :

Transformer neural networks are a type of deep learning architecture that is well-suited to handle sequential data, like text or speech. They consist of two main parts: an encoder and a decoder.

The encoder takes in a sequence of inputs, such as a sentence in English, and “encodes” it into a set of hidden representations, known as word vectors. These word vectors capture the meaning of each word in the input sentence in a way that the model can understand.

The decoder then takes these word vectors as input and generates a new sequence of output, such as a sentence in French. It does this one word at a time, using the previously generated words as context to inform the generation of the next word.

One of the main advantages of the transformer architecture is that it can process the entire input sequence at once, rather than processing one word at a time. This allows the model to capture the global context of the input sequence, and generate output.

3. Encoder — Decoder :

Transformer networks consist of an encoder & decoder, encoding input to word vectors and decoding to the output sequence.

The encoder and decoder can be used separately or combined to build different types of language models. For example, if we stack multiple encoder layers together, we get a bi-directional encoder representation, such as in models like BERT (Bidirectional Encoder Representations from Transformers). This allows the model to consider the context both to the left and right of the current word, which can lead to a more accurate understanding of the input.

On the other hand, if we stack multiple decoder layers together, we get a generative pre-trained transformer, such as GPT (Generative Pre-trained Transformer) These models can generate new text by predicting the next word in a sentence, based on the context provided by the previous words in the sentence.

ChatGPT is a variation of GPT that is fine-tuned for conversational contexts. It is trained to respond to a user’s request by generating an appropriate response. It also uses additional techniques from reinforcement learning to further improve its performance in generating conversational responses.

Overall, transformer neural networks and their variants are powerful tools in the field of natural language processing and can be adapted to a wide range of tasks such as language translation, question answering, text summarization, and language models

4. Reinforcement Learning :

Reinforcement learning is a method of achieving a goal by using rewards as an incentive for an agent to take specific actions. In the example provided, the agent is trying to reach the end state, and the rewards in each square are used to entice the agent to take specific actions. The agent’s current position is the state, and the effort it takes, such as going left, right, up, or down, is used to try to reach the end goal. The sequence of actions the agent takes to try to reach the goal is the policy.

Relating this to chatGPT, the reward given to the model depends on the response it generates. If the response is good, it will receive a high reward, if the response is not good it will receive a negative reward. In the context of chatGPT, a time step occurs when every word or word token is generated. The state can be defined as a combination of the user input prompt and every word that has been generated until that point. This can be used to infer what action to take next, which is what word should be generated next.

The policy in this case would be the sequence of words that are generated in the response. Different policies (responses) will have their own rewards and can be compared to see which response is better and which is worse. The model can be fine-tuned based on this comparison, to help generate better responses. Reinforcement learning is an effective way to fine-tune the model and make it generate more appropriate responses, based on the rewards it receives for the generated responses. It is the method of achieving a goal by using rewards as an incentive for an agent to take certain actions.

In chatGPT, the model is the agent trying to generate a logical response, the state is the prompt + generated words, the policy is the response generated, and reinforcement learning is used to fine-tune the model based on reward for responses.

5. The final architecture :

  • First, a pre-trained GPT model is fine-tuned to generate responses to user prompts using a supervised fine-tuning method (SFT)
  • Next, data with labels is used to further train the model. The labelers write prompts and corresponding responses, the fine-tuned GPT model is used to generate multiple responses for a single prompt, and the labelers rank the responses based on their quality.
  • These rankings are used to train another GPT model, called the rewards model, which takes in the initial prompt and a response, and outputs a reward that quantifies how good the response was.
  • An unseen prompt is passed through a copy of the SFT model, a response is generated and passed through the rewards model to get a rank.
  • The rank is used to further fine-tune the SFT model by incorporating the rank into the loss function.
  • The incorporation of rewards into the model through the loss function helps the model to generate less toxic and more coherent and factual responses.

Use-cases :

  1. Learning :

If you want a detailed lesson on a topic from a teacher, or you want a quick revision from your friend before exams, ChatGPT is here for you. It can explain any complex topic to you anywhere anytime and exactly the way you want it. Wanna see an example. Here’s a binary search explained in the style of Mean Girls for you.

So that is Regina George explaining binary search to you. You can also learn from The Joker, Spiderman, or anyone you want ;)

2. Assignments :

Another huge part of a student’s academic workload is assignments. Have you ever been struck in the middle? Or don’t know how to start? Or you have loads of information and don’t know how to compile them in a single place. Again, ChatGPT is here for the rescue. You can type the topic and the number of words you want in your essay and

ChatGPT will write a plagiarism-free assignment for you.

3. Simplification and Summarization :

We saw that you can learn from ChatGPT in a simple language. But, let’s say you are studying from a book/ppt and you are stuck in a specific place. It’s too complex for you to understand, either it’s too complex or it has a lot of words. Again, *drum rolls please* ChatGPT is here for the rescue. Just copy-paste the paragraph you want in ChatGPT and say whether you want to simplify or summarize it. And there you go, you get your information in simple language. Impressive, isn’t it?

4. Convert your ideas into code :

Have you ever thought owning the magic pencil would be so cool? You can just draw something and it will come to life. How wonderful will it be? Well… ChatGPT is a magic pencil for developers. You can type what you want your code to do and there you go, in a single click, you get the code. No more struggling to write code from scratch!!! This helps also in writing repetitive codes. Why spend time in writing repetitive code when AI can do it for you in less than 10 seconds and that too for free? And we humans can spend time working on the next version of ChatGPT ;)

5. Debug:

Okay, but what if you already have the code? But it shows loads of errors. And the compiler message sounds Greek and Latin. Just copy and paste the code in ChatGPT and wait for the magic to happen. Not only do you get the list of errors and where it is present, but you also get the possible solutions for them. Fascinating, isn’t it?

6. Explain the functionality of the code:

We have written the code from scratch debugged our code etc. Let’s say you already have a code from the internet or from your teacher or your friend. And you can’t get what that code does. Yeah, you guessed it right. Ask ChatGPT to do it. Copy-paste the code and get the explanation in simple English.

7. Free grammar check:

You can check your spelling, grammar, punctuation, etc, all for free. It helps to improve the accuracy and clarity of your writing. Do you want it to be more formal? It can convert your paragraph into a formal essay.

8. Replacement for google :

ChatGPT is the future. It can be used as a translator, calculator, dictionary, etc. Why go to google for definitions when you have a personalized teacher for you? In the near future, it will be ‘Go, ChatGPT it’.

9. Resumes and cover letters:

You can ask us, what’s the big deal? There are templates available already. How does it change anything? Here’s the interesting part. It can create personalized resumes and cover letters for you. You can give the necessary information about yourself, the place you are applying for, how long you want it to be, whether should it be formal or not, etc. And tada … There is your personalized resume and cover letter. You can do some changes if you want and submit them. You can make your resume customized to the job you are applying for, all in no time.

And so much more…

Apart from the things mentioned above, you can get a detailed explanation of a math problem step-by-step, by just giving it the question, creating a personalized study plan, etc. and you can have fun. It can create poems, rap songs, etc.

Conclusion :

In conclusion, OpenAI’s ChatGPT-3 is a remarkable achievement in the field of artificial intelligence and natural language processing. With its advanced capabilities, it has the potential to revolutionize the way we interact with technology and automate many tasks that were previously performed by humans. However, it raises questions about the future of work and whether AI will replace human workers, including developers and content creators. As technology continues to evolve, it’s important to consider the ethical implications and ensure that the benefits are shared fairly. While time will only be able to say if ChatGPT-3 would replace human workers or assist them, the future of AI and its impact on society will continue to spark debate and discussions.

--

--