timelapse

Practical AI: Utilizing Large Language Models

Who Am I?

  • Software developer with a BSc in Computer Science.
  • About a year experience in utilizing LLMs (ChatGPT) every day at work.
    • I don't develop AI systems, rather I utilize them to improve my programming.
  • I have voraciously consuming the latest developments in generative AI.
Your Photo

Roadmap

Purpose: To provide a comprehensive introduction to AI, machine learning, and LLMs, enabling the audience to understand, evaluate, and harness the power of generative AI for their work and creativity.

Why learn about AI tools?

  • Empowerment: Leveraging AI tools can empower you to create amazing work.
    • Like any skill utilizing AI tools improves with practice.
  • Rapid Improvement: AI is improving at a breathtaking pace, it seems likely that almost all 'knowledge' and artistic professions will be changed forever.
    • New jobs and artist developments will challenge existing institutions.
  • Informed Evaluation: Understanding how these tools work enables evaluation of 'AI hype'.
Nvidia GB200

Birds with Hats 🐦🎩

Grey Jay
Hawk
Pelican
Pelican
Pelican
Eagle
Magpie
timelapse

Introduction to 'AI'

Defining Artificial Intelligence (AI)

    AI encompasses the development of computer systems capable of performing tasks that traditionally require human intelligence.

  • Task-Specific AI:
    • Designed for specialized tasks, demonstrating intelligence in a narrow domain.
    • Image recognition, speech recognition, and game-playing AI are examples of task-specific AI.
  • General AI (AGI):
    • Systems that excel across a wide range of tasks, potentially surpassing human capabilities.
    • AGI could learn and adapt to new situations without explicit programming.
Figure Robot

"traditionally require human intelligence"

In 1950, British Mathematician Alan Turing proposed the Imitation Game to evaluate if a computer possesses intelligence.

  • The Turing Test:
    • Challenges machines to engage in dialogue so convincingly that observers cannot distinguish it from human responses.
  • Recent LLMs (Claude Opus, GPT-4) arguably have the ability to mimic human dialogue at a level that meets the criteria of the Turing Test.
    • There is no longer a clearly defined test for machine intelligence.

Machine Learning & Neural Networks

Machine learning is the process were a computer system can be trained to accomplish a task. A neural network is an algorithm that can learn patterns from data.

  • Machine Learning: Beyond Traditional Programming
    • In traditional programming, tasks are solved similarly to following a recipe. This method falls short with complexity and unpredictability.
    • Machine Learning is akin to teaching a computer to cook by tasting dishes: it identifies patterns with flexible, adaptive learning.
  • Neural Networks: Imitating the Brain
    • Neural networks simulate the brain's structure with interconnected 'neurons'.
    • They can be trained using a technique called 'backpropagation', which iteratively adjusts the neurons' connections to produce the desired outcome.
Neural Network Illustration

Machine Learning Paradigms

Cat 1
Supervised learning
Dog 1
Unsupervised learning
Reinforcement Learning

Recognizing Cats and Dogs

Cat 3
Dog 3
Cat 4
Dog 4
Cat 5
Dog 5
Cat 1
Dog 1
Cat 2
Dog 2

Step 1: Collect and Label a Dataset

Cat 1
Cat
Dog 1
Dog
Cat 2
Cat
Dog 2
Dog
Cat 3
Cat
Dog 3
Dog
Cat 4
Cat
Dog 4
Dog
Cat 5
Cat
Dog 5
Dog

Step 2: Neural Network Training

A guessing game between a teacher and a toddler is a simple analogy for understanding neural network training.

  1. Initial Guesses: The neural network, like a toddler, makes initial guesses when shown labeled images of cats and dogs. It may not always be correct at first.
  2. Learning from Mistakes: Just as a teacher corrects a toddler's mistakes, the network learns from the differences between its guesses and the actual labels, adjusting its understanding accordingly.
  3. Repetition and Improvement: With repeated exposure to more examples and continuous feedback, the neural network gradually improves its ability to classify images accurately, similar to how a toddler's skills develop through practice and guidance.

Key Point: This process of guessing, receiving feedback, and learning from mistakes is the foundation of how neural networks learn to recognize and classify patterns in data.

Cat 3
Dog 4
Dog
Prediction:
Cat: 70%
Dog: 30%

Step 3: Testing the Trained Network

Dog 4
Prediction:
Cat: 95%
Dog: 5%
Dog 4
?
Prediction:
Cat: 10%
Dog: 90%

AI Basics: Key Takeaways 🔑

timelapse

Large Language Model background

Introducing Large Language Models

LLMs are computer programs that output coherent and relevant text in response to an input prompt.

  • OpenAI's release of ChatGPT in November 2022 brought LLM technology into the public consciousness.
  • LLMs can be trained in a variety of sizes measured by parameter count
  • The largest LLMs have demonstrated an unprecedented ability to 'reason' with language

Just like how the cat and dog recognizer learned from labeled images, LLMs learn from vast amounts of text data to capture the intricacies of human language.

GPT Model Growth Graph

Increasing LLM size seems to improve performance on 'reasoning' tasks.

How LLMs Generate Text

LLMs generate text by playing a guessing game, similar to the cat and dog classification example we saw earlier.

  • Instead of guessing the correct label for an image, LLMs predict the most probable next word based on the previous words in the sequence.
  • This process is repeated, with each new predicted word added to the input sequence 🔄

LLMs are a highly advanced version of autocomplete.

Compressing the Internet

LLMs learn from vast amounts of diverse online data, essentially "compressing" the knowledge available on the internet into their parameters.

  • During training, LLMs capture patterns, relationships, and real-world knowledge from this data.
    • This is similar to how the cat and dog classifier learned from labeled images.
  • Training top-of-the-line LLMs, like GPT-4, is speculated to cost upwards of $100 million.

A good language model is also a model of the world.

Transformers and Attention: The Backbone of LLMs 🤖🚗

The transformer architecture, introduced in 2017, has been crucial to the development of LLMs.

  • Transformers utilize an attention mechanism that allows LLMs to focus on the most relevant parts of the input data.
    • (no attention): "I went to the Calgary Stampede and met a nice [day]" (phone keyboard)
    • (w/ attention): "I went to the Calgary Stampede and met a nice [cowboy]." (GPT-3.5)
  • This architecture consists takes input data and generate appropriate outputs, such as translations, summaries, or responses.
  • Transformers are highly versatile adapt to handle a wide array of input, including text, audio, images, and video.
Transformer Architecture
Transformer Architecture

Completion Models

We have described LLMs autocomplete for internet documents, this is different from the helpful assistant presented by a tool like ChatGPT

Prompt: Can you suggest some dog names?

(davinci-002):

Please?

Name your favorite black and tan male and female dog names,

Name your favorite black and tan Great Dane male and female dog names. Please give a variety. Thank you!

Prompt: list of dog names: Randy,

(davinci-002):

Taffy / Tiffy, Tonto, Risa / Sheena, Sid, Sandy / Sandy, Spike, Scruffy, Teddy, Bodi, Lady, Maxx, Sandy, Roxy, Bella, Fifi, Lucky, Nobi, Marvin, Buddy, Ted, Oscar, Cookie, Cleo, Champ, Cheko, Sam, Pickles, Kevin, Toby, Shadow, Colin, Noro, Brian, Scotty, Kimichi, Pepper

LLM personas

LLMs utilize a compression of the knowledge available on the internet. By fine-tuning this compressed knowledge, we can create models that excel at specific tasks.

  • Models like ChatGPT are fine-tuned for conversational interactions, with the model playing the role of a helpful assistant.
    • Prompting is an effective way to invoke an persona in an assistant LLM.

Prompt: please describe large language models to me in 3 sentences

(GPT-4): Large language models (LLMs) like ChatGPT are advanced AI systems trained on vast amounts of text data to generate human-like responses to textual inputs. (...) These models use techniques from deep learning, specifically transformer architectures, to understand and produce text contextually, adapting their responses based on the input they receive.

Prompt: As a kindergarten teacher, please describe large language models to me in 3 sentences

(GPT-4): Large language models are like very smart robots that can read and write. They learn by studying a huge amount of books, articles, and websites to understand and use language just like people do. They can help answer questions, write stories, and even explain things in different ways depending on who they're talking to!

Reinforcement Learning from Human Feedback

Reinforcement Learning from Human Feedback

Users of ChatGPT participate in reinforcement learning when the model asks you to select the best of two responses.

Limitations of LLMs

  • Hallucinations:
    • LLMs are trained on the internet which contains inaccurate information.
    • Ex. Generating convincing-sounding but fictional news articles or scientific discoveries
  • Biased outputs:
    • Ex. Gender stereotyping in generated stories like defaulting to female pronouns for nurses or teachers
  • Difficulty handling complex situations:
    • Ex. Customer service chat-bots struggling with unique situations requiring human judgment
Transformer Architecture

Unnecessary Refusals

her fleece as white as copyright infringement

Effective Prompting Techniques

We'll explore three powerful techniques for enhancing your interactions with large language models:

  • Letting LLMs think step-by-step
  • Using examples to guide LLM outputs
  • Assigning roles to LLMs for improved performance

By mastering these prompting strategies, you'll be able to unlock the full potential of LLMs and achieve better results in your applications.

Let LLMs Think Step-by-Step

Encourage LLMs to think through problems step-by-step for more accurate and nuanced responses.

Prompt: What is the capital of France? Think step by step.

Response:

<thinking>

Step 1: France is a country in Europe.

Step 2: The capital of a country is usually its largest and most important city.

Step 3: Paris is the largest and most important city in France.

</thinking>

<answer>Therefore, the capital of France is Paris.</answer>

Step-by-Step Thinking

Use Examples to Guide LLM Outputs

Provide well-crafted examples in prompts to improve accuracy, consistency, and quality of LLM responses.

Prompt:

Extract the names and roles from this text:

<example>
Input: Sarah Johnson, a talented writer, crafts compelling articles for the company blog.
Output: Sarah Johnson [WRITER]
</example>

John Doe, a skilled programmer, works at Acme Inc. Jane Smith, an experienced designer, collaborates with him on various projects.

Response:

John Doe [PROGRAMMER]

Jane Smith [DESIGNER]

Using Examples

Give LLMs a Role

Assign specific roles to LLMs to prime them for desired responses, improve accuracy, and tailor tone and demeanor.

Prompt: You are a biology teacher. Explain the concept of photosynthesis to your students.

Response:

Hello, class! Today, we'll be learning about photosynthesis, the fascinating process that allows plants to create their own food using sunlight. Imagine you're a plant, soaking up the sun's rays. Your leaves are like tiny solar panels, capturing the light energy. Inside your leaves, you have tiny green helpers called chloroplasts. They use the sunlight, along with water from the soil and carbon dioxide from the air, to make glucose, a type of sugar that you use for energy. As a bonus, you release oxygen into the air, which helps all the animals (including us!) breathe. So, the next time you see a plant, remember the incredible process of photosynthesis that keeps our world green and alive!

Roleplaying
timelapse

Conclusion

The Future of LLMs

  • As new high performance AI accelerator hardware is released, we can expect LLMs to become more capable of handling complex language tasks.
    • With better LLMs creating 'autonomous agents' will become more viable, enabling LLMs to prompt themselves to solve complex problems.
    • As this capacity improves more and more software will be written with autonomously by AI systems.
  • LLM systems could drive costs down in key service industries like: healthcare, education, and the legal system.
  • LLMs have the potential to automate certain tasks in customer support and other knowledge work domains, which may lead to job displacement in these areas.

Cost Reduction?

Perhaps LLM can stem rapidly inflating costs in education and healthcare.

Summing up

  • Give flagship language model like Claude 3 Opus or GPT-4 a try.
  • LLMs can enable individuals to leverage their creativity on projects that would have otherwise been impossible
  • AGI is the stated goal of OpenAI, LLMs are seen as a stepping stone on that path.