ChatGPT & GPT 4, How it works ?

Youssef Fenjiro
8 min readApr 17, 2023


What is ChatGPT & GPT4 ?

ChatGPT is an artificial intelligence language model developed by OpenAI (backed by Microsoft). It is part of the GPT (Generative Pre-trained Transformer) series of language models, which are designed to generate human-like text by predicting the next word in a sequence of words.

It’s a great step toward Artificial General Intelligence AGI, which is an advanced form of artificial intelligence that would be capable of performing any intellectual task that a human can do.

GPT4 key technical information

  • Multi-layered artificial neural network inspired by human’s brain
  • 100 billion neurons (over 100 layers) and 100 trillion synapses
  • GPT-4 can communicate in 26 different languages
  • Allows to process in input 25,000 words i.e. ~52 pages of text at a time
  • it can generate code for the following programming languages: Python, Java, JavaScript, C++, Ruby, PHP, Swift, Kotlin

What GPT 4 can do ?

ChatGPT’s functional features are the capabilities it offers to users in terms of the tasks it can perform and the interactions it can facilitate. Some of its notable functional features include:

1. Conversational Interfaces: ChatGPT can engage in natural language conversations with users, providing them with relevant responses based on the input it receives.

2. Language Translation: ChatGPT can translate text from one language to another, enabling users to communicate across language barriers.

3. Sentiment Analysis: ChatGPT can analyze the sentiment of text, providing users with insights into the emotional tone of a message.

4. Text Summarization: ChatGPT can summarize long blocks of text, making it easier for users to digest and understand complex information.

5. Personalization: ChatGPT can learn and adapt to individual users’ preferences and behaviors, providing personalized recommendations and responses.

6. Content Creation: ChatGPT can generate new content such as blog posts, articles, and product descriptions, based on specific prompts or keywords.

7. Customer Support: ChatGPT can provide automated customer support, answering frequently asked questions and resolving common issues.

8. Data Analysis: ChatGPT can analyze large volumes of data and provide insights and predictions based on that analysis.

9. Chatbot Integration: ChatGPT can be integrated with chatbot platforms to provide more advanced conversational capabilities to users.

Overall, ChatGPT’s functional features enable it to serve a wide range of use cases across industries, from customer service and e-commerce to healthcare and finance.

ChatGPT & GPT 4 : The bricks used to build the model

As an AI language model, ChatGPT is equipped with a wide range of technical features that enable it to understand and respond to natural language input in a human-like way. Some of its notable technical features include:

1. Deep Learning Architecture: ChatGPT is based on the GPT-3.5 architecture, which uses a deep neural network with hundreds of millions of parameters to analyze and generate text.

2. Natural Language Processing: ChatGPT utilizes advanced natural language processing (NLP) techniques to understand and interpret input text, including tokenization, named entity recognition, and part-of-speech tagging.

3. Contextual Awareness: ChatGPT is designed to be contextually aware, meaning it can understand and respond to the nuances of conversation and adjust its responses accordingly.

4. Language Generation: ChatGPT has the ability to generate new text that is coherent, grammatically correct, and contextually appropriate.

5. Reinforcement Learning: ChatGPT uses Reinforcement learning to continuously improve its language processing capabilities over time.

2 other features are available to allow commercial usage:

6. Knowledge Base Integration: ChatGPT can integrate with knowledge bases and external data sources to provide accurate and relevant information to users.

7. Cloud-Based Infrastructure: ChatGPT can be deployed in a cloud-based infrastructure, allowing it to scale to meet the needs of large user bases.Haut du formulaire

Deep learning is a type of machine learning that involves the use of neural networks with multiple layers to analyze and learn from data. It is inspired by human brain neurons.

Deep learning algorithms use large datasets to learn representations of the underlying features and relationships in the data, which can then be used to make predictions or classifications. The training process involves adjusting the weights and biases of the network to minimize the difference between the predicted output and the actual output.

Deep Learning became possible thanks to:

  • Powerful computing resources
  • Huge Labeled Datasets

Natural Language Processing (NLP) is a field of artificial intelligence that deals with the interactions between computers and human language. It involves teaching computers to understand, interpret, and generate human language, both spoken and written.

NLP combines computer science, linguistics, and cognitive psychology to develop algorithms and models that can analyze, process, and generate natural language data. See below its applications:

  • Automatic translation
  • Text summary
  • Speech Recognition
  • Answer to questions
  • Text Classification
  • Sentiment analysis

The Transformer consists of an encoder and a decoder trained using unsupervised learning mode to understand and interpret human language.

The encoder processes the input sequence and generates a fixed-length representation of the input, which is then used as the initial state of the decoder. The decoder generates the output sequence one element at a time, using the encoder’s representation and the previously generated output elements as input.

Both encoder and decoder are composed of multiple layers of self-attention and feedforward neural networks. The self-attention layers allow the network to weigh the importance of different parts of the input sequence when generating each output element.

Supervised learning is a type of machine learning where the algorithm is trained on labeled data, where the correct outputs are already known. The algorithm learns to map input features to output labels through examples provided during training. In supervised learning, the goal is to build a model that can accurately predict the output for new inputs.

Reinforcement learning, on the other hand, is a type of machine learning where the algorithm learns through trial and error. It involves an agent that interacts with an environment, and the agent learns to take actions that maximize a reward signal. The goal of reinforcement learning is to find an optimal policy that maximizes the cumulative reward over time.

Combining Supervised & Reinforcement Learning

Supervised learning and reinforcement learning can be combined to create hybrid learning approache that can take advantage of the strengths of both approaches, by using supervised learning to pre-train a neural network on labeled dataset to mimic expert skills and then fine-tune it using reinforcement learning which allows to go beyond the expert’s khowledge level.

Training process of GPT4

The training process of ChatGPT can be broadly divided into the following steps:

1. Data collection: A large corpus of text data is collected from various sources, such as books, websites, and social media platforms. The text data is preprocessed to remove any irrelevant information and to extract the text content.

2. Tokenization: The text data is tokenized into sequences of words, which are then converted into numerical representations.

3. Model architecture design: The architecture of the neural network that will be used to train the language model is designed. In the case of ChatGPT, the architecture is based on pretrained transformer neural network, which is designed to process sequential data such as natural language.

4. Pre-Training Transformer Neural Network (TNN): The language model is trained in unsupervised mode to predict the next word in a sequence given the previous words in the sequence. The training process involves optimizing the model parameters to minimize the prediction error.

5. Training using supervised learning: the GPT model use the pre-trained TNN that already master the human language and trained it on large labeled datasets (validated by humans/experts) using supervised learning, to master specific task, such as question-answering or chatbot conversation, text summarizing.

6. Training a reward function to use it for the Reinforcement learning training: we use many instances of ChatGPT to generating data with different Answers for the same questions, then, humans/experts will rank these answers from bad to very good. And finally training, the Reward Model in supervised mode using expert assesment of GPT’s answers.

7. Fine-tuning Reinforcement Learning: The trained model is fine-tuned with reinforcement learning using the already trained reward function.

8. Deployment: The trained model is deployed in a production environment to generate responses to user queries or to perform other natural language processing tasks.

The impact of ChatGPT and GPT4 on jobs

ChatGPT and other conversational AI technologies have the potential to automate a wide range of jobs that involve repetitive and predictable interactions with customers or users. Some of the jobs that can be eliminated or transformed by chatGPT include:

1. Customer service representatives: ChatGPT can handle routine customer inquiries, such as order status, returns, and refunds, reducing the need for human customer service representatives.

2. Technical support: ChatGPT can provide basic technical support, such as troubleshooting steps and software updates, reducing the need for human technical support specialists.

3. Sales representatives & Market research analysts: ChatGPT can handle routine sales inquiries and provide product recommendations, reducing the need for human sales representatives.

4. Personal assistants: ChatGPT can handle routine scheduling and appointment management tasks, reducing the need for human personal assistants.

5. Media jobs (advertising, content creation, technical writing, journalism)

6. Social media managers: ChatGPT can generate and post social media content, respond to customer inquiries, and moderate comments, reducing the need for human social media managers.

7. Translators: ChatGPT can translate text from one language to another, reducing the need for human translators.

8. Teachers: ChatGPT can teach and give answers to student’s questions, it can even do their homeworks and their reports and presentations.

9. Developers, coders, software engineers, data analysts: ChatGPT can in many programming language python, java, ….

10. Legal industry jobs (paralegals, legal assistants): chatGPT can replicate some of the work that paralegals and legal assistants do.

11. Finance jobs (Traders, Financial analysts, personal financial advisors): Workers in the finance industry could be at risk for AI replacement



Youssef Fenjiro

Data scientist, Machine learning & Artificial intelligence.