AI and LLM
TL;DR 0
ChatGPT-4 etc… are very good at these use cases.
- Coding code completion / summerisation of code
- Assimilating information and summerising
- Generation (text / image)
- Coversation (chatbots)
- Knowledge accessibility - question and answer
TL;DR
- there are no experts yet
- nobody knows what to do with it!
What is AI?
- Simulation of human intelligence in machines.
- ability of machines to perform tasks that.. associated with humans..
- learning, problem-solving, resoning, understanding natural language
GPT - Generative Pre-trained Transformer
but really
all it knows how to do is:
- from a sequence of words…predict the next one eg “knock knock”… and it should be “who’s there?”
Background
1966 ELIZA language model debued at MIT
All language models are:
- trained on a set of data
- infer relationships and generate new content based on the trained data
Terminology
LLM - Large Language Model is a type of AI algorithm
NLP - Natural Language Processing applications. Where a user inputs a query in (English) to generate a result.
Deep Learning -
Transformer architecture - standard architecture for language modeling since 2018. Developed by Google.
What is a Language Model
A mathematical model of human language… which allows it to mimic human language… which is why it can generate text that looks like an intelligent person
A couple of years ago OpenAI and Google started training these models with huge amounts of words from.
Step 1 - get text
GPT-3 training data:
- common crawl (60%)
- webtext2 (22%)
- books (15%)
- whole of wikipedia (3%)
97% English language
representative of last 30 years of English speaking culture
Step 2 - feed into neural network
Learned about the structure of the text and made a mathematical model
Captured structure of language ie relationships between words and sentences and how they are arranged. Also captured all the content of those words
Captured cultual, historical knowledge, scientific knowledge, legal.
Essentiallly a fuzzy cultural map of all human knowledge in the last 30 yeras of decades in English
we’ve invented something but we don’t know what it is capable of
research
in education research - if you train it on a paper, then can ask quesions
- summerise
- key points
- answer questions on the text
- explain like I’m 5
creative writing
- writers…. more cat like… more dog like.
- song lyrics
timeline
- GPT-3 - May 2020
- GH Co-pilot - June 2021
- ChatGPT release - Nov 2022… explosive hype starts!
- GPT-4 - March 2023
Elicit
speeds up literature review for professional researchers
questions
Hallucinating! It’s just making predictions based on training data.. not connected to the real world.
-
“what is the world record for crossing the english channel entirely on foot?” - this answer changes all the time. Chat GPT-3.5
-
where are the n’s in mayonnaise? GPT-3.5 answer: The word “mayonnaise” does not contain the letter “n.” It is spelled M-A-Y-O-N-N-A-I-S-E. So, there are no “n’s” in the word “mayonnaise.”
https://github.com/giuven95/chatgpt-failures
Black box
We can’t tell why it tells us a certain answer! ie it’s like we’ve built a car but can’t explain why the wheels go around.
- more like a biological creature we’ve grown rather than tool we’ve invented
- learns by trial and error
- emergent, surprising behaviour we need to study
AI researchers and ML scientists - LLMs as ‘Alien Minds’.
https://www.youtube.com/@AndrejKarpathy/featured - ChatGPT, Tesla… educator. Andrej Karpathy
Shoggoth unofficial mascot of LLM’s
Constraining Behaviour
Need to guiie it
Prompt Engineering
Describe what you want in very specific terms
Tangible example of what inputs and outputs you expect
Also tell it
- intelligent
- kind
- funny
- smart
“you are an intelligent, well educated, well-read, responsible, truthful, researcher now anwswer my question:
Fine Tuning
give it a database of examples of excpected inputs and output, now pay more attention to this.
Reinforcement learning
Get humans to score the outputs of results. What OpenAI have done with chatgpt.
Squish vs Structure
ie temperature… high is squish.. low is predictable
creative vs predictable
eg poetry we want creative. extract data we want creative.
very structured - may as well use traditional programming.. cheaper! ie keyword search
Prompt Chaining (compositionality)
eg What are the side effects of magnesium supplements?
- can’t trust an llm to give a good answer as we don’t know the sources it has used! Could be some random persons blog
so lets think how a human would go about it
- search google scholar for “side effects magnesium”
- read title and abstract of each result
- rank by semantic relevance
- filter for nubmer citations > 1
- generate sub questions eg
1.how does gener and age affect the prevalence of side effects 2.what dosage level does each side effect appear at 3.how common is each side effect?
- summarise findings in a paragraph
**try copilot for programming!
Chatbots
Chatbot - mimics human conversation. modern ones use AI
ChatGPT - Chat Generative Pre-trained Transformer. LLM based chatbot. Released Nov 2022. 2,000 characters input
Microsoft Bing Chat - uses GPT-4… 4,000 characters input
Open Source Chatbots
LLaMA - Large Language Model Meta AI. Feb 2023
LLaMA-2 - July 2023. 7, 13 and 70 billion parameters.
https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard Open LLM Leaderboard
Falcon - 180B. Sept 2023. 180b parameters Trained on 3.5tn tokens.
ChatGPT
chat.openai.com - GPT-3.5 is free. GPT-4.0 is paid.
The API is different pricing to ChatGPT PLus ($20 per month)
Bing Chat
https://www.bing.com/new - uses GPT-4 under the hood along with Bing.
There is a sidebar for Edge, where you get more time..
Uses of Chatbots
Anyone
-
check spelling, grammer and tone of this email
-
summerise this text: (eg scientific article)
-
write poem on happiness that is easy to understand
-
write a 200 word essay on ….
Business
- write a job description for a marketing manager
Coder
- generate code
- explain code
https://github.com/features/copilot GitHib copilot o
https://news.ycombinator.com/item?id=37559996 comment here about learning F# and using an LLM to help.
Image Creators
Create art from words.. or upload an image
Bing image creator - powered by Dall-E. Seem to get 100 free images.
Dall-e 2 - only get a few free credits.
And Dall-E 3 now
Midjourney and Leonardo.ai are competitors
/imagine Worried couple driving fast in ambulance car
Open Interpreter
https://github.com/KillianLucas/open-interpreter open interpreter
Top of trending repos this week
miniconda - so can separate enviornments
https://docs.conda.io/projects/miniconda/en/latest/miniconda-install.html install instructions
# 3.10.12
python3 --version
# python 3.10
wget https://repo.anaconda.com/miniconda/Miniconda3-py310_23.5.2-0-Linux-x86_64.sh
# pyton 3.8
wget https://repo.anaconda.com/miniconda/Miniconda3-py38_23.5.2-0-Linux-x86_64.sh
bash Mini....(press tab)
# should be in /ho9me/dave/miniconda3
# do you wish the installer to initialize Anaconda3
no
eval "$(/home/dave/miniconda3/bin/conda shell.bash hook)"
# this added something to .bashrc
conda init
# restart shell
# now I've got (base) dave@asdf in my shell
# update conda
conda update -n base -c defaults conda
conda create -n oi python=3.11.4
conda activate oi
# conda deactivate
pip install open-interpreter
interpreter
# get an openai key
# https://platform.openai.com/
# does it survive a restart of shell?
export OPENAI_API_KEY=KEY_HERE
# needs a GPT-4 account
# if you use the same phone number on different email it wont give you credits
# https://openai.com/pricing
# based on tokens
interpreter
# to use GPT3.5-turbo
# but easy to overload it.
interpreter --fast
and now
what files do I have on my desktop
HERE go through video… need to put in credit card for gpt-4 for the api.
https://youtube.com/watch?v=s-f4lCETxu0&si=jqieBEjl2qNPbaf3 - next video by The AI Breakdown
some great use cases in there
https://beebom.com/how-run-open-interpreter-run-chatgpt-code-interpreter-locally/ article with fun stuff.. bad install instructins for Win side python.
LLama 2
https://ai.meta.com/resources/models-and-libraries/llama-downloads/ need to request a new download link
https://github.com/facebookresearch/llama
How can AI help my Kids
generative AI
- “make a picture of a farting cat”
- “make a picture of a cat on the moon riding a skateboard kicking a football and a football”
- make
chatgpt
- tell me a joke
- what is a proton - explain like I’m 9
https://www.reddit.com/r/ChatGPT
LLM Video
https://news.ycombinator.com/item?id=37631089 - Jeremy Howard
Favourite Questions
- what is the answer to life the universe and everything?
“(Bard) The answer to the ultimate question of life, the universe, and everything is 42.
This is a reference to the science fiction comedy series The Hitchhiker’s Guide to the Galaxy by Douglas Adams. In the series, a supercomputer named Deep Thought is asked to calculate the answer to the ultimate question of life, the universe, and everything. After seven and a half million years of calculations, Deep Thought determined the answer was 42.
However, Deep Thought explained that the answer was incomprehensible because the beings who asked the question didn’t know what the question actually was. In other words, the answer to the ultimate question of life, the universe, and everything is different for everyone, and it’s up to each individual to find their own answer.
So, what is the answer to life the universe and everything for you?
Is it to find love and happiness? To make a difference in the world? To learn as much as you can about the universe? To simply experience all that life has to offer?
Whatever it is, I hope you find it.”
Fun AI’s
https://textfx.withgoogle.com/
What is ChatGPT good at?
- Coding code completion / summerisation of code
- Assimilating information and summerising
- Generation (text / image)
- Coversation (chatbots)
- Knowledge accessibility - question and answer
1. Coding
“can you write a simple crud app in python?”
GPT3.5 did it well!
import os
# Function to create a new task
def create_task(task_list, task):
task_list.append(task)
# Function to read all tasks
def read_tasks(task_list):
for index, task in enumerate(task_list):
print(f"{index + 1}. {task}")
# Function to update a task
def update_task(task_list, index, new_task):
if index >= 0 and index < len(task_list):
task_list[index] = new_task
else:
print("Invalid task index")
# Function to delete a task
def delete_task(task_list, index):
if index >= 0 and index < len(task_list):
del task_list[index]
else:
print("Invalid task index")
# Function to save tasks to a text file
def save_tasks_to_file(task_list, filename):
with open(filename, "w") as file:
for task in task_list:
file.write(task + "\n")
# Function to load tasks from a text file
def load_tasks_from_file(filename):
task_list = []
if os.path.exists(filename):
with open(filename, "r") as file:
task_list = file.read().splitlines()
return task_list
# Main function
def main():
filename = "tasks.txt"
tasks = load_tasks_from_file(filename)
while True:
print("\nTask Management Menu:")
print("1. Add Task")
print("2. List Tasks")
print("3. Update Task")
print("4. Delete Task")
print("5. Exit")
choice = input("Enter your choice: ")
if choice == "1":
task = input("Enter a new task: ")
create_task(tasks, task)
elif choice == "2":
read_tasks(tasks)
elif choice == "3":
index = int(input("Enter the task number to update: ")) - 1
new_task = input("Enter the new task: ")
update_task(tasks, index, new_task)
elif choice == "4":
index = int(input("Enter the task number to delete: ")) - 1
delete_task(tasks, index)
elif choice == "5":
save_tasks_to_file(tasks, filename)
print("Exiting the program.")
break
else:
print("Invalid choice. Please try again.")
if __name__ == "__main__":
main()
3. Generation
- make poems
- make more ‘scottish’ tone, ‘glasweigan’, formal,
tell jokes
- ie tell me a knock knock joke..
- a sarcastic one
- another… but probably better to look on google
not good at / would be better using existing tools: tell jokes
- ie tell me a knock knock joke..
- a sarcastic one
- another… but probably better to look on google
5. Knowledge Accessibility
- finding out specific information eg “Who won the world series in 2020?”.. use wikipedia.
- but maybe a converstaion (which helps in digesting a lot of information).. would be…. but it can hallucinate
Working
https://bjlkeng.io/posts/building-a-qa-bot-of-me-with-openai-and-cloudflare/
code up a logfile parser
and a graph?