Hi, I'm

Pei-Han Hsu.

INFO7375 ST Prompt Engineering & AI Spring 2025

This website is built as part of my assignment - Teach a Prompt Pattern, combining the web development techniques with practical applications of AI and prompt engineering.

Part 1 - Comprehensive Exploration of the Prompt Pattern

The Prompt pattern I chose is role pattern. The pattern is a natural language instruction that guides an AI model to respond as if it were a specific persona. For example, instead of simply asking Solve this equation, the prompt might specify You are a math professor explaining this to a high school student. This ensures the AI’s response is tailored to the student’s level and includes appropriate explanations and examples.

Part 1-1 - Core Concepts

Role Assignment - Role Assignment
  • Role prompts establish a specific “identity” for the responder, shaping both the tone and perspective of communication. For instance:
    • Role: You are a doctor explaining a treatment plan to a patient.
    • Output Style: Clear, compassionate, and informative.
  • This approach ensures the message aligns with the audience’s expectations and is delivered in a way that suits the assigned role. By defining the role explicitly, the responder generates responses that feel natural and relatable within the given context.
Contextual Framing - Contextual Framing
  • Including situational details in the prompt defines the scope and depth of the response, tailoring it to the specific circumstances.
  •   import gpt
      # Define the role and situation
      context = "You are a customer support agent. A customer is unhappy with their recent purchase."
      prompt = f"{context} Write a polite response to address their concerns."
    
      # Generate the response
      response = gpt.generate(prompt)
      print(response)
    
  • In this example, the context (“customer support agent”) and the situation (“unhappy customer”) provide clear boundaries and guidance for the generated response. Contextual prompts embed specific details, ensuring the model:
    • Focuses on relevant knowledge.
    • Adapts to the situational requirements.
    • Responds with clarity and precision for tasks requiring domain-specific awareness.
Summary - Summary
By combining Role Assignment and Contextual Framing, this methodology creates responses that are both accurate and aligned with the user’s needs, offering an effective strategy for diverse NLP applications.

Part 1-2 Purpose of the Pattern

Significance in NLP

It helps generate responses that are specific to the given context or role, improving relevance and meeting user expectations more effectively.

  1. Contextual Relevance: Assigning roles like doctor or teacher ensures responses match the situation and user needs.
  2. Personalized Experience: Tailored replies create more engaging and meaningful interactions, like a healthcare chatbot offering clear advice.
  3. Task Precision: Keeps responses focused on specific queries, such as handling only refund-related questions.
  4. Consistency: Maintains a uniform tone and style, important for professional or brand communication.
  5. Adaptability: Fits various uses, from customer service to education, by customizing responses based on roles.
  6. Improved Training: Helps models perform better in specific areas, like legal or medical contexts, through fine-tuned role prompts.
  7. Integrated Responses: Combines text with visual or other inputs to provide clearer and more relevant answers.
Impact on Model Performance
  1. Clarity - Defining roles and context eliminates ambiguity, enabling accurate and coherent responses.
  2. Relevance - Providing situational details tailors responses to specific needs.
  3. Consistency - Clearly defined roles and contexts help maintain uniformity in responses across similar tasks or queries.
  4. Efficiency - Embedding task-specific details reduces the need for additional clarifications, speeding up response generation and improving user satisfaction. 5.Adaptability - Role prompts allow the model to seamlessly adjust its tone and style based on the defined context.
  5. Depth - Contextual framing encourages more in-depth and nuanced responses tailored to the complexity of the task.
  6. Example Scenario - You are a financial advisor. A client wants to know how to plan for retirement savings. Role-based Prompt Example
Impact on User Interaction
  1. Increased Engagement - Role prompts create responses that resonate with users by mimicking professional or empathetic tones suited to the context.
  2. Consistency and Reliability - By defining the response framework, role prompts ensure consistent output quality across similar queries.
  3. Personalization - Role prompts allow responses to be tailored to individual user preferences, improving relevance and satisfaction.
  4. Trust and Credibility - By simulating expert roles, role prompts establish a sense of authority and professionalism, fostering trust.
  5. Empathy and Emotional Connection - Role prompts designed to express empathy help users feel understood, improving the overall interaction.
  6. Example Scenario - You are a travel advisor. A client wants recommendations for a budget-friendly beach vacation. Role-based Travel Prompt Example
Real-World Benefits
  1. Customer Support - Role prompts enable chatbots to handle inquiries effectively, reducing wait times and improving user satisfaction.
  2. Education - In virtual tutoring, prompts like “You are a math teacher explaining algebra to a 10th grader” ensure responses are age-appropriate and educational.
  3. Healthcare - Role prompts in medical AI systems provide patient-centric advice, enhancing accessibility to healthcare information.
Significance in Real-World Applications
  1. Role prompts are critical in guiding AI to deliver focused, contextual, and highly relevant outputs. This is especially impactful in real-world applications where accuracy, tone, and specificity are essential for success.
  2. Take AI in Medical Support for example.
  • Scenario - A healthcare organization used a role prompt to develop an AI tool for patient triage.
  • Role Prompt - You are a virtual triage nurse. Your task is to assess patients’ symptoms based on their descriptions and suggest whether they should seek emergency care, consult a physician, or manage their symptoms at home. Use empathetic and non-alarming language. If the symptoms described are severe, advise immediate medical attention.
  1. Impact:
    • Scalability - The AI could handle thousands of inquiries per day, helping rural and underserved communities with limited healthcare access.
    • Patient Empowerment - The empathetic tone encouraged patients to describe their symptoms without fear or anxiety.
    • Lives Saved - By reliably flagging critical cases, the AI ensured that high-risk patients received timely care.

Part 2 - Demonstrating the Prompt Pattern Through Examples

Part 2-1 - Example:Customer Support Chatbots
Part 2-1 - Example:Customer Support Chatbots
An e-commerce platform receives thousands of customer inquiries daily, ranging from order tracking and refund requests to product recommendations. With limited human agents, response delays became a major issue, leading to customer dissatisfaction and decreased loyalty. To address this, the platform introduced a customer support chatbot, leveraging the role prompt pattern to define its behavior.
Part 2-2 - Role Prompt
Part 2-2 - Role Prompt
You are a polite and empathetic virtual customer support agent for an e-commerce platform. Your role is to assist customers with their inquiries, such as tracking orders, processing returns, and providing product information. Always use clear and concise language, avoid technical jargon, and offer step-by-step guidance. If an issue cannot be resolved, escalate the matter to a human agent while providing a summary of the conversation.
Part 2-3 - Execution
Part 2-3 - Execution
1. Order Tracking
2. Return Process
3. Human Escalation
Part 2-4 - Impact 1
Part 2-4 - Impact 1
Improved User Satisfaction By clearly defining the chatbot's role, it consistently handled inquiries with professionalism and empathy, significantly increasing customer satisfaction ratings.
Part 2-4 - Impact 2
Part 2-4 - Impact 2
Reduction in Errors The constraints and guidelines reduced misunderstandings, as the AI avoided unnecessary technical details and focused on simple instructions.
Part 2-4 - Impact 3
Part 2-4 - Impact 3
Efficiency Gains By taking on a well-defined role, the chatbot could handle up to 80% of basic customer queries without escalation to human agents, saving costs and time.

Part 3 - Presentation of the Prompt Pattern

Example - "Customer Support Chatbots"
An e-commerce platform receives thousands of customer inquiries daily, ranging from order tracking and refund requests to product recommendations. With limited human agents, response delays became a major issue, leading to customer dissatisfaction and decreased loyalty. To address this, the platform introduced a customer support chatbot, leveraging the role prompt pattern to define its behavior.
Why the Example Works?
There are 3 situation, relatability, clarity , and efficiency. Please read the above image.