A Short Course On Generative AI

Welcome to the world of Generative AI, where artificial intelligence technology unleashes its creative potential to produce various forms of content such as text, imagery, audio, and synthetic data. In this course, we will delve into the fascinating realm of Generative AI, exploring its definition, functionality, model types, and applications.

Understanding Artificial Intelligence (AI)

But before we embark on this journey, let’s establish a foundational understanding of artificial intelligence. AI, akin to disciplines like physics, is a branch of computer science dedicated to creating intelligent agents capable of reasoning, learning, and acting autonomously. Its goal is to build machines that can think and behave like humans. Within AI, machine learning is a subfield that empowers systems to learn from input data, making accurate predictions without explicit programming.

Machine Leanring (ML)

Machine learning encompasses two primary classes of models: supervised and unsupervised learning. In supervised learning, models learn from labelled data, which includes tagged information like names, types, or numbers. These models leverage historical examples to predict future values or outcomes. For instance, in the context of a restaurant, a supervised learning model could learn from past data on bill amounts and corresponding tips to predict future tip amounts based on factors like order type (pickup or delivery).

On the other hand, unsupervised learning is all about discovering raw, unlabeled data to identify inherent patterns and groupings. For example, you might analyse employee tenure and income data to cluster employees and determine if someone is on a fast track within the organisation.

Deep Learning (DL)

Now, let’s delve deeper into the concepts that form the bedrock of Generative AI. The model’s performance is evaluated in supervised learning by comparing its predictions against the actual training data. The model minimises the error between predicted and actual values through optimisation techniques until they align closely. Meanwhile, deep learning, a subset of machine learning, utilises artificial neural networks inspired by the human brain. These networks comprise interconnected nodes or neurons that learn to perform tasks by processing data and making predictions. Deep learning models, often characterised by multiple layers of neurons, excel in recognising complex patterns compared to traditional machine learning models. DL can be divided into two types discriminative model and generative model.

Discriminative Models

In machine learning, discriminative models are powerful tools for classification and prediction tasks. Unlike their generative counterparts, discriminative models excel at distinguishing between different kinds of data instances, allowing them to assign labels or make decisions based on input features.

Generative Models

Unlike discriminative models, which focus on distinguishing between different classes or categories of data, generative models learn the joint probability of input and output data, enabling them to generate new samples from the learned distribution. Generative models have numerous applications, including image synthesis, text generation, voice synthesis, and more. Generative AI uses these models to create new, human-like text, images, or sounds, opening up possibilities for various applications, from creative arts to automated systems.

Generative AI (GenAI)

Generative AI operates within the framework of deep learning and employs artificial neural networks capable of processing labelled and unlabeled data. This approach encompasses supervised, unsupervised, and semi-supervised learning methods. Semi-supervised learning involves training a neural network with a small amount of labelled data and a larger pool of unlabeled data. The labelled data helps the network grasp the basic task concepts, while the unlabeled data aids in generalisation for new examples.

Large Language models (LLM)

Let’s focus specifically on where Generative AI fits into the broader AI landscape. Generative AI is a subset of deep learning, utilising artificial neural networks to process labelled and unlabeled data. It encompasses large language models (LLM), a specific type of generative AI model. Large language models, such as GPT-3 (Generative Pre-trained Transformer 3), have garnered significant attention for their ability to produce highly realistic and contextually appropriate text. These models are built upon the foundation of deep learning, explicitly leveraging a sophisticated architecture called Transformers. Learning from extensive training data, large language models understand grammar, semantics, and domain-specific knowledge.

Generative Language Models (GLM)

Generative language models, in particular, play a vital role in understanding patterns in language through training data. They predict the following sequence of text based on their learned patterns, making them powerful tools for text generation. They can provide contextual answers, complete sentences, or answer questions based on the massive amounts of data they have been trained on.

Protective vs Generative Model

Predictive machine learning models predict future outcomes based on historical data. For example, a predictive model might forecast future purchases or customer churn based on past customer behaviour.

On the other hand, generative AI models generate new data instances that resemble the training data. For instance, a generative AI model trained on a dataset of images of cats can generate new images of cats that it has never seen before.

Both models learn from data, but while predictive models are primarily concerned with making accurate predictions on new data, generative models focus on understanding the underlying data distribution to create new data points similar to those in their training set.

The Emergence Of Generative AI

The emergence of generative AI owes much to the transformative impact of Transformers, a revolutionary model architecture in natural language processing. Transformers consist of an encoder and decoder, with the encoder encoding input sequences and passing them to the decoder. The decoder learns to decode representations for various tasks. However, it’s important to note that Transformers may sometimes produce hallucinations—nonsensical or grammatically incorrect outputs—due to insufficient training data or context.

What is not GenAI?

Generative AI (GenAI) is an artificial intelligence that learns from many examples and can create new things based on what it has learned. Imagine if you show it a bunch of pictures of dogs; it might be able to create a new picture of a dog that doesn’t exist but looks real. It’s like having a really smart robot that can write stories, draw pictures, or even make videos based on what you ask.

However, GenAI isn’t just about guessing or sorting things into categories. It doesn’t just look at past data to say what might happen in the future, which is what some simpler AI models do. And while it can write like a human and respond appropriately to different topics, it might sometimes make silly mistakes or write things that don’t make sense. This can happen if it hasn’t learned from enough examples or the examples it learned from weren’t very good. So, while GenAI is powerful, it still needs good data to learn from and clear instructions to do a good job.

Transformer

A transformer is like a smart language translator machine. When you give it a sentence, it breaks it down (this part is called the encoder), trying to understand the meaning and the relationships between the words. Then, it builds up a new sentence (using the decoder), maybe in a different language or answering a question based on what it just learned. So, it’s a machine that understands and generates language.

One issue with these transformers is that they might say things that don’t make sense or are out of place. We call these ‘hallucinations’ (I explain this also below). This is like if someone suddenly started talking about penguins in the middle of a conversation about cars – it just doesn’t fit. This can happen if the machine hasn’t learned enough from the right kind of data or if we don’t give it enough information to start with.

Hallucinations

In the context of AI, “hallucinations” refer to the instances where the AI model generates outputs that are nonsensical, grammatically incorrect, or don’t align with the input or reality. These can be words, phrases, or whole sentences that seem out of place or unrelated. This typically happens when the AI model hasn’t been trained on sufficient or accurate data, hasn’t been given enough context, or hasn’t been provided with enough constraints during its training. The term “hallucinations” is used because, like human hallucinations, the model generates these outputs and does not have a basis in the data or input provided to the AI.

Prompt Engineering

In language models and natural language processing, prompt engineering plays a pivotal role in shaping and controlling the output generated by these robust AI systems. Prompt engineering involves crafting effective prompts or inputs to guide the model’s responses and steer it towards generating desired outputs.

Prompt engineering refers to crafting specific input prompts to guide the behaviour of AI models, particularly large language models, towards generating the desired output. It involves designing, testing, and iterating on prompts to obtain the most effective results. The objective is to instruct the AI model in such a way that it understands the task at hand and provides useful and accurate responses.

For example, instead of simply prompting a model with “Elephants”, which is vague, you might use a more specific prompt like “Describe the characteristics and behaviour of African elephants”. This refined prompt gives the model a clear task, thus guiding it to generate the detailed and relevant information you seek. In essence, prompt engineering is a method of user-model communication to bridge the gap between human intention and AI model output.

Prompt Design

Prompt design, on the other hand, takes a broader and more strategic perspective. It involves the conceptual and strategic planning of prompts to align with the overall objectives and requirements of a given application or use case. The prompt design focuses on higher-level considerations such as defining the task, setting the context, determining the desired style or tone, and outlining any specific constraints or guidelines for the model’s responses.

Prompt design plays a crucial role in controlling the output of generative AI models. Developers can guide the models to generate desired responses by designing effective prompts. Generative AI tools and resources such as Generative AI Studio, Generative AI App Builder, and PALM API empower developers to explore, customise, and integrate generative AI models into their applications seamlessly. These tools open avenues for developing digital assistants, custom search engines, sentiment analysis, image captioning, and more.

Foundation models

Generative AI works by leveraging machine learning algorithms to learn patterns from a vast amount of data and then generating new, original content based on that learned information. This could be in the form of text, images, audio, video, or even actions, depending on the specific model and task at hand. Like the Transformer models, these models consist of an encoder-decoder architecture where the encoder processes the input, and the decoder generates the output. The AI system’s responses are controlled through prompts, which are text inputted to guide the output. To improve their performance, these models can be fine-tuned or adapted for specific tasks, creating what’s known as “Foundation models”. They have vast applications ranging from language translation to image generation, from executing tasks to generating code. Tools like Google’s Generative AI Studio aid developers in creating and deploying these AI models, making the technology increasingly accessible.

Generative AI model types

Generative AI models can be broadly divided into several types based on their input and output:

  • Text-to-Text Models: These models take natural language input and produce a text output. They are often used for tasks like language translation, question answering, or text completion.
  • Text-to-Image Models: These models take text descriptions as input and generate corresponding images. This is achieved by training on a large set of images, each captioned with a short text description.
  • Text-to-Video Models: These models generate a video representation from text input. The input text could be a single sentence or a full script; the output is a video that aligns with the input text.
  • Text-to-3D Models: These models generate 3D objects corresponding to a user’s text description. This can be used in gaming, virtual reality, or other 3D applications.
  • Text-to-Task Models: These models are trained to perform a defined task or action based on text input. This could be a range of actions, like answering a question, making a prediction, or taking some action in a user interface.

These model types represent a range of applications for generative AI, allowing the generation of a wide variety of content and actions from text inputs.

Generative AI applications

Generative AI applications encompass a wide range of fields and tasks. Here are some typical applications:

  • Content Creation: Generative models can create new content in the form of text, image, video, and 3D objects. They can be used for writing articles, generating artwork, creating videos, or 3D modelling.
  • Text Translation: Text-to-text models can be used to translate text from one language to another, facilitating communication between different language speakers.
  • Sentiment Analysis: Generative models can analyse and infer sentiments from user-generated content, which is useful for businesses to understand customer feedback or for social listening.
  • Code Generation: They can be used for tasks like debugging, explaining, and translating code from one programming language to another. This can help developers automate repetitive tasks and increase efficiency.
  • Conversational AI: Generative models can be used to create chatbots or digital assistants that can interact with users in a natural, human-like way. They can understand and respond to user queries, providing customer support, personal assistance, and more.
  • Education and Training: Generative models can generate educational content and tutorials, providing personalised learning experiences for students.
  • Gaming: Text-to-3D models can be used to generate objects, characters, or environments in games based on textual descriptions, providing new possibilities for game design.
  • Fraud Detection and Risk Analysis: In finance, generative models can analyse transaction patterns to detect fraudulent activities or assess risks.

These are just a few examples of the wide array of applications that generative AI models can have. The versatility of these models provides endless possibilities for their application across many sectors.

Generative AI has the potential to revolutionise various industries, including healthcare, finance, and customer service. Its applications span code generation, debugging, natural language communication, image synthesis, etc. By harnessing the power of generative AI, developers can unlock new levels of creativity and innovation, paving the way for intelligent systems that can generate content and assist users in unprecedented ways. Stay tuned for more from me on Gen AI at enamulhaque.co.uk.