ANDREW NG · DEEPLEARNING.AI · COURSERA Generative AI for Everyone 3 WEEKS · MARCH 2024 · ANDREW NG

Course Notes · Generative AI · March 2024

Generative AI for Everyone

My notes from Andrew Ng's Coursera course — a non-technical deep dive into what generative AI is, how it works, where it fits in the AI landscape, and what it means for business and society.

Generative AI LLMs Business Coursera · Andrew Ng · March 16, 2024 · 3 weeks
Week 1

01 What is Generative AI?

Generative AI is a class of AI systems that can produce high-quality content — specifically text, images, and audio. Examples include ChatGPT, Bard, and BingChat.

$4.4T
Added annually to economy
7%
Global GDP rise in 10 yrs
80%
US workers with tasks impacted

AI has been mentioned on 38% of S&P 500 earnings calls as of early 2024 — the most mentions in tech, followed by energy. Generative AI as a developer tool will be even more impactful in the long term. AI is already pervasive: Google and Bing for web search, fraud detection in credit card payments, recommender systems on Amazon and Netflix.

AI is a general purpose technology — like electricity or the internet. Asking "what is AI useful for?" is like asking what electricity is good for. The answer is: everything.

02 How Generative AI Works

Where it fits in the AI landscape

Think of AI as a toolbox. Supervised learning is the most important existing tool. Generative AI is the newest addition. The toolbox also contains unsupervised learning and reinforcement learning.

AI Supervised learning Generative AI ✦ Unsupervised learning RL newest tool

Supervised Learning

Given an input (A), the model learns to predict an output (B). A decade of large-scale supervised learning laid the foundation for generative AI. Early models were small; researchers discovered that larger models with more data continue to improve, which unlocked LLMs.

Input (A)Output (B)Application
EmailSpam? (0/1)Spam filtering
Ad, user infoClick? (0/1)Online advertising
X-ray imageDiagnosisHealthcare
Audio recordingText transcriptSpeech recognition
Restaurant reviewsSentiment (pos/neg)Reputation monitoring

Large Language Models (LLMs)

LLMs are built by using supervised learning to repeatedly predict the next word. Train on hundreds of billions of words and you get ChatGPT.

My favourite food is a bagel with cream cheese My favourite food is a → bagel My favourite food is a bagel→ with My favourite food is a bagel with→ cream My favourite food is a bagel with cream→ cheese Input (A) → Output (B): next word prediction

LLM as a Thought Partner

LLMs give us new ways to find information — like having a knowledgeable collaborator always on hand. They can brainstorm, rewrite, summarise, and reason. But they sometimes hallucinate — making up plausible-sounding but incorrect facts. Use trustworthy websites for high-stakes topics (health, legal); LLMs are better where less structured web information exists.

03 Generative AI Applications

GenAI tasks fall into three broad modes. Across all of them, the more context you give, the better the output.

✍️
Writing
  • Brainstorm product names or campaign ideas
  • Write press releases
  • Translation
  • Generate specific output with context
📖
Reading
  • Proof reading
  • Summarising long articles or call centre conversations
  • Customer email analysis and routing
  • Reputation monitoring over time
💬
Chatting
  • Specialised chatbots (travel, cooking, IT support)
  • Human-in-the-loop triage
  • Deploy internal-facing first, monitor before going public
Two types of LLM applications: Web apps (ChatGPT, BingChat — direct human interaction) and LLM-based software (identifying or processing text inside larger systems, like email classification pipelines).

04 What LLMs Can and Cannot Do

A useful mental model: think of an LLM as a fresh college graduate with lots of general knowledge but no company-specific context, no internet access, and no memory of past sessions. You get a different fresh graduate every conversation.

Knowledge Cutoff

The model's knowledge is frozen at training time — it won't have details on recent events.

Hallucinations

Ask it for Shakespeare quotes about Beyoncé and it will confidently invent them. Always verify factual claims.

Context Length

LLMs accept input + output of a limited combined length (the context window). Very long documents may not fit.

Structured Data

LLMs work best with unstructured data (text, images, audio). For tabular data, supervised learning is usually better.

Bias & Toxicity

LLMs are trained on internet data, which carries societal biases. The model learns and can reproduce those biases.

05 Tips for Prompting

1. Be detailed and specific

Give sufficient context. Describe the task in detail. Vague prompt → vague output.

Initial prompt

Help me write an email asking to be assigned to the legal documents project

With context + detail

Help me write an email asking to be assigned to the legal documents project. I'm applying for a job on the legal documents project, which will check legal documents using LLMs. I have ample experience prompting LLMs to generate accurate text in a professional tone. Write a paragraph explaining why my background makes me a strong candidate.

2. Guide the model to think through its answer

Add explicit steps to the prompt so the model follows a structured reasoning path.

Final prompt

Brainstorm 5 names for a new cat toy Step 1: Come up with 5 fun, joyful words that relate to cats. Step 2: For each word, come up with a rhyming name for a toy. Step 3: For each toy name, add a fun, relevant emoji.

3. Experiment and iterate

  • There are no perfect prompts — adjust and improve until results are satisfactory
  • Don't overthink the initial prompt; just start
  • Be careful with confidential information
  • Always double-check before fully trusting the output

06 Image Generation — Diffusion Models

Image generation is mostly done via Diffusion Models — a supervised learning approach at heart. Training: take a clean image + caption, progressively add noise across steps. The model learns to predict a less noisy image from a noisier one. Generation works in reverse: start from pure noise + a text prompt and iteratively denoise until a clean image appears (typically ~100 steps).

TRAINING: add noise → GENERATION: remove noise ← 🍎 Clean Light noise More noise Pure noise "red apple" + noisy image → less noisy
Week 2

07 Using GenAI in Software Applications

Before GenAI, building a reading, writing, or chatbot app required months of ML engineering. Now a working prototype can be built in hours or days. Example — a reputation monitoring system:

ApproachStepsTime
Traditional MLLabel data → train model → cloud deploymentMonths
Prompt-basedWrite a prompt classifying review sentiment → call LLM APIHours / days

08 Lifecycle of a Generative AI Project

Building GenAI applications is a highly empirical, iterative process — not a straight line from idea to deployment.

1. Scope
Decide what the software can do
2. Build
Initial prototype in 1–2 days
3. Evaluate
Catch counterintuitive cases, improve
4. Deploy
Monitor; loop back to step 2 or 3

09 Retrieval Augmented Generation (RAG)

RAG lets an LLM answer questions using specific documents you provide at query time, rather than relying purely on its training knowledge. Think of the LLM as a reasoning engine, not a knowledge store.

Question Search Docs New Prompt Answer Retrieved text injected into prompt → LLM reasons over it

RAG Applications

  • Chat with PDFs — PDF.ai, ChatPDF, AskYourPDF, docAnalyzer.ai
  • Article Q&A — CourseraCoach, Snapchat AI, Hubspot chatbot
  • New web search forms — BingChat, You.com

10 Fine-tuning, Pretraining & Model Choices

Fine-tuning

Useful when the context is bigger than the input context length, or when the LLM needs domain-specific language (medical notes, legal, financial documents). Allows a smaller model to match a larger one on a specific task — lower cost, lower latency, runs on-device.

Pretraining

  • Expensive — requires $10M+, many months, and vast data
  • When in doubt: don't do it. Should be a last resort.
  • BloombergGPT was trained on 50B+ parameters of proprietary Bloomberg data — outperforms open-source GPTs on financial text

Model Size

1B
Pattern matching and basic world knowledge
e.g. Restaurant review sentiment classifier
10B
Greater world knowledge, can follow basic instructions
e.g. Food order chatbot
100B+
Rich world knowledge, complex reasoning
e.g. Brainstorming partner, complex Q&A

Closed vs Open Source

Closed SourceOpen Source
AccessVia cloud API — easy to integrateFull control, run on own hardware
PowerGenerally more powerful/largeRapidly catching up
CostRelatively inexpensive (contributed by large cos.)Infra costs shift to you
RiskVendor lock-in — switching means re-running all promptsFull data and privacy control

Instruction Fine-tuning & RLHF

A base LLM predicts the next word — if you ask "What is the capital of France?" it might respond with another question (the most common continuation in training data). Instruction fine-tuning trains it on Q&A pairs to follow instructions instead. RLHF (Reinforcement Learning with Human Feedback) goes further: train a reward model on human preference scores, then tune the LLM to generate responses the reward model rates highly. Companies use RLHF to make LLMs Helpful, Honest, and Harmless (the 3 Hs).

Tool Use & Agents

  • Tools — LLMs can call external functions (place an order, run a calculation). LLMs are bad at precise math; a calculator tool solves this by letting the model offload computation and receive the result
  • Agents — use LLMs to carry out complex sequences of actions autonomously. Cutting-edge research area, evolving rapidly

11 Cost Intuition

Pricing is based on input + output tokens. Output tokens are generally more expensive. A token is roughly ¾ of a word — 300 words ≈ 400 tokens. Common short words ("the", "a") count as 1 token; longer words split ("program" + "ming").

Back-of-envelope: Keeping an adult occupied for 1 hour (250 words/min reading speed) = 15,000 output words + 15,000 prompt words = 30,000 words = ~40,000 tokens. At $0.002/1K tokens → $0.08 total. Genuinely inexpensive at scale.
Week 3

12 Generative AI & Business

Day-to-day uses

  • Writing assistant & thought partner — drafting, editing, ideating
  • Marketing — brainstorming email campaigns, ad copy
  • Recruiting — summarising candidate reviews in 50 words or less
  • Programming — writing Python, debugging, documentation

Task Analysis Framework

AI doesn't automate jobs — it automates tasks. Most jobs are a collection of many tasks. The framework: list the tasks in a role → assess each for GenAI potential along two dimensions:

Technical FeasibilityBusiness Value
Can AI do it? At what cost?How much time is spent on this task?
Think: fresh grad following prompt instructionsDoes doing it faster/cheaper create real value?
If unsure, try prompting an LLM to test itDoes doing this more consistently unlock new revenue?
An ML engineer can assess RAG/fine-tuning feasibilityLook beyond cost savings — workflow expansion matters

Augmentation vs Automation

  • Augmentation — AI helps a human do the task faster (human-in-the-loop)
  • Automation — AI performs the task autonomously once trust is established

Job impacts across roles

  • Programmer — writing code and documentation: high potential. Reviewing others' code, gathering requirements: lower
  • Lawyer — drafting and reviewing documents, interpreting regulations: high potential. Negotiating, reviewing evidence: lower
  • Landscaper — most tasks: low potential. Physical roles remain less impacted than knowledge roles
Insight: Historically, automation hit low-wage jobs hardest. GenAI reverses this — higher-wage knowledge workers are now most exposed. Sales, marketing, software engineering, and customer operations will be most impacted.

13 Teams to Build GenAI Software

RoleResponsibility
Software EngineerWrites the app; ideally knows LLM basics
ML EngineerImplements the AI system; familiar with prompting, RAG, fine-tuning
Product ManagerIdentifies and scopes the project
Prompt EngineerUsually not a standalone role — typically an ML engineer with extra skills
Data EngineerOrganises data, ensures data quality (larger teams)
Data ScientistAnalyses data and guides project/business decisions (larger teams)

A one-person team can be a software engineer with prompting know-how, or an ML engineer. A two-person team: ML engineer + software engineer. Many configurations work — start lean and scale the team as the product complexity grows.

14 Generative AI & Society

Concerns about AI

  1. 1
    Will AI amplify human biases? Yes, it can reproduce biases in training data. Mitigations: fine-tuning with curated data and RLHF to train models on an unbiased reward model.
  2. 2
    Who loses their job? Geoff Hinton predicted in 2016 that radiologists would be replaced in 5 years. A decade later, not one has lost their job — because radiologists perform 30+ tasks and X-ray interpretation is just one. The correct framing: "AI won't replace radiologists. Radiologists who use AI will replace radiologists that don't." — Curtis Langlotz, Stanford.
  3. 3
    Human extinction? Arguments are not concrete. Perfect control isn't needed for technology to be valuable and safe — we can't control turbulence on aeroplanes, but we fly. AI will also be a key tool in solving real risks: climate change, pandemics.

Artificial General Intelligence (AGI)

General-purpose AI ≠ Artificial General Intelligence. AGI by definition can do any intellectual task a human can — drive a car after 20 hours of practice, complete a PhD thesis in 5 years. Though AI is powerful and better than humans at specific tasks, expecting AGI-level performance is an extremely high bar and not where we are today.

Responsible AI

⚖️
Fairness
Ensure AI doesn't perpetuate or amplify biases
🔍
Transparency
Make AI decisions understandable to those affected
🔒
Privacy
Protect user data and confidentiality
🛡️
Security
Safeguard systems from malicious attacks
🌱
Ethical Use
Deploy AI only for beneficial purposes
🤝
Diverse Teams
Include perspectives from all stakeholders

15 Building a More Intelligent World

Intelligence is the power to apply knowledge and skills to make good decisions. Human intelligence is expensive — education, training, time. Artificial intelligence is cheap. AI has the potential to give every individual the ability to access intelligence at low cost.

AI is the new electricity — with the potential to revolutionize all industries and all corners of human life. The fear of AI today is similar to the fear of electricity when it was new. Today, nobody would give up light, heat, and refrigeration for fear of electrocution.

— Andrew Ng

Looking beyond AI, the world faces climate change, pandemics, and war. Solving them will require all the intelligence we can master — including artificial intelligence.