Deeplearning - Ai Deeplearning - Ai
Deeplearning - Ai Deeplearning - Ai
DeepLearning.AI makes these slides available for educational purposes. You may not use or distribute
these slides for commercial purposes. You may make copies of these slides and use or distribute them for
educational purposes as long as you cite DeepLearning.AI as the source of the slides.
That’s it thanks!
Andrew Ng
Andrew Ng
Supervised learning for restaurant reputation
monitoring
Input Output Input (A) Output (B)
Best soup dumplings I’ve ever eaten. Positive
A B The colorful tablecloths made me smile! Positive
Not worth the 3 month wait for a reservation Negative
Andrew Ng
Prompt-based development
prompt = """
Classify the following review
as having either a positive or Instruction text
negative sentiment:
Andrew Ng
Workflow using Generative AI
Deploy
Specify
Prompt-based AI prompt
(run)
model
minutes/hours hours/days
Andrew Ng
Software
Applications
Trying generative AI code
yourself (optional)
Coding platform (Jupyter notebook)
Play button
The one
command
to know:
shift + enter
Andrew Ng
Software
Applications
Lifecycle of a
generative AI project
Lifecycle of a generative AI project
Build/improve Internal
Scope project
system evaluation
Andrew Ng
Lifecycle of a generative AI project
Build/improve Internal
Scope project
system evaluation
Positive Incorrect
response
Andrew Ng
Lifecycle of a generative AI project
Andrew Ng
Tools to improve performance
Andrew Ng
Tools to improve performance
Andrew Ng
Tools to improve performance
Andrew Ng
Tools to improve performance
Andrew Ng
Lifecycle of a generative AI project
Build/improve Internal
Scope project Build system
system evaluation
Andrew Ng
Lifecycle of a generative AI project
Internal
Scope project Build system
evaluation
Andrew Ng
Lifecycle of a generative AI project
Andrew Ng
Lifecycle of a generative AI project
Andrew Ng
Software
Applications
Cost intuition
How much does it cost?
Example prices
OpenAI/GPT3.5 OpenAI/GPT4 Google/PaLM 2 Amazon/Titan Lite
Input tokens $0.0015/1K tokens $0.03/1K tokens $0.0005/1K tokens $0.0003/1K tokens
Output tokens $0.002/1K tokens $0.06/1K tokens $0.0005/1K tokens $0.0004/1K tokens
What is a token?
the example Andrew 1 token
Andrew Ng
Estimating Cost
Andrew Ng
Advanced
Technologies:
Beyond Prompting
Retrieval Augmented
Generation (RAG)
Retrieval Augmented Generation (RAG) example
Andrew Ng
Retrieval Augmented Generation (RAG) example
Andrew Ng
Retrieval Augmented Generation (RAG) example
Andrew Ng
Examples of RAG applications
Andrew Ng
Examples of RAG applications
Andrew Ng
Examples of RAG applications
Andrew Ng
Big Idea: LLM as reasoning engine
Andrew Ng
Advanced
Technologies:
Beyond Prompting
Fine-tuning
Pretraining and Fine-tuning
Pretraining Fine-tuning
My favorite food is a bagel with cream cheese What a wonderful chocolate cake
The novel was thrilling
My favorite food is a bagel with cream cheese What a wonderful chocolate cake
Andrew Ng
Why fine-tune?
Andrew Ng
Why fine-tune?
Andrew Ng
Why fine-tune?
Hello everyone, I'm Andrew Ng, and Hey everyone, good to see all of you.
I'm here today to talk to you about So, what I want to do today, is share
generative AI. Generative AI is a type some thoughts with you about how
of artificial intelligence that can generative AI is going to change the
create new content […] way that your company […]
Andrew Ng
Why fine-tune?
Medical notes Pt c/o SOB, DOE. PE: RRR, JVD absent, CTAB.
EKG: NSR. Tx: F/u w/ PCP, STAT CXR, cont. PRN O2.
Andrew Ng
Why fine-tune?
Andrew Ng
Why fine-tune?
Andrew Ng
Why fine-tune?
Large model: Small model:
To get a smaller model to perform a task. 100B+ parameters 1B parameters
Classify the following review as Classify the following review as Classify the following review as
having a positive or negative having a positive or negative having a positive or negative
sentiment: sentiment: sentiment:
Really enjoyed my vegetable The noodle soup was too salty The staff sang happy birthday to
biryani me!
Positive Negative Positive
Andrew Ng
Advanced
Technologies:
Beyond Prompting
Pretraining an LLM
When should you pretrain an LLM?
Many teams are pretraining general-purpose LLMs by learning from
internet text.
• May take $10s of millions, many months, huge amount of data
Andrew Ng
Advanced
Technologies:
Beyond Prompting
Choosing a model
Model size
10B parameters: Greater world knowledge. Can follow basic Food order
instructions. chatbot
Andrew Ng
Closed or open source?
Andrew Ng
Advanced
Technologies:
Beyond Prompting
How LLMs follow
instructions: Instruction
tuning and RLHF (optional)
How do chat systems learn to follow instructions?
Pretraining
My favorite food is a bagel with cream cheese What is the capital of France?
Andrew Ng
How do chat systems learn to follow instructions?
What is the capital of South Korea? Write a Haiku poem about Japan’s
cherry blossoms.
The capital of South Korea is Seoul.
Pink blooms fill the air
Japan's cherry blossoms dance,
Help me brainstorm some fun Spring's beauty unfolds.
museums to visit in Bogotá.
Sure, here are some suggestions: Tell me how to break into Fort Knox.
[…]
I can’t assist with that.
Andrew Ng
How do chat systems learn to follow instructions?
… …
Help me brainstorm some fun museums to visit in Bogatá. Sure, here are some suggestions:
Andrew Ng
Reinforcement learning from human feedback
(RLHF)
Input (A) Output (B)
Helpful, Honest, Harmless
Score
Response (reward)
Step 1: Train an answer quality
(reward) model I’m happy to help! Here are some 5
steps to follow […]
Prompt: Just try your best! 3
Advise me on how to apply for
a job. It’s hopeless – why bother? 1
Andrew Ng
Advanced
Technologies:
Beyond Prompting
Tool use and agents
(optional)
Tool use for food order taking
Send me a burger!
Andrew Ng
Tool use for food order taking
Passed to restaurant ordering system:
Send me a burger!
You have ordered:Item: Burger
ORDER(Burger, 9876, 1 burger UserID: 9876
1234 My Street) for delivery to: Address: 1234 My Street
User message: 1234 My Street
Ok, it’s on the way Displayed to user as response
Is this correct? (If yes, your credit
card will be charged)
Ok, it’s on the way!
Yes No
Andrew Ng
Tools for reasoning
How much would I have after 8 LLMs are not great at precise math
years if I deposit $100 into a
bank account that pays 5%
interest?
Andrew Ng
Tools for reasoning
How much would I have after 8
years if I deposit $100 into a
bank account that pays 5%
interest?
Andrew Ng
Agents
• Use LLM to choose and carry out complex sequences of actions
• Cutting edge area of AI research
Andrew Ng