Lesson 2: Basics of Prompts

What is a Prompt?

A prompt is an input given to a machine-learning model to generate a desired output. In natural language processing (NLP), prompts are typically sentences or phrases that instruct the model on what kind of text to generate. Prompts can also be used in other domains, such as generating images, code, or even music.

Types of Prompts


  1. Text Prompts:

    • Used to generate text based on a given input.

    • Example: "Write a story about a dragon who finds a treasure."


  1. Image Prompts:

    • Used to generate images based on a descriptive text input.

    • Example: "Create an image of a sunset over a mountain range."


  1. Code Prompts:

    • Used to generate programming code based on a described task.

    • Example: "Write a Python function to calculate the factorial of a number."


  1. Audio Prompts:

    • Used to generate audio outputs like music or speech from text descriptions.

    • Example: "Generate a calm, soothing melody for relaxation."


  1. Multimodal Prompts:

    • Combine different types of inputs and outputs, like text to image, image to text, etc.

    • Example: "Describe this image of a beach scene in a detailed paragraph."

Simple Prompt Examples and Exercises


  1. Text Prompt Examples:


  • Simple Prompt: "Tell a joke about computers."

    • Exercise: Write a prompt to generate a short poem about the seasons.

  • Complex Prompt: "Explain the concept of black holes in simple terms."

    • Exercise: Create a prompt that asks for a summary of the book "1984" by George Orwell.


  1. Image Prompt Examples:


  • Simple Prompt: "Draw a picture of a cat wearing a hat."

    • Exercise: Write a prompt to generate an image of a futuristic cityscape.

  • Complex Prompt: "Create an image of a forest with magical creatures."

    • Exercise: Design a prompt for an illustration of an ancient castle on a cliff.


  1. Code Prompt Examples:


  • Simple Prompt: "Write a Python script to reverse a string."

    • Exercise: Develop a prompt to generate a JavaScript function that sorts an array of numbers.

  • Complex Prompt: "Create a Python program that simulates a basic calculator with add, subtract, multiply, and divide functions."

    • Exercise: Formulate a prompt to write a SQL query that retrieves all employees with a salary greater than $50,000.


  1. Audio Prompt Examples:


  • Simple Prompt: "Generate a 10-second sound of ocean waves."

    • Exercise: Write a prompt to create a brief upbeat tune for a podcast intro.

  • Complex Prompt: "Produce a 30-second instrumental piece in the style of classical music."

    • Exercise: Craft a prompt to generate a voice narration for a short story about space exploration.


  1. Multimodal Prompt Examples:


  • Simple Prompt: "Describe this image of a dog playing in a park."

    • Exercise: Write a prompt to generate a picture based on the text description: 'A bustling marketplace in a medieval town.'

  • Complex Prompt: "Generate a detailed caption for this photograph of a bustling city street at night."

    • Exercise: Create a prompt to turn a short poem into an illustrative image.


__________________________________________________

Exercises


  1. Text Prompt Exercise:


  • Write a prompt to generate a news article about a recent scientific discovery.

  • Example: "Write a news article about the discovery of a new planet in our solar system."


  1. Image Prompt Exercise:


  • Develop a prompt to create an image of a fantasy world with dragons and knights.

  • Example: "Generate an image of a knight riding a dragon in a mystical forest."


  1. Code Prompt Exercise:


  • Formulate a prompt to generate a Python script that sorts a list of names alphabetically.

  • Example: "Write a Python function to sort a list of names in alphabetical order."


  1. Audio Prompt Exercise:


  • Write a prompt to create a sound effect for a spaceship taking off.

  • Example: "Generate a sound effect of a rocket launching into space."


  1. Multimodal Prompt Exercise:


  • Craft a prompt to generate a descriptive paragraph based on an image of a serene lake at sunrise.

  • Example: "Describe this image of a calm lake with the sun rising in the background."