List page: AI, ML and if statements

Detecting text produced by an LLM

LLM’s (large language models) can generate very convincing text, but this text can easily be detected using a not quite so large language model. The easiest way to do this is by looking at the perplexity of the text. This is a number that expresses how good a model (like GPT2) is at predicting a given sample of text. Perplexity is mostly used for measuring how good LLM’s are, but LLM generated texts have a consistently lower perplexity (easier to predict) than text written by a human. (AI, ML and if statements )

Image classification, on the MNIST dataset [ML4]

A common example of a problem that can be solved using ML, but is difficult otherwise is handwriting recognition. But before we can try, we first need to find a dataset, I will be using the MNIST dataset, containing 28x28 images of handwritten digits. The torchvision package provides an easy way to get it, but it must first be installed with pip: pip install torchvision Now MNIST can trivially be downloaded and loaded, but we need to convert it to an torch tensor from a PIL image. (AI, ML and if statements )

Going faster with pytorch [ML part 3]

The last post’s automatic differentiation engine was nice, but very slow, even by python standards. Even without this, python is quite a slow language, and usefully neural networks can get very big. The library pytorch provides a highly optimized (in C) and highly generic library of common tasks for ML. Installing it is very easy. (I would recommend using your system package manager on linux) pip install torch Because iteration in python is slow, torch provides vector (“tensors”) types, that allow working with many values at a time, similar to numpy ndarrays. (AI, ML and if statements )

Exploring step counts in stable diffusion.

TLDR: The step count has very litle effect on image content, and increasing it has rapidly deminishing returns over 20 steps. A lot of people run stable diffusion with very high step counts, like 100 or 200, but is this neccicary to produce good images? No. Here a a bunch of images generated with stable diffusion (K-LMS scheduler), with the same seed and prompt, with different step counts: Prompt 5 steps 10 steps 20 steps 40 steps 80 steps 160 steps A fantasy landscape. (AI, ML and if statements ) (stable-diffusion)

Deep learning, or going beyond linear regression [ML2]

Machine learning using a linear regression model is very simple, but rather underwhelming, as the results are always linear functions. Deep learning allows much more complex models to be created, without adding too much more complexity. This is done by creating a stack of layers, Each one with a series of neurons linearly determined from connected outputs on the previous layer. Each connection has a weight, a coefficient controlling the strength and direction of the connection, and each neuron has a bias value controlling the “default” value for the neuron. (AI, ML and if statements )

What is machine learning anyway? [ML1]

Machine learning (ML) and Artificial intelligence (AI) are some of the most common buzzwords on the internet right now. Almost every day some new company promises seemingly impossible feats of automation using ML, AI and deep learning, and they sometimes deliver. But before diving deeper, we need to define AI and ML. AI vs ML You will often here AI and ML used interchangeably, but they actually mean quite different things. (AI, ML and if statements )

Why does Chat-GPT Lie?

LLM’s (Large Language Models) like Chat-GPT are able to hold extended conversations with humans or generate relatively long runs of text (a few paragraphs), however despite sounding authoritative, they consistently create large amounts of fluent bullshit. The reason for this is that Chat-GPT is not some new magical sentient AI that has access to all the knowledge on the internet. It is simply a language model, tasked predict text: The quick red fox jumped over the [BLANK] It produces a prediction of the most likely words to follow a string of text. (AI, ML and if statements )

Smooth prompt interpolation with stable diffusion. [SD part 3]

You have probably seen smooth animations made with stable diffusion like this: https://www.youtube.com/watch?v=Bo3VZCjDhGI But how was it done? The answer is very simple, by running multiple prompts on the same image, the noise predictions can be combined to create an intermediate image. Changing the relative weights of the prompts, but keeping the initial latents (seed value) the same, a series of intermediate images can be created. Starting prompt: “A fantasy landscape” end prompt: “A sprawling cityscape”, seed: 42 (AI, ML and if statements ) (stable-diffusion)

Stable diffusion, in code. [SD part 2]

If you have not read the last post, I would highly recommend you read it first. Full disclosure, I will be using pre-trained models from the internet for unet, CLIP TextEncoder, and vae. Environment A cuda comparable (read NVIDIA) GPU will perform best, but a reasonably modern CPU with more than 8 GB of ram should work fine, as long as you are prepared to wait. Here are all the python libraries I used, these can be installed with pip. (AI, ML and if statements ) (stable-diffusion)

Just how does stable diffusion actually work? [SD part 1]

Stable Diffusion is a newish (Dec 20, 2021) image generation model. It can generate quickly generate highly detailed images with a concise text prompt: Prompt: “A photograph of an astronaut riding a horse”: It does this while being much faster and smaller than OpenAI’s DALL-E. Better yet, it it open source, meaning you can not only run it on your own hardware with out restrictions (It even performs decently on a CPU! (AI, ML and if statements ) (stable-diffusion)

ChatGPT and the future of programming.

ChatGPT is a free preview of OpenAI’s large language model, capable of answering questions, writing short programs or essays, and poetry. The model is set up as chatbot, and displays a remarkable ability to hold conversations or answer technical questions. It can even write short programs based on a description of the desired function: This has lead to speculation that similarly AI’s might replace human programmers and writers. However, ChatGPT’s knowledge is replaced by vivid confabulation when it is faced with a question that has not been discussed on the internet: (AI, ML and if statements )

Analyzing Tic Tac Toe, and writing an AI.

Using the min max algorithm to make a Tic Tac Toe AI. (games) (Computer programming) (AI, ML and if statements )