Prompt Engineering

  1. Zero Shot classification

    Question 1 of 5

    • Write a function get_sector(company_name) that takes a company name (e.g., Tesla) and returns only its industry sector (e.g., Automotive) in a single word.
    • Write a function is_urgent(email_body) that analyzes a customer email and returns True if customer sounds frustrated or mentions a deadline, and False otherwise.
    • Write a function classify_sentiment(text) that classifies the sentiment of a given text as positive, negative, or neutral.
    • Write a function to_kg(weight_str) that takes strings like 150 lbs or 2 tons and returns the numerical value converted to kilograms as a float.
  2. Few Shot classification

    Question 2 of 5

    • Write a function extract_skills(job_description) that extracts and returns a list of required skills mentioned in a job description using 2 examples.
    • Write a function standardize_date(date_str) that provides 3 examples of converting messy dates (e.g., Jan 5th 22, 05/01/2022) into the YYYY-MM-DD format
    • Write a function parse_address(raw_text) that uses 2 examples to show how to turn a string like 123 Main St, New York, NY into a JSON with street, city, state keys.
    • Write a function text_to_sql(user_query) that uses 4 examples to teach the model how to convert a natural language request (e.g., Show me top 5 users by spend) into a valid SELECT statement for a table named Users
  3. Role Playing

    Question 3 of 5

    • Write a function explain_p_value(p_val) where the model acts as a Senior Statistician. It should explain the significance of the input p_val to a non-technical product manager.
    • Write a function check_pii(text_data) where the model acts as a Privacy Auditor. It must scan a string and return a list of any sensitive information found (emails, phone numbers, names).
    • Write a function review_code(python_snippet) where the model acts as a Lead Engineer. It should return exactly two bullet points: one for a bug found and one for a performance improvement.
  4. Conditional Prompting

    Question 4 of 5

    • Write a function translate_if_needed(text) that checks the input language. If it is English, return the text as-is; else return the English translation.
    • Write a function safe_summary(news_article) that summarizes a text, but adds a rule: "If the article contains political bias, start the response with 'Warning: Subjective Content' before the summary."
    • Write a function route_query(user_query) that checks if the input is a technical support question (e.g., contains words like "error", "issue", "help"). If it is, return "Route to Tech Support"; otherwise, return "Route to Sales".
  5. Multistep Reasoning

    Question 5 of 5

    • Write a function plan_experiment(business_problem) that takes a problem like "Users are leaving the checkout page." Step 1: State a null hypothesis. Step 2: Propose an A/B test change (e.g., button color). Step 3: Define the "Success Metric" to track.