A Couple Current Examples of AI Around Us
A Couple Current Examples of AI Around Us
- "Google, I need directions from old Fort Laramie to Old Faithful Inn in Yellowstone"
A Couple Current Examples of AI Around Us
- "Google, I need directions from old Fort Laramie to Old Faithful Inn in Yellowstone"
A Couple Current Examples of AI Around Us
- "Google, I need directions from old Fort Laramie to Old Faithful Inn in Yellowstone"
- Computer games across many genres.
A Couple Current Examples of AI Around Us
- "Google, I need directions from old Fort Laramie to Old Faithful Inn in Yellowstone"
- Computer games across many genres.
A Couple Current Examples of AI Around Us
- "Google, I need directions from old Fort Laramie to Old Faithful Inn in Yellowstone"
- Computer games across many genres.
Putting Some AI Into Your Code
Kirk Haines
Principal Developer Relations Engineer
khaines@newrelic.com
https://twitch.tv/wyhaines
@wyhaines
What is AI?
What is AI?
Artificial intelligence (AI) is the ability of a computer or a robot controlled by a computer to do tasks that are usually done by humans because they require human intelligence and discernment.
-- artificial intelligence | Definition, Examples, and Applications | Britannica
What is AI?
i.e. Artificial intelligence is when a computer or robot can do something that usually only humans can do.
* This simple definition was created by asking an AI to summarize the previous definition in a way that a second grade student could understand it.
AI Is Becoming More Accessible
AI Is Becoming More Accessible
AI Is Becoming More Accessible
Google's BERT (Bidirectional Encoder Representations from Transformers)
BERT powers almost every single English based query done on Google Search, the company said during its virtual Search on 2020 event Thursday.
You can download BERT and use it yourself:
AI Is Becoming More Accessible
Generative Pre-trained Transformer 2 -- GPT-2, from OpenAI
- General purpose
- Answers questions
- Summarizes text
- Generates new content
- Even has translation abilities.
- ...but wasn't specifically trained to do any of these things.
- Trained on 1.5 billion terms
- Modified MIT open source available:
https://github.com/openai/gpt-2
Bigger And More Capable
GPT-3
Bigger And More Capable
GPT-3
- Trained on 175 Billion terms.
Bigger And More Capable
GPT-3
- Trained on 175 Billion terms.
- Microsoft has an exclusive license.
Bigger And More Capable
GPT-3
- Trained on 175 Billion terms.
- Microsoft has an exclusive license.
- Other access is via a for-pay API service.
Bigger And More Capable
GPT-3
- Trained on 175 Billion terms.
- Microsoft has an exclusive license.
- Other access is via a for-pay API service.
- General purpose - Just tell it what you want in plain language, and optionally provide a few examples.
GPT-3 -- Examples!
GPT-3 -- Examples!
These are all real. The code for them is available at:
GPT-3 -- Examples!
Factual Answers to Questions
The prompt is to just tell it what it is, and show a few examples of question/answer:
I am a highly intelligent question answering bot. If you ask me a question that is rooted in truth, I will give you the answer. If you ask me a question that is nonsense, trickery, or has no clear answer, I will respond with "Unknown".
Q: What is human life expectancy in the United States?
A: Human life expectancy in the United States is 78 years.
Q: Who was president of the United States in 1955?
A: Dwight D. Eisenhower was president of the United States in 1955.
Q: Which party did he belong to?
A: He belonged to the Republican Party.
GPT-3 -- Examples!
Factual Answers to Questions
My questions, and GPT-3's answers:
Q: What does the body use LDL for?
A: LDL is used by the body to transport cholesterol.
Q: What is an earthquake?
A: An earthquake is a sudden, rapid shaking of the earth.
Q: Who was the lead actor in the movie Gladiator?
A: Russell Crowe was the lead actor in the movie Gladiator.
GPT-3 -- Examples!
Recipe Inventor
The prompt is simple set of instructions, and a list of ingredients:
Write a recipe based on these ingredients and instructions:
Simple Keto Breakfast
Ingredients:
ground beef
2 large eggs
cotija cheese
tabasco sauce
frozen slices bell peppers and onions
Directions:
GPT-3 -- Examples!
Recipe Inventor
The result is a recipe:
Write a recipe based on these ingredients and instructions:
Simple Keto Breakfast
Ingredients:
ground beef
2 large eggs
cotija cheese
tabasco sauce
frozen slices bell peppers and onions
Directions:
1. Cook ground beef in a pan until browned.
2. Add frozen bell peppers and onions.
3. Add eggs and scramble.
4. Add cotija cheese and tabasco sauce.
Ground beef, 2 large eggs, cotija cheese, tabasco sauce, frozen bell peppers and onions.
GPT-3 -- Examples!
Summarize and Simplify
Frame the task in a way that sets the expectation for the desired results:
My second grader asked me what this passage means:
"""
Generative Pre-trained Transformer 2 (GPT-2) is an open-source artificial intelligence created by OpenAI in February 2019. GPT-2 translates text, answers questions, summarizes passages, and generates text output on a level that, while sometimes indistinguishable from that of humans, can become repetitive or nonsensical when generating long passages. It is a general-purpose learner; it was not specifically trained to do any of these tasks, and its ability to perform them is an extension of its general ability to accurately synthesize the next item in an arbitrary sequence. GPT-2 was created as a "direct scale-up" of OpenAI's 2018 GPT model, with a ten-fold increase in both its parameter count and the size of its training dataset.
"""
I rephrased it for them, in plain language that a second grader can understand:
"""
GPT-3 -- Examples!
Summarize and Simplify
And get back a summary that a second grader can understand:
My second grader asked me what this passage means: """ ( ... deleted for space in the slide ... ) """ I rephrased it for them, in plain language that a second grader can understand: """ GPT-2 is a computer program that can translate from one language to another, answer questions about what it read, and summarize passages. It was created by taking a computer program that could do those things, and then adding many more parts to it. This made it better at doing them.
GPT-3 -- Examples!
Data Extraction from Unstructured Data
Parsing unstructured data is hard. Extracting unstructured addresses is very hard. So, let's give a few examples, some of which have missing data, to tell it what we want:
FOR RENT: Nicest Country Apartments, Bear Creek. 5318 Road 68F. Furnished, Utilities, TV, WiFi, Broker owned.
harrisrealestate.com
307-555-6480
Please make a table summarizing the contact information. If information is missing, mark it NA:
| address | website | telephone | rent |
| 5318 Road 68F, Bear Creek | harrisrealestate.com | 307-555-6480 | NA |
"""
GPT-3 -- Examples!
Data Extraction from Unstructured Data
More examples...
2 Bedroom, 1 bath apartment, $725 per month plus deposit, utilities included. Call 307-555-5913 for application and more info.
Please make a table summarizing the contact information. If information is missing, mark it NA: | address | website | telephone | rent | | NA | NA | 307-555-5913 | $725 | """
GPT-3 -- Examples!
Data Extraction from Unstructured Data
More examples...
Quiet neighborhood. Two Bedrooms, W/D, no smoking, no pets. $550/mo, $550 deposit, you pay utilities. www.ztownp.com 555-7273
Please make a table summarizing the contact information. If information is missing, mark it NA: | address | website | telephone | rent | | NA | www.ztownp.com | 555-7273 | $550 | """
GPT-3 -- Examples!
Data Extraction from Unstructured Data
Three is enough. Let's see if it can pull the data itself.
Clean 3 bedroom, 2 bath house on 5 acres. Horses allowed. 1351 Powerplant Road, Longle. $1050 per month, plus deposit and utilities. 307-555-5555
Please make a table summarizing the contact information. If information is missing, mark it NA: | address | website | telephone | rent |
GPT-3 -- Examples!
Data Extraction from Unstructured Data
Three is enough. Let's see if it can pull the data itself.
Clean 3 bedroom, 2 bath house on 5 acres. Horses allowed. 1351 Powerplant Road, Longle. $1050 per month, plus deposit and utilities. 307-555-5555 Please make a table summarizing the contact information. If information is missing, mark it NA: | address | website | telephone | rent | | 1351 Powerplant Road, Longle | NA | 307-555-5555 | $1050 |
GPT-3 -- Examples!
Data Extraction from Unstructured Data
Three is enough. Let's see if it can pull the data itself.
FOR SALE OR RENT TO BUY: Cozy 1950s family home with modern updates. Wood floors throughout. 4 bedrooms on 2 levels, with 3 bathrooms. $1400/mo. OWC with 30% down on $245000. 307-555-5432
Please make a table summarizing the contact information. If information is missing, mark it NA:
| address | website | telephone | rent |
GPT-3 -- Examples!
Data Extraction from Unstructured Data
Three is enough. Let's see if it can pull the data itself.
FOR SALE OR RENT TO BUY: Cozy 1950s family home with modern updates. Wood floors throughout. 4 bedrooms on 2 levels, with 3 bathrooms. $1400/mo. OWC with 30% down on $245000. 307-555-5432
Please make a table summarizing the contact information. If information is missing, mark it NA:
| address | website | telephone | rent |
| NA | NA | 307-555-5432 | $1400 |
GPT-3 -- Examples!
Writing Stories
Start with a simple prompt, and a few sentences:
You are a fantasy novel author. You are writing a short story:
"""
Skant grunted softly and adjusted his grip on the game sledge that he pulled. The half moon was low in the sky tonight, and the hunt had lasted longer than he had hoped, but Skant had no problem seeing the trail that he followed as it slipped between trees and along the contours of the flattening ground, towards his home. His ancestry cursed him as much as it blessed him, but in this place, not so far from where his ancient ancestors once called home, it blessed him. He would be there soon, and tomorrow he would cut and hang the meat to dry.
GPT-3 -- Examples!
Writing Stories
Let GPT-3 do the rest!
Skant was not alone on the hunt. His sister, Shan, walked behind him, her large ears flicking from side to side and her eyes taking in every detail of the forest that they passed through. Behind Shan, silent and unseen, was a third member of their pack, a small brown-furred creature with wide ears and the eyes of a hunter. The creature moved silently through the forest, and it could smell the creatures that Skant could not. It was an invaluable ally, one that Skant had known for almost half his life. He had raised it from a cub, and in turn, it had saved his life more than once.
Skant was looking forward to a warm meal and a good night's sleep. Tomorrow he would be cutting wood for the fire, and then he would be off to trade with the other clans. The hunt had gone well, and the dried meat would fetch a good price. Skant had hunted for this clan for all of his adult life. He was a good hunter, and the clan had prospered under his leadership and his, and SHan's, guidance.
"Wait, Shan." Skant stopped his sledge and put a hand out to stop Shan. "Something is wrong."
"What is it?" Shan asked, her voice low and her eyes wide.
"Something is not right," Skant said, his nose twitching as he tried to make sense of the scents he was picking up.
GPT-3 -- Examples!
Writing Stories
"It is nothing." Shan said, "We have had a good hunt, and we are almost home. Let's go back to the camp."
"Something is not right," Skan said, "My ears tell me that." Skant stopped and pulled the sledge up. He looked at his sister and said, "Something is not right."
Skant was not afraid, but he knew that there was something in the forest that should not be there. He looked at Shan, "Wait here."
"No." Shan said.
"Shan," Skant said, "I need you to stay here and guard the meat. I will go and get the cub."
"No," Shan said again, "This is my hunt. It is my meat, and I will take it home. We will go together."
"There is something in the forest," Skant said, "I smell it. I cannot see it, but I can smell it. I must go and find it."
"Then I will go with you." Shan said, "We will find it together."
GPT-3 -- How To Do It Yourself
GPT-3 -- How To Do It Yourself
- Join the waitlist for API access: https://openai.com/blog/openai-api/
GPT-3 -- How To Do It Yourself
- Join the waitlist for API access: https://openai.com/blog/openai-api/
- Get accepted for live access to the API.
GPT-3 -- How To Do It Yourself
- Join the waitlist for API access: https://openai.com/blog/openai-api/
- Get accepted for live access to the API.
- Start writing code! Many API client libraries are available:
GPT-3 -- How To Do It Yourself
- Join the waitlist for API access: https://openai.com/blog/openai-api/
- Get accepted for live access to the API.
- Start writing code! Many API client libraries are available:
beta.openai.com/docs/developer-quickstart/making-requests
GPT-3 -- How To Do It Yourself
- Join the waitlist for API access: https://openai.com/blog/openai-api/
- Start writing code! Many API client libraries are available:
beta.openai.com/docs/developer-quickstart/making-requests- Python
- C# / .NET
- Crystal (https://github.com/wyhaines/openai-crystal for recently maintains fork)
- Dart
- Go
- Java
- Javascript
- Ruby
- Unity
GPT-3 -- How To Do It Yourself
Experiment!!!
GPT-3 -- How To Do It Yourself
Experiment!!!
Many tools are widely available, and we are still discovering their true capabilities and limitations. The applications for these technologies are expansive.
Thank You
Resources linked to in this talk:
https://github.com/google-research/bert
https://github.com/openai/gpt-2
https://github.com/wyhaines/futurestack-ai-talk-examples
https://openai.com/blog/openai-api/
beta.openai.com/docs/developer-quickstart/making-requests
https://github.com/wyhaines/openai-crystal
Futurestack : Putting Some AI Into Your Code
By wyhaines
Futurestack : Putting Some AI Into Your Code
Crystal is a very fast statically typed language, with type inference, implemented on LLVM, but with a very Ruby-like syntax that makes it easy for Ruby developers to pick it up and become productive with it quite quickly.
- 829