arugyani / shopIQ

LLM powered high-consideration research tool for UTD senior project
1 stars 0 forks source link

LLM: prompts: abstract filters #13

Closed divyamk closed 3 months ago

divyamk commented 4 months ago

LLM Prompt Engineering - Questions & Answers

In this issue we test different prompts for getting user details and filter specifications from the LLM.

In addition, we will specify response formats for a consistent result.

arugyani commented 3 months ago

Preliminary Prompts

Contributors: @prajwalpkn @arugyani

Using guidance from Prompt Engineering Guide, the following prompts were developed and tested using Claude, GPT-3.5, and GPT-4. The prompts and outputs shown below are our current iterations after some hours working and iterating on various prompt techniques.

Key Notes

Prompts & Sample Outputs

Claude 3 Prompt

Basic Prompt
As an expert in cameras, generate a question to guide a customer in choosing the right camera product. Provide 4 multiple-choice options, each no longer than 5 words, to help the user make their purchasing decision. Use the user's response to the question to determine the next most relevant question to ask. Indicate whether the user can select multiple answers for the question.

Format the output in JSON as follows:

{ "question": "Your question here", "multipleAnswers": true, "options": [ { "label": "A", "text": "Option 1, max 5 words" }, { "label": "B", "text": "Option 2, max 5 words" }, { "label": "C", "text": "Option 3, max 5 words" }, { "label": "D", "text": "Option 4, max 5 words" } ] }

Continue this JSON format for up to 6 questions in total, each question based on the user's previous response. Set "multipleAnswers" to true or false for each question to indicate whether multiple answer selections are allowed. Respond with only the JSON.

[
    {
        "question": "What's your main purpose for the camera?",
        "answers": ["Sports photography", "Vlogging", "Travel photography", "General use"],
        "multipleAnswers": false
    },
    {
        "question": "Which sports will you be photographing?",
        "answers": ["Water sports", "Indoor sports", "Mountain sports", "Racing sports"],
        "multipleAnswers": true
    },
    {
        "question": "How important is video quality to you?",
        "answers": ["Very important", "Somewhat important", "Not very important", "Unimportant"],
        "multipleAnswers": false
    },
    {
        "question": "Do you need a camera that's easy to carry?",
        "answers": ["Yes, very light", "Somewhat portable", "Not a priority", "Size doesn't matter"],
        "multipleAnswers": false
    },
    {
        "question": "How important is weather resistance?",
        "answers": ["Very important", "Somewhat important", "Not very important", "Unimportant"],
        "multipleAnswers": false
    },
    {
        "question": "What's your budget range?",
        "answers": ["Under $200", "$200-$500", "$500-$1000", "Above $1000"],
        "multipleAnswers": false
    }
]

GPT Prompts & Outputs

Given the context of identifying a user's camera needs, particularly for beginners, create a simplified questionnaire. The goal is to make the process user-friendly while capturing essential preferences and requirements related to camera usage.

### Instructions ###
- Avoid preliminary descriptions. Directly list the questions with their respective multiple choice options.
- Formulate 5-6 questions designed to be easily understandable by someone with minimal knowledge of cameras. Each should aim to uncover specific needs or preferences.
- Provide 4 multiple choice answers for each question. These options should encompass a wide range of common preferences and needs. Keep answers concise, ideally under 5 words.
- Allow for multiple answers on certain questions where users might have more than one preference. Indicate clearly which questions permit multiple selections.
- Following the questionnaire, synthesize the responses to recommend camera specifications that match the identified preferences.

### Questionnaire Format ###
Responses should be structured in JSON format, adhering to the following template:

[
    {
        "question": "Your question here",
        "answers": ["Option 1", "Option 2", "Option 3", "Option 4"],
        "multipleAnswers": true or false
    }
    ...
]

Please ensure each question is designed to be approachable and informative, helping users articulate their camera needs without needing in-depth technical knowledge.
[
    {
        "question": "What's your main purpose for the camera?",
        "answers": ["Sports photography", "Vlogging", "Travel photography", "General use"],
        "multipleAnswers": false
    },
    {
        "question": "Which sports will you be photographing?",
        "answers": ["Water sports", "Indoor sports", "Mountain sports", "Racing sports"],
        "multipleAnswers": true
    },
    {
        "question": "How important is video quality to you?",
        "answers": ["Very important", "Somewhat important", "Not very important", "Unimportant"],
        "multipleAnswers": false
    },
    {
        "question": "Do you need a camera that's easy to carry?",
        "answers": ["Yes, very light", "Somewhat portable", "Not a priority", "Size doesn't matter"],
        "multipleAnswers": false
    },
    {
        "question": "How important is weather resistance?",
        "answers": ["Very important", "Somewhat important", "Not very important", "Unimportant"],
        "multipleAnswers": false
    },
    {
        "question": "What's your budget range?",
        "answers": ["Under $200", "$200-$500", "$500-$1000", "Above $1000"],
        "multipleAnswers": false
    }
]
prajwalpkn commented 3 months ago

Updated Claude 3 Prompt with Informational Blurb and JSON format:

As an expert in cameras, generate a question to guide a customer in choosing the right camera product. Provide 4 multiple-choice options, each no longer than 5 words, to help the user make their purchasing decision. Use the user's response to the question to determine the next most relevant question to ask. Indicate whether the user can select multiple answers for the question.

Format the output in JSON as follows:

{ "question": "Your question here", "questionInfo": "Informational blurb about the question and options, if needed", "multipleAnswers": true, "options": [ { "label": "A", "text": "Option 1, max 5 words" }, { "label": "B", "text": "Option 2, max 5 words" }, { "label": "C", "text": "Option 3, max 5 words" }, { "label": "D", "text": "Option 4, max 5 words" } ] }

Continue this JSON format for up to 6 questions in total, each question based on the user's previous response. Set "multipleAnswers" to true or false for each question to indicate whether multiple answer selections are allowed. Include the "questionInfo" field with an informational blurb if the question and options require technical knowledge or information not widely known to the general public. Respond with only one question at a time in JSON.
arugyani commented 3 months ago

New Prompt for Filter Selection

Added new prompt for converting user generalized Q/A to technical filter specifications. The below prompt is the final version of multiple iterations.

### TASK ###
Your task is to analyze user input provided in JSON format, which includes a series of questions and their answers. 

Based on this information, you will generalize and make selections for product filters that best match the user's criteria. 

Focus on interpreting the nuances in the user's responses to select the most appropriate filters. If the provided information is insufficient for a precise selection, do your best to generalize based on your knowledge about the product. 

Your output will also be structured in JSON, detailing the selected filters that align with the user's preferences.

JSON Output

{
  "Price": "Under $200",
  "Brand": [],
  "Color": ["Black", "Blue", "Silver", "White", "Red", "Gray"],
  "HD Format": ["4K", "1080p"],
  "Storage Media": ["microSD Card", "SD Card"],
  "Connectivity": ["Wireless", "USB", "HDMI"],
  "Sensor Resolution": ["8 – 12 MP", "12 – 16 MP", "16 – 20 MP"],
  "Video Format": ["H.264 / AVC", "MOV", "MPEG-4"],
  "Optical Zoom": ["< 4x", "4 – 8x"],
  "Video Resolution": ["8 – 12 MP", "12 – 16 MP"],
  "Photo Resolution": ["5 – 12 MP", "12 – 20 MP"],
  "Multipack Quantity": [],
  "Internal Storage Capacity": ["16 GB", "32 GB", "64 GB"],
  "Shipping & returns": ["Free returns", "1-3 day delivery", "Free shipping"]
}