WAHJA

Understanding AI Algorithms: How ChatGPT and Other AI Tools Operate

AI (Artificial Intelligence) is the backbone of todays modern digital world. From phones to computers to games to even your smart house or the smart fridge, there is an AI built into it.

AI like ChatGPT, Gemini, Midjourney and many more pop up everywhere. Methods of learning, Supervised and unsupervised reinforcement allow continuous improvement. At the core, the question is:

Free Vector | Sci fi artificial intelligence tech concept background design (freepik.com)

What is AI?

”AI Is the simulation of human intelligence in machines. Giving them the ability to perform tasks such as Learning, reasoning, decision-making, perception and problem-solving, tasks that require human cognitive Ingenuity.”

This human intelligence can be found in all digital devices around you. AI has revolutionized the community. The profound effect it has on all of us is changing lives. AI is built on Algorithms.

Algorithms are the building blocks of AI. To understand them it’s to grasp Artificial Intelligence. Understanding algorithms is crucial. It helps in better decision-making and better problem-solving. Grasping the concepts of algorithms help understand how the Ai works and how and what data it gathers to generate the response, thus allowing more transparency. This also enables us to stop its misuse and provide improvements.

What is an AI Algorithm?

AI and Algorithms can be often misused or misunderstood. It is also used interchangeably which is incorrect. AI and Algorithms are linked but different.

An AI is the Intelligence that uses Algorithms to perform tasks. Algorithms are Set or sets of steps/instructions given to perform a task. An input is given to the AI which then uses the stored algorithms in its memory and performs the steps related to produce the output. Algorithms can be defined as,

Algorithms are a sequence of steps/set of steps that turn an input into useable and logical response.”

There are many AI algorithms but the most popular types of AI algorithms are,

  • Supervised Learning
  • Unsupervised Learning
  • Reinforcement learning

These three form the foundation of most AI and machine learning applications. Some more types include,

  • Decision Trees(supervised)
  • Support Vector Machines(supervised)
  • K-means clustering(unsupervised)
software engineering background

Algorithm vectors, photos and PSD files | Free download (freepik.com)

Supervised Learning

Supervised learning has a supervisor overseeing the learning process. In this learning method the machine is trained on data that is labelled. Labelled data is raw data that has been labelled to add meaning/context to it. In AI training Labelled data has the correct answers or classifications marked.

The steps in training a machine with this algorithm are,

  • Data is broken into two sets, Labelled or training data and unlabelled or test data. 
  • The machine is trained on the labelled data intensively.
  • Supervisor is constantly correcting the machine which helps it in correcting the mistakes.
  • The machine is then given the test data.
  • If it produces the desired result the machine is move to the next phase (what ever it might be) otherwise it is trained again.

AI Generated

Sometimes a third set called the Validation Data Set is also used to finetune the model. The machine is trained to recognize patterns and relationships between input features and target labels. The supervision steps are not mostly done by humans but uses other algorithms like Gradient Descent.

It is also divided into two categories.

Regression (Where output value is real value)

Classification (Where output value is a category)

Unsupervised Learning

Unsupervised learning throws the machine in the field without any guidance. There are no labelled data sets and no supervisor to oversee the process and correct the mistakes.

It is a process were, 

“The Machine learns without guidance and discovers patterns and relationships in clusters of data”

It is the training of a machine without labels or classifications and the algorithm is allowed to act on the data independently. The task is to group unsorted information, without any prior training of the data, according to patterns, similarities, characteristics and differences.

AI Generated

Unsupervised learning has several common approaches,

Clustering:

In this method, the machine is used to group similar data types together, working iteratively moving data points in one cluster closer and the others farther to their cluster centres.

It is further divided into types,

  • K-means clustering
  • Independent Component Analysis
  • Principal value composition
  • Hierarchical clustering
  • DBSCAN
  • GMMs

Association:

This rule is used to find patterns in data by finding relationship between different items in the dataset.

Some common algorithms include, 

  • Eclat Algorithm
  • Apriori Algorithm
  • FP-Growth Algorithm

Reinforcement Learning

It is the are of machine learning that works on reward and punishment systems. A machine is told to do a particular task and if it performs well, it receives a reward, otherwise punishment. This method is employed by various machines to find the best possible behaviour or path to take to complete a task.

This approach is the science of decision making (a core trait of AI). This forces the machine to learn the optimal approach to a problem to maximize the reward. The following is the basic theory.

  • A machine given a task.
  • The steps are laid down and the punishments for poor performance.
  • If the machine performs well in the task (each step of the algorithm) it is given a reward, otherwise it is punished.
  • The machine is left to improve itself over its generations (a test is a generation) by trial and error, maximizing the reward.

In each generation the best version of the candidate (machine) is picked. Some of its neural network is tweaked just a little and tested again, then the best version is again picked up and this process continues till the failure rate (depends on the organization in charge of the model) is in the acceptable bounds.

Components of AI Algorithm

An AI algorithm has the following components.

  • Data

It is the basis of any AI model. Data is on which the AI is trained, which the algorithm learns from and which is used to evaluate the performance of the model.

  • Model

The model is the AI itself. The mathematical representation of the algorithm that defines how data is transformed into results.

  • Parameters

These are the adjustment variable in the model which are tweaked during the training to minimize the errors between the predicted and actual result.

  • Training

This is the process of making the AI model. The AI in this step is trained to do the task it was designed for and to reduce the errors as much as possible.

  • Evaluation

After training the model is evaluated to asses its performance. It is put through a set of tests to perform the evaluation.

  • Optimization

The optimization step is to ensure the error rate is as low as possibly can be. The model is optimized again on new data to ensure it behaves as expected.

Jigsaw_Puzzle_Frames_1_White

Free Vector | Jigsaw_Puzzle_Frames_1_White (freepik.com)

Data: The Fuel for AIs

AI is nothing without data. As much as we need oxygen, AI needs data, and lots of it. And AI model is trained on data, evaluated on data and also optimized on data. An AI model is tested and trained on this data in the following steps.

  1. Data Splitting

Data is split into two parts, the training set and the testing set. 70%-80% is in the training set while the rest is in the testing set.

  1. Training

This data is then fed to the model during training. The model learns to make assumptions, predictions, solves patterns, makes groups and accomplishes the task given to it. The model is trained by using various training algorithms.

  1. Validation (sometimes required)

It is done to finetune the model’s hyper parameters and to prevent overfitting.

  1. Testing

Testing is the phase where the model is evaluated. Its performance is checked and the predictions it makes are compared to the expected output. The testing phase determines if the training worked or not.

  1. Improvements

The final stage is to improve the model by various methods. Minimizing errors and reducing the error range and the precision and accuracy of the model. 

How AI are Made

Smart Industry Technology Isometric Concept

Free Vector | Smart Industry Technology Isometric Concept (freepik.com)

Data collection and processing

Data collection is a fundamental process in creating an AI model. Data is the life line of the model and it will behave as the data is given to it. So, it is crucial to collect correct data and information to train the model on.

Data can be collected from various sources like

  1. Databases
  2. Web scraping
  3. Surveys
  4. Sensors
  5. Government institutions
  6. Buying data

Data once collected in raw form must be cleaned. The cleaning process includes various steps which are,

  1. Removing Duplicate records
  2. Correcting errors
  3. Handling missing values
  4. Formatting/standardizing
  5. Removing inconsistencies
  6. Fixing naming conventions
  7. Data labelling (for supervised learning)
  8. Data integration (if collected from multiple different sources)

Data quality directly effects the quality of the selected model. The model will behave according to the

data that is given to it. If the data is faulty, the model will also produce incorrect responses. The training step is invaluable if the data is not correct.

Model Selection

After the collection of data, the next step is to determine the type of model to train. Choosing the right model falls upon the type of problem at hand. For a regression problem the best model will be a regression model. The classification model will not be useful here. Some types of models are given below.

  1. Linear Regression

Used for regression, forms relationship between dependent and independent variables by fitting a linear equation to the data.

  1. Logistic Regression

Classification model used for binary classification.

  1. Decision Trees

For both regression and classification. Splits data into branches (subsets of data) based on input fields.

  1. Random Forest

Uses multiple decision trees to improve the accuracy of the model.

  1. Support Vector Machines (SVM)

Finds the hyperplane that best separates the data into different classes.

  1. K-means clustering

It partitions the data into K distinct clusters based on similar features.

After selecting the desired model, the training process can begin. Training method should be chosen keeping in mind each has its own pros and cons. After training the model can be tested. The tests will point out shortcomings in the model’s performance which can then be targeted and finetuned in the evaluation of the tests. Further training can be done if the model is not meeting the standard set.

Overfitting and Underfitting

Overfitting occurs when the model is exceptionally well suited for the training data but does poorly on the test data. The model picks up the noise and outliers in the training data that do not generalize to the real data or even the test data so the performance on the real data is poor. This occurs when,

  1. Too many parameters are involved
  2. Insufficient training data is available
  3. Excess of training occurs

The other concept, Underfitting is the poor performance on both the training and the test model when the model is way too simple to recognize the underlying patterns in the data. This makes it overly simplistic about assuming the data leading to incorrect responses. This occurs when,

  1. Model is way simpler than the facing problem
  2. Training time is insufficient
  3. Inadequate data available.

Hyperparameter tuning

Hyperparameters are learning process controllers, such as learning rate, layers of neural network, etc. They are set before the training and can severely affect the training and significantly improve the model’s performance. Common tuning techniques are,

  1. Random Search
  2. Grid Search
  3. Gradient based optimization
  4. Evolutionary optimization

They can lead to higher performance, preventing issues like overfitting or underfitting and ensure the model will generalize to new data. 

Deployment and Monitoring

  1. Once trained the model is exported in a suitable format. In special frameworks like TensorFlow or files in python. 
  2. The model is then integrated into the production environment where it can be accessed by applications which can send data and receive predictions from the model.
  3. Infrastructure is set up to host the model. This ensures the model can handle load and scale as needed later.
  4. Before full deployment the model is tested on a small scale and then checked for performance, power usage, predictions and latency and integration.
  5. The final step is to bring the model to the real time predictions. The model is finally deployed to be used and to be improved.
Cloud technology with futuristic hologram on smartwatch

Free Photo | Cloud technology with futuristic hologram on smartwatch (freepik.com)

Monitoring the model is an important step as it ensures the model is up to date and running smoothly. This includes continuously monitoring the up time of the model, the predictions and the precision and accuracy. Analysing the errors and mentoring the response to new data may give hints if the model needs to be retrained or it will learn the new data by itself. Finally, the model must alert of any errors or misuses to the deployers, and the report of its health and performance. 

ChatGPT

ChatGPT (Generative Pre-Trained Transformer) is an AI chatbot developed by OpenAI and launched on November 30, 2022. The foundational model (A broad model trained on a large data that can be specified to task specific models) for OpenAI’s ChatGPT is their own GPT-n series, most recent being the GPT-4. ChatGPT is a task specific model fine tuned from a broad foundational model. In January 2022, OpenAI introduced InstructGPT. It was a series of models which were fine tuned, using combination of supervised and reinforcement learning from human feedback (RLHF). This training continued to grow and the GPT model became what is now ChatGPT. It is based on a transformer model. 

Programming background collage

Free Photo | Programming background collage (freepik.com)

A transformer is a model that solves the problem of sequence transduction. They transform an input sequence into and output sequence. This includes any tasks like speech recognition, translation, text-to-speech transformation and more.

How ChatGPT works

ChatGPT is based on transformer model, which consists of multiple attention layers that allow the model to focus on different parts of the prompt (text). This makes it highly effective for language processes. ChatGPT has multiple layers each containing attention heads. They allow it to process data in parallel.

The Transformer model is trained on a large data set. The model is Pre-Trained on a diverse dataset that helps the model learn Grammer, sentence creation, facts about the world, gains knowledge and build reasoning abilities. The model is then Fine-Tuned with narrower datasets and human reviewers following specific guidelines. This makes the responses more accurate and contextually sound

The response is generated through a series of steps in the underlying transformer model.

  1. The input prompt is converted into a format the model can understand. This is usually in a sequence of tokens (words)
  1. The model is trained to understand the contextual meaning of the prompt. It uses the sequence of tokens to determine the relationship and the importance of each token.
  1. The model generates the next token (as the answer to the prompt). It puts out different possibilities and choses the one with the highest probability. 
  1. The process is repeated till the model generates a complete response.
  1. The model then takes the generated tokens and converts (translates) it into a format the human user can understand (the preferred language the user is giving prompt in)

ChatGPT has been trained on an immensely large set of data and each prompt generated is adding to the training. This allows ChatGPT to generate humanlike responses. The GPT model is being used as base for many other language models in the worlds. Some are,

  • Chatbots for websites.
  • Content creation bots
  • Customer support bots.
  • Artificial personalities. And more.

Other Popular AI Tools

After the launch of ChatGPT, many other AI models have also surfaced. Some are language processors other image processors. A few AI tools available are, 

  1. Character AI

Character Ai is a host of different GPTs each trained to be a different personality. They include Famous people, Fantasy RPGs, Novel righters, Debate champions and much more being added.

Chat duplication : r/CharacterAI

character.ai | Personalized AI for every moment of your day

  1. Mid journey

Mid journey is similar to OpenAI’s Dall-E and Stability AI’s stable diffusion. It is a generative AI that transforms text to images. The AI takes prompt as text and transforms them into pictures.

Оплата Midjourney из России. Поможем оплатить. Сервис оплаты Remoney.

Midjourney

  1. RunwayML

It is a creative suite for artists providing tools like image editor, video editing and creating designs all streamlined with AI capabilities.

RunwayML : Bringing Machine Learning(ML) to Creators of All Disciplines ...

Runway – Advancing creativity with artificial intelligence. (runwayml.com)

  1. Perplexity

It is designed specific for research and helps users find and synthesize information from various sources, making it ideal for academic and professional research.

Perplexity AI Launches iOS Version of Conversational Answer Engine ...

Perplexity

Ethical Considerations and Challenges of AI

Use of AI presents certain ethical considerations and hurdles. 

  1. AI bias and Fairness

AI systems generate responses as they have been trained. They inherit bias from the data they are trained on. This could lead to unfair and discriminatory outcomes. Ensuring diverse and representative training data and implementing bias detection can lead to fair responses.

  1. Privacy, Data and transparency

AI models are trained on huge masses of data. Data that organization get from the real world. This raises a security concern for data protection and security. Data protection measure must be implemented. Organization must be transparent to what they are going to use the data for and how will it impact the model. Unauthorized access and misuse of personal data is a privacy violation.

  1. Accountability

When an AI system makes a mistake, the organizations should be held accountable. Determining who is accountable when an AI makes a mistake or causes harm in a complex system (such as automated driving) is crucial for maintaining the peoples trust in the model.

  1. Environmental impact & use/misuse

Training large model requires a huge number of computational resources that in turn draw a large amount of power. This can cause a substantial environmental footprint. The use of AI models must be governed and policies and regulations must be put in place for any misuse of the model.

  1. Employment impact

As AI grows it is taking place of human workers by introducing automated robots. A single robot is capable of doing the work of 10 humans. Employment rates have plummeted with the introduction of robots in the industry. Addressing this issue and creating more jobs that require humans along side AI can help lower down the unemployment rates.

Still life illustrating ethics concept

Free Photo | Still life illustrating ethics concept (freepik.com)

Conclusion

AI is a crucial part of todays age. AI algorithms help us make better decisions, perform better health care, get better fitness information and much more. AI models are machines trained using different algorithms (supervised, unsupervised and reinforcement learning are common). Data is the blood of AI models. They are trained on data and then tested, evaluated and fine tuned before putting them against real world data. Data collection, model selection, training, evaluating, hyperparameter setting, deployment and monitoring are the processes that make up an AI model. AI models like ChatGPT, Dall-E, Midjourney, Stable diffusion is on the market. Each Model carrying their own pros and cons. AI models are built for human use and should not be misused or caused harm with instead they are built to provide information and make task easier.

Recap of Key points

What is AI? 

AI is artificial intelligence, mimicking human intelligence and performing tasks like humans.

AI Algorithms

A set of steps is called an algorithm.

Types of algorithms.

Supervised learning: contains a supervisor and labelled data sets

Unsupervised learning: has no supervisor and no guidance. Machine is independent. Used to find patterns and similarities.

Reinforcement learning: Has a reward (for good performance) and punishment (for bad performance) system to train.

Components of AI Algorithm

Data

Model

Parameters

Training

Evaluation

Optimization

Making of AI

Data collection, cleaning and formatting.

Model selection based on the type of problem.

Model training, testing, evaluation, finetuning and deployment.

ChatGPT and other tools

Developed by OpenAI in Nov 30, 2022. Based on transformer model. Generates human like response using tokens

Popular AI tools

Character AI: host of different AI personalities

Midjourney: Text to Image generation AI

RunawayML: Creative suit for artists with AI powered tools.

Perplexity: specialized tool for academic and professional research

Ethical Considerations

AI bias and Fairness.

Privacy and Transparency.

Accountability.

Employment impact.

Environmental Impact.

FAQs

What is AI Algorithm?

Algorithms are a sequence of steps/set of steps that turn an input into useable and logical response.

How do AI algorithms learn?

Through three main types. Supervised learning, Unsupervised learning and reinforcement learning.

What is ChatGPT?

It is a Generative Language AI Chatbot developed by OpenAI in 2022.

How does ChatGPT generate responses?

It generates response by converting the prompt given by the user into understandable format and process the data according to its algorithms and training to produce a human like response.

What are some applications of AI tools?

Natural Language Processors

Health care

Finance

Retail/E-commerce

Image/video processing

What are the ethical concerns related to AI?

Bias of an AI models response

Data privacy

Transparency

Accountability 

Employment issues

Environmental footprints.

Share on:

As a passionate technology enthusiast and avid blogger. I am dedicated to explore the evolving world of tech innovations. I aim to solve problems of others. I have expertise in Digital Content creation and Social Media Marketing.

Leave a Comment