A short course on deeplearning.ai, taught by Andrew Ng and Isa Fulford.

ChatGPT Prompt Engineering for Developers - DeepLearning.AI



Two types of LLMs (Large Language Models):

In this course, we focus on Instruction Tuned LLM.

<aside> ☝ Sometimes, if LLM doesn’t work, it’s just because your instruction isn’t clear enough!


Guidelines for Prompting

👉 OpenAI API 📙 Notebook.

Two principles:

Principle 1 - write clear and specific instructions

  1. Tactic 1. Use delimiters to clearly indicate distinct parts of the input: """, `````, ---, <>, <tag></tag> (xml tags)

    prompt = f"""
    Summarize the text delimited by triple backticks \\ 
    into a single sentence.
  2. Tactic 2. Ask for a structured output: JSON, HTML

    prompt = f"""
    Generate a list of three made-up book titles along with their authors and genres. 
    Provide them in JSON format with the following keys: 
    book_id, title, author, genre.
  3. Tactic 3. Ask the model to check whether conditions are satisfied → check assumptions required to do the task → how the model should handle the edge case to avoid unexpected errors or result.

    prompt = f"""
    You will be provided with text delimited by triple quotes. 
    If it contains a sequence of instructions, re-write those instructions in 
    the following format:
    Step 1 - ...
    Step 2 - …
    Step N - …
    If the text does not contain a sequence of instructions, then simply write 
    \\"No steps provided.\\"