ML/AI, CV

Generative AI as a Creative Tool

Generative AI (Gen AI) is an exciting frontier in technology where machines are empowered to create, shaping the future of human-machine interaction. This innovative tool is transforming fields left and right, offering quick and efficient solutions to complex problems with its ability to generate new designs and ideas.


Introduction

Generative AI is an exciting field of artificial intelligence that opens the door to creating new and original content, spanning from written text to stunning visuals and even computer-generated music. It showcases the innovative side of AI by going beyond simple analytical tasks to engage in creative processes. Immediatley raises the question does it replace humans, well my hope is that it will revolutionise the current work force just like how robotic automation changed the landscape of manual labour, the important thing to remember is that the future impact of AI is still undetermined, and we all can play a part in ensuring that it is used responsibly.

Training generative AI models is about teaching computers to create new content, like text or images, by learning from huge datasets. This training helps AI to understand and recreate the complex patterns found in human language and visual arts. The process is intricate but immensely rewarding, leading to AI that can generate amazingly realistic outputs.

BuZzz words

Large Language Models (LLMs): These are AI models specifically designed to understand and generate human language by being trained on a vast amount of text data.

Variational Autoencoders (VAEs): A type of AI model that can be used to create new images. It has two main parts: the encoder reduces data to a simpler form, and the decoder expands it back to generate new content.

Latent Space: A compressed representation of data that the autoencoder creates in a simpler, smaller form, which captures the most important features needed to reconstruct or generate new data.

Parameters: Parameters are the variables that the model learns during training. They are internal to the model and are adjusted through the learning process. In the context of neural networks, parameters typically include weights and biases.

Weights: Weights are coefficients for the input data. They are used in calculations to determine the importance or influence of input variables on the model's output. In a neural network, each connection between neurons has an associated weight.

Biases: Biases are additional constants attached to neurons and are added to the weighted input before the activation function is applied. Biases ensure that even when all the inputs are zero, there can still be a non-zero output.

Hyperparameters: Hyperparameters, unlike parameters, are not learned from the data. They are more like settings or configurations for the learning process. They are set prior to the training process and remain constant during training. They are external to the model and are used to control the learning process.

Autoregressive text generation: Autoregressive text generation is like a game where the computer guesses the next word in a sentence based on the words that came before it. It keeps doing this to make full sentences.

Latent space decoding: Imagine if you had a map of all the possible images you could create, with each point on the map being a different image. Latent space decoding is like picking a point on that map and bringing the image at that point to life.

Diffusion models: Diffusion models start with a picture that's full of random dots like TV static, and then they slowly clean it up, adding bits of the actual picture until it looks just like a real photo or painting.

Generative Adversarial Networks (GANs): A system where two neural networks, one to generate data and one to judge it, work against each other. This competition helps improve the quality of the generated results. (generators vs discriminators)

Recurrent Neural Networks (RNNs): A network that's really good at handling sequences, like sentences or melodies, because it processes one piece at a time and remembers what it saw before.

Transformer-based models: A more advanced type that looks at whole sequences at once, not one piece at a time, making it faster and smarter at tasks like writing sentences or translating languages.

Sequential Data: Data that is connected in a specific order, like words in a sentence or steps in a dance routine.

Perceptron: A basic computational model in machine learning that makes decisions by weighing input data. It's like a mini-decision maker that labels data as one thing or another.

Binary Classifier: A type of system that categorizes data into one of two groups. Picture a light switch that can be flipped to either on or off.

Vector of Numbers: A sequence of numbers arranged in order, which together represent one piece of data.

Activation Function: A mathematical equation that decides whether the perceptron's calculated sum from the inputs is enough to trigger a positive or negative output.

Multi-Layer Perceptron (MLP): A type of artificial neural network that has multiple layers of nodes, each layer learning to recognize increasingly complex features of the input data.

Input Layer: The first layer in an MLP where the raw data is initially received.

Output Layer: The last layer in an MLP that produces the final result or prediction of the network.

Hidden Layers: Layers between the input and output that perform complex data transformations.

Labeled Dataset: This is a collection of data where each piece of information comes with a correct answer or label. It's like a quiz with the questions and answers already provided.

Gradient Descent: This method helps find the best settings for a neural network by slowly tweaking them to reduce errors, similar to finding the lowest point in a valley.

Cost Function: Imagine it as a score that tells you how wrong your network's predictions are. The goal is to make this score as low as possible.

Learning Rate: This hyperparameter specifies how big the steps are when adjusting the neural network's settings during training. Too big, and you might skip over the best setting; too small, and it'll take a very long time to get there.

Backpropagation: Short for backward propagation of errors. This is like a feedback system that tells each part of the neural network how much it contributed to any mistakes, so it can learn and do better next time.

Tensors: Generalized versions of vectors and matrices that can have any number of dimensions (i.e. multi-dimensional arrays). They hold data for processing with operations like addition or multiplication.

Matrix operations: Calculations involving matrices, which are two-dimensional arrays, like adding two matrices together or multiplying them.

Scalar values: Single numbers or quantities that only have magnitude, not direction (for example, the number 7 or 3.14).

Linear algebra: An area of mathematics focusing on vector spaces and operations that can be performed on vectors and matrices.

Loss functions: They measure how well a model is performing by calculating the difference between the model's predictions and the actual results.

Cross entropy loss: This is a measure used when a model needs to choose between categories (like whether an image shows a cat or a dog), and it shows how well the model's predictions align with the actual categories.

Mean squared error: This shows the average of the squares of the differences between predicted numbers (like a predicted price) and the actual numbers. It's often used for predicting continuous values rather than categories.

Gradients: Directions and amounts by which a function increases most. The parameters can be changed in a direction opposite to the gradient of the loss function in order to reduce the loss.

Momentum: A technique that helps accelerate the optimizer in the right direction and dampens oscillations.

PyTorch Dataset class: This is like a recipe that tells your computer how to get the data it needs to learn from, including where to find it and how to parse it, if necessary.

PyTorch Data Loader: Think of this as a delivery truck that brings the data to your AI in small, manageable loads called batches; this makes it easier for the AI to process and learn from the data.

Batches: Batches are small, evenly divided parts of data that the AI looks at and learns from each step of the way.

Shuffle: It means mixing up the data so that it's not in the same order every time, which helps the AI learn better.

Training Loop: The cycle that a neural network goes through many times to learn from the data by making predictions, checking errors, and improving itself.

Epochs: A complete pass through the entire training dataset. The more epochs, the more the computer goes over the material to learn.

Optimizer: Part of the neural network's brain that makes decisions on how to change the network to get better at its job.

Tokenizers: These work like a translator, converting the words we use into smaller parts and creating a secret code that computers can understand and work with.

Tokenization: It's like cutting a sentence into individual pieces, such as words or characters, to make it easier to analyze.

Tokens: These are the pieces you get after cutting up text during tokenization, kind of like individual Lego blocks that can be words, parts of words, or even single letters. These tokens are converted to numerical values for models to understand.

Pre-trained Model: This is a ready-made model that has been previously taught with a lot of data.

Models: These are like the brain for computers, allowing them to learn and make decisions based on information they've been fed.

Datasets: Think of datasets as textbooks for computer models. They are collections of information that models study to learn and improve.

Trainers: Trainers are the coaches for computer models. They help these models get better at their tasks by practicing and providing guidance. HuggingFace Trainers implement the PyTorch training loop for you, so you can focus instead on other aspects of working on the model.

Example: Generate One Token at a Time

Everything above is theory. The fastest way to stop finding LLMs mysterious is to watch one work slowly enough to follow - a small model on a Raspberry Pi, where each token takes a visible fraction of a second to appear.

That walkthrough is its own post: Generate One Token at a Time - demystifying the LLMs.

Previous
It's machine learning time