Effective prompt engineering with the kluster.ai API¶
Prompt engineering is the practice of crafting inputs to guide large language models (LLMs) toward high‑quality responses. Well‑designed prompts can turn vague outputs into precise, actionable insights.
In this notebook, we show how prompt quality affects LLM performance by comparing three levels of prompts—Bad, Better, and Best—in a retail sales analysis scenario. The goal: uncover strategies to grow the business and boost profits.
Using a simple retail dataset with sales, pricing, and profit data, you’ll see how adding structure, context, and business‑specific details transforms basic observations into strategic recommendations.
By the end, you’ll be equipped to apply these principles to your own business data using any of the supported models available through the kluster.ai API—unlocking deeper, more valuable insights.
Prerequisites¶
Before getting started, ensure you have:
- A kluster.ai account - sign up at kluster.ai
- A kluster.ai API key - get your key from the API Keys page. For instructions, see the API key guide
Setup¶
In this notebook, we'll use Python's getpass
module to safely input the key. Provide your kluster API key when prompted. Then, we'll import the required dependencies, specify the LLM model to use, and initialize the client. Refer to the supported models chart if you're unsure which one to choose.
# Import required packages at the beginning of the notebook
from getpass import getpass
from openai import OpenAI
from IPython.display import Markdown
api_key = getpass('Enter your kluster.ai API key: ')
# Feel free to swap out the model with any of Kluster's supported models
model = "google/gemma-3-27b-it"
client = OpenAI(base_url="https://api.kluster.ai/v1", api_key=api_key)
Bad prompt 🔴¶
Below is an example of a poorly written prompt that’s unlikely to yield a meaningful answer. Although it’s an extreme case, it illustrates how a vague prompt with minimal context can limit an LLM’s response. For instance, we don’t know the product, the audience, or the goal of asking the LLM. Providing that information would immediately make this prompt more effective.
# Define the bad prompt
bad_prompt_text = """Here's some data:
| Product | Sales |
|---------|-------|
| A | 10 |
| B | 20 |
| C | 5 |
| D | 15 |
Tell me about it."""
# Use the variable in the API call
response_bad = client.chat.completions.create(
model=model,
messages=[{"role": "user", "content": bad_prompt_text}],
temperature=0.5
).choices[0].message.content
print("\nModel response:\n" + response_bad)
Model response: Okay, here's a breakdown of the data you provided: **Overview:** This data shows the sales figures for four different products (A, B, C, and D). **Key Observations:** * **Product B is the top performer:** It has the highest sales with 20 units sold. * **Product A is second best:** It sold 10 units. * **Product D is in the middle:** It sold 15 units. * **Product C is the lowest performer:** It has the lowest sales with only 5 units sold. **Possible Insights & Questions:** * **Why is Product B so successful?** Is it price, marketing, features, or something else? * **Why is Product C struggling?** Does it need improvement, better marketing, or should it be discontinued? * **Overall sales are relatively low:** Depending on the context (time period, market size, etc.), these numbers might be considered low. * **What is the unit of sale?** Is it individual items, cases, or something else? Knowing this helps understand the scale of the sales. **In short, this data provides a quick snapshot of product performance, highlighting strengths (B) and weaknesses (C) and prompting further investigation.** Do you want me to perform any calculations on this data (e.g., percentages of total sales, average sales)? Or would you like me to consider this data in a specific context? For example, are these sales figures for a week, a month, or a year?
Analysis of the bad prompt¶
The Bad prompt offers only the most rudimentary information—products and their sales—and provides no clear instructions beyond "tell me about it." This inevitably results in:
- Minimal context - without pricing, profit margins, or a specific goal (e.g., analyzing profitability, recommending strategies), the LLM can only produce surface-level observations
- No actionable guidance - the prompt doesn't request particular insights or next steps, so the model responds with high-level statements rather than solutions
- Limited utility - because the data is purely quantitative (sales alone) and lacks details such as time frame, product characteristics, or marketing context, the response cannot go beyond pointing out which products sold more or less
Overall, this prompt's lack of clear direction and supporting information stifles the model's ability to provide meaningful analysis or recommendations.
Better prompt 🟡¶
The prompt below significantly improves upon the basic version by providing essential context and structure—such as pricing information, a specified timeframe, and requests for clear analytical steps with actionable recommendations. This approach guides the model toward delivering more valuable business insights. Remember, the prompter’s primary goal is to learn how to run a more profitable business.
# Define the better prompt
better_prompt_text = """Here's monthly sales data from our store (units sold) for four products during January 2025:
| Product | Units Sold |
|---------|------------|
| A | 10 |
| B | 20 |
| C | 5 |
| D | 15 |
We sell these products at the following prices:
| Product | Price per Unit |
|---------|----------------|
| A | $5.00 |
| B | $3.50 |
| C | $8.00 |
| D | $6.00 |
I'd like you to do the following clearly and specifically:
1. Calculate total monthly revenue for each product.
2. Identify the best and worst-performing products by revenue.
3. Suggest specific and actionable strategies to boost overall sales, particularly focusing on lower-performing products.
4. Provide recommendations on whether adjusting pricing or marketing might improve profitability based on current sales performance.
Structure your response clearly with separate sections and explain briefly your reasoning behind each recommendation."""
# Use the variable in the API call
response_better = client.chat.completions.create(
model=model,
messages=[{"role": "user", "content": better_prompt_text}],
temperature=0.5
).choices[0].message.content
print("\nModel response:\n" + response_better)
Model response: ## January 2025 Sales Analysis & Recommendations Here's a breakdown of the January 2025 sales data, including revenue calculations, performance analysis, and actionable strategies for improvement. **1. Total Monthly Revenue per Product** To calculate revenue, we multiply the units sold by the price per unit for each product: * **Product A:** 10 units * $5.00/unit = $50.00 * **Product B:** 20 units * $3.50/unit = $70.00 * **Product C:** 5 units * $8.00/unit = $40.00 * **Product D:** 15 units * $6.00/unit = $90.00 **2. Best & Worst Performing Products (by Revenue)** * **Best Performing Product:** Product D ($90.00 revenue) - This product generated the highest revenue in January. * **Worst Performing Product:** Product C ($40.00 revenue) - This product generated the lowest revenue in January. **3. Strategies to Boost Overall Sales** Here are specific, actionable strategies, with a particular focus on improving the performance of Products A and C: * **Product C (Lowest Performing - $40 Revenue):** * **Bundle with Product D:** Offer a bundle deal – "Buy Product D and get 20% off Product C." This leverages the popularity of Product D to drive sales of Product C. *Reasoning: Cross-selling can introduce customers to products they might not have considered otherwise.* * **Targeted Social Media Campaign:** Run a social media campaign showcasing the *unique benefits* of Product C. Focus on high-quality images/videos demonstrating its value. *Reasoning: Product C has a higher price point, suggesting it might offer a premium feature. Marketing should emphasize that.* * **Limited-Time Promotion:** Run a "Limited-Time Offer" – e.g., "25% off Product C this weekend only." Create a sense of urgency. *Reasoning: Creates immediate demand and encourages trial.* * **Product A (Low Performing - $50 Revenue):** * **Loyalty Program Integration:** Offer double loyalty points on Product A purchases. *Reasoning: Encourages repeat purchases and builds customer loyalty.* * **In-Store Placement:** Improve the placement of Product A in the store. Move it to a higher-traffic area or near complementary products. *Reasoning: Visibility significantly impacts sales.* * **Content Marketing:** Create blog posts or short videos demonstrating how Product A solves a specific customer problem. *Reasoning: Educates customers about the product's value and builds trust.* * **Product B (Moderate Performing - $70 Revenue):** * **Increase Order Value:** Suggest related products at checkout (e.g., "Customers who bought Product B also bought…"). *Reasoning: Increases the average transaction value.* * **Product D (Best Performing - $90 Revenue):** * **Maintain Momentum:** Continue current marketing efforts. Monitor sales closely for any dips and be prepared to react. *Reasoning: Don't fix what isn't broken, but stay vigilant.* * **Gather Customer Feedback:** Send out a short survey to Product D customers asking for feedback on what they like about the product. Use this information in marketing materials. *Reasoning: Leverage positive customer experiences.* **4. Pricing & Marketing Recommendations for Profitability** Based on the current performance, here's a breakdown of pricing and marketing considerations: * **Product C (High Price, Low Volume):** * **Pricing – Consider a Slight Reduction:** While Product C has the highest price, its low sales volume suggests price sensitivity. A small price reduction (e.g., $1.00) *could* increase demand enough to offset the lower margin. *However, test this carefully!* A/B testing different price points is recommended. * **Marketing – Focus on Value Proposition:** Marketing should *strongly* emphasize the benefits justifying the higher price. Highlight quality, durability, unique features, or exclusivity. * **Product B (Moderate Price, Moderate Volume):** * **Pricing – Monitor Competitor Pricing:** Ensure Product B's price is competitive within the market. * **Marketing – Emphasize Value for Money:** Highlight the affordability and benefits of Product B. * **Product A (Low Price, Low Volume):** * **Pricing – Consider a Bundle:** Instead of a price increase, consider bundling Product A with other items to increase the overall transaction value. * **Marketing – Focus on Accessibility:** Position Product A as an accessible and affordable option. * **Product D (Moderate Price, High Volume):** * **Pricing – Monitor for Optimal Margin:** Maintain current pricing unless competitor activity necessitates a change. Focus on maximizing margin. * **Marketing – Leverage Popularity:** Continue highlighting Product D's popularity and positive customer reviews. **Important Considerations:** * **Data Collection:** Continue to track sales data monthly to monitor the effectiveness of these strategies. * **Customer Segmentation:** Consider segmenting your customer base to tailor marketing efforts more effectively. * **A/B Testing:** When making pricing changes, always A/B test different price points to determine the optimal price for maximizing revenue and profit. * **Seasonality:** Be mindful of potential seasonal trends that may affect sales. This analysis provides a starting point. Regular monitoring and adjustments are crucial for ongoing success.
Analysis of the better prompt¶
This Better prompt elevates the request beyond the "Bad" version by incorporating pricing details and clearer instructions, which yield more focused calculations and recommendations. The prompt also specifies a timeline (January 2025) and outlines key tasks (calculating revenue, identifying product performance, suggesting sales-boosting strategies). As a result, the LLM response provides:
- Structured revenue calculations - by explicitly asking for per-product revenue, it brings a quantitative foundation to the analysis
- Actionable recommendations - requests for pricing and marketing adjustments prompt specific suggestions, rather than broad, generic ideas
- Organized output - clearly defined sections ensure the response is easy to interpret and act upon
However, the prompt stops short of requesting profit margins, customer demographics, or broader business context (e.g., marketing channels or inventory challenges) seen in the Best prompt. Consequently, while the Better prompt moves toward more concrete, data-driven insights, it still lacks the richness and depth needed to produce thorough, strategic recommendations.
Best prompt 🟢¶
Finally, we arrive at a prompt that provides enough detail for the LLM to respond with meaningful insights on growing the business and increasing profits in this hypothetical scenario. By outlining comprehensive business context, detailed product information, structured analytical requirements, demographic data, profit margins, marketing channels, and specific business challenges, this prompt equips the model to deliver tailored and actionable recommendations.
# Define the best prompt
best_prompt_text = """Here's monthly sales data (units sold) from our small retail store for four products during January 2025:
| Product | Units Sold |
|---------|------------|
| A | 10 |
| B | 20 |
| C | 5 |
| D | 15 |
Prices and profit margins are as follows:
| Product | Price per Unit | Profit Margin (%) |
|---------|----------------|-------------------|
| A | $5.00 | 30% |
| B | $3.50 | 40% |
| C | $8.00 | 25% |
| D | $6.00 | 35% |
### Additional Business Context:
- **Customer Demographics:**
- Primary: Young adults (18-30 years old)
- Secondary: Middle-aged professionals (35-50 years old)
- Marketing channels: Instagram ads, email newsletters, weekend promotions
- **Product Context:**
- **Product A:** Everyday consumable, consistent demand
- **Product B:** Lower-priced, frequent purchases, popular with young adults
- **Product C:** Premium product, aimed at professionals, slow-moving, excess inventory
- **Product D:** Mid-range product, recently gaining popularity
- **Challenges:**
- Overstock of Product C; immediate action required
- Limited marketing budget; high ROI needed
- Seeking quick profitability improvements through inventory and pricing strategies, avoiding new product lines
### Clearly and specifically, please provide the following structured analysis:
**1. Revenue and Profit Analysis:**
- Calculate total monthly revenue and total gross profit per product.
- Clearly identify best and worst-performing products based on profitability.
**2. Profitability Optimization Recommendations (Think step-by-step):**
- Provide **specific, actionable steps** to quickly address excess inventory, particularly Product C.
- Suggest **explicit pricing adjustments or promotional strategies**, clearly aligned with primary and secondary demographics.
- Clearly explain your reasoning behind each recommendation.
**3. Marketing Optimization Recommendations:**
- Provide targeted recommendations for utilizing existing marketing channels (Instagram, newsletters, weekend promotions) to maximize profitability.
- Clearly specify which products to prioritize in each channel and explain why.
**Structure your response clearly:**
- Use separate headings for each of the above sections.
- Present recommendations clearly in bullet-point format.
- Briefly but explicitly explain your reasoning behind each suggestion.
Please be concise, specific, and actionable."""
# Use the variable in the API call
response_best = client.chat.completions.create(
model=model,
messages=[{"role": "user", "content": best_prompt_text}],
temperature=0.5
).choices[0].message.content
print("\nModel response:\n" + response_best)
Model response: ## 1. Revenue and Profit Analysis Here's the breakdown of revenue and profit for each product in January 2025: | Product | Units Sold | Price per Unit | Total Revenue | Profit Margin (%) | Gross Profit | |---------|------------|----------------|---------------|-------------------|--------------| | A | 10 | $5.00 | $50.00 | 30% | $15.00 | | B | 20 | $3.50 | $70.00 | 40% | $28.00 | | C | 5 | $8.00 | $40.00 | 25% | $10.00 | | D | 15 | $6.00 | $90.00 | 35% | $31.50 | | **Total**| **40** | | **$250.00** | | **$84.50** | **Best Performing Product (Profitability):** Product D generates the highest gross profit ($31.50) despite not having the highest revenue. This is due to its relatively high price and profit margin. **Worst Performing Product (Profitability):** Product C generates the lowest gross profit ($10.00) despite a higher price point. This is due to low unit sales and a lower profit margin compared to D. ## 2. Profitability Optimization Recommendations Here are actionable steps to improve profitability, focusing on inventory and pricing: * **Product C - Immediate Inventory Reduction:** * **Flash Sale (Target: Professionals):** Offer a 30% discount on Product C for one weekend only, promoted heavily via email newsletter to the secondary demographic (35-50 year olds). *Reasoning:* A significant discount incentivizes purchase, moving inventory quickly. Targeting professionals through email maximizes reach to the intended audience. * **Bundle with Product D (Target: Both Demographics):** Create a bundle: Product C + Product D at a 10% discount compared to purchasing individually. *Reasoning:* Attaches a slow-moving item (C) to a popular one (D), increasing the likelihood of C being sold. Appeals to both demographics. * **Consider a "Buy One Get One 50% Off" promotion on Product C:** *Reasoning:* This encourages customers to purchase two units, further reducing inventory. * **Product A - Maintain Current Strategy:** Continue consistent sales. No immediate changes needed. *Reasoning:* Consistent demand indicates a stable revenue stream. * **Product B - Targeted Promotion (Target: Young Adults):** * **Instagram Contest/Giveaway:** Run a contest requiring users to follow the store's Instagram page, tag friends, and share a post featuring Product B. Offer a prize bundle including Product B. *Reasoning:* Leverages Instagram's reach to the primary demographic, increasing brand awareness and driving sales. * **Introduce a "3 for $10" deal:** *Reasoning:* Encourages larger purchases of this frequently bought item, increasing revenue. * **Product D - Slight Price Increase (Target: Both Demographics):** * Increase the price by $0.50 to $6.50. *Reasoning:* Product D is gaining popularity and has a good profit margin. A small price increase can boost profitability without significantly impacting demand. Monitor sales closely after the increase. ## 3. Marketing Optimization Recommendations Here's how to utilize existing marketing channels to maximize profitability: * **Instagram (Focus: Product B & D):** * **Product B:** Focus on visually appealing content showcasing Product B in lifestyle settings relevant to young adults (e.g., study spaces, social gatherings). Run the contest/giveaway mentioned above. *Reasoning:* Instagram is the primary channel for reaching the young adult demographic. * **Product D:** Highlight the benefits and features of Product D through short videos and engaging images. *Reasoning:* Capitalize on its growing popularity and appeal to both demographics. * **Run targeted ads:** Utilize Instagram's ad platform to target ads specifically to the 18-30 and 35-50 age ranges, promoting relevant products. * **Email Newsletter (Focus: Product C & D):** * **Product C:** Promote the flash sale and bundle deal exclusively to the email list, specifically segmenting the list to target the 35-50 age group. *Reasoning:* Email is effective for reaching the professional demographic and driving immediate action. * **Product D:** Announce the slight price increase and highlight its benefits. *Reasoning:* Informs existing customers about the change and reinforces the product's value. * **Segmented Emails:** Send different newsletters to the young adult and professional segments, featuring products relevant to their demographics. * **Weekend Promotions (Focus: All Products, Rotating):** * **Rotate promotions weekly:** One weekend focus on Product B, another on Product D, and dedicate a weekend to clearing out remaining Product C inventory. *Reasoning:* Creates a sense of urgency and encourages repeat visits. * **In-Store Signage:** Prominently display weekend promotions in-store to capture impulse purchases. *Reasoning:* Drives foot traffic and maximizes sales during peak hours. These recommendations are designed to be implemented quickly and efficiently, leveraging existing resources to improve profitability within the given constraints. Continuous monitoring of sales data is crucial to assess the effectiveness of these strategies and make adjustments as needed.
Analysis of the best prompt¶
The Best prompt excels because it integrates comprehensive data (product sales, prices, and profit margins) with detailed business context (target demographics, product characteristics, marketing channels, and specific challenges). By explicitly specifying the desired structure—including step-by-step revenue and profit analysis, targeted profitability recommendations, and marketing optimizations—it guides the LLM toward high-value, actionable insights.
Key strengths of this Best prompt:
- Complete data & metrics - monthly sales, pricing, and profit margins remove guesswork and allow precise revenue/profit calculations
- Focused business context - target customer demographics, marketing channels, and product nuances (e.g., overstock of Product C) align the output with real business priorities
- Clear task breakdown - dividing the request into distinct sections (Revenue/Profit Analysis, Profitability Recommendations, Marketing Strategies) ensures the response is both methodical and thorough
- Actionability & specificity - the prompt requests concrete next steps—such as pricing tweaks and promotional ideas—tailored to each product's characteristics and customer segment
- Logical reasoning instructions - guiding the LLM to "think step-by-step" fosters more thoughtful planning, especially around clearing excess inventory and leveraging different marketing channels
Overall, this approach maximizes the LLM's potential, yielding responses that are precise, context-aware, and immediately useful to decision-makers.
Leveraging AI to improve your prompts¶
Using an LLM to refine your prompt might sound meta, but it’s a powerful way to accelerate your prompt engineering learning curve. By harnessing AI to analyze and tweak your own queries, you can rapidly elevate the quality of your prompts and, ultimately, your results.
While our best prompt is already strong, prompting an LLM for further improvements highlighted additional considerations, such as setting a clear time horizon, specifying budget constraints (e.g., a $2,000 monthly marketing budget), and assessing potential risks (e.g., pitfalls of new approaches). Incorporating these refinements can make your prompts more actionable and better aligned with real-world business needs.
You can ask the LLM to analyze and improve your prompt by submitting a meta-prompt like:
I want to get better results from my prompt. Here's what I'm trying to achieve:
[Describe your goal]
Here's my current prompt:
"""
[Your existing prompt]
"""
Please improve this prompt after analyzing it by outputting the complete contents of the revised and improved prompt. Please be sure to provide the exact prompt that can be fed into an LLM without filler or extraneous information. Consider:
- Adding relevant context or constraints
- Clarifying instructions and expectations
- Structuring the output format
- Including examples if helpful
We can feed the above prompt alongside our existing best prompt text into the model as shown below:
# Re-use the best prompt text defined above.
ai_prompt_text = ("I want to get better results from my prompt. Here's what I'm trying to achieve:\n"
"The goal is to analyze the given sales data, product information, and business context to provide a structured and actionable report. This report should include:\n"
"1. A revenue and profit analysis to identify the best and worst-performing products.\n"
"2. Specific recommendations for optimizing profitability through pricing, inventory management, and promotional strategies.\n"
"3. Targeted marketing optimization suggestions.\n"
"\n"
"Here's my current prompt:\n"
"\"\"\"\n"
+ best_prompt_text +
"\n\"\"\"\n"
"Please improve this prompt after analyzing it by outputting the complete contents of the revised "
"and improved prompt. Please be sure to provide the exact prompt that can be fed into an LLM "
"without filler or extraneous information. Consider:\n"
"- Adding relevant context or constraints\n"
"- Clarifying instructions and expectations\n"
"- Structuring the output format\n"
"- Including examples if helpful")
# Use the variable in the API call
response_ai_enhanced = client.chat.completions.create(
model=model,
messages=[{"role": "user", "content": ai_prompt_text}],
temperature=0.5
).choices[0].message.content
print("\nModel response:\n" + response_ai_enhanced)
Model response: ``` Here's monthly sales data (units sold) from our small retail store for four products during January 2025: | Product | Units Sold | |---------|------------| | A | 10 | | B | 20 | | C | 5 | | D | 15 | Prices and profit margins are as follows: | Product | Price per Unit | Profit Margin (%) | |---------|----------------|-------------------| | A | $5.00 | 30% | | B | $3.50 | 40% | | C | $8.00 | 25% | | D | $6.00 | 35% | ### Additional Business Context: - **Customer Demographics:** - Primary: Young adults (18-30 years old) - responsive to social media and discounts. - Secondary: Middle-aged professionals (35-50 years old) - value quality and convenience, respond to email and targeted promotions. - Marketing channels: Instagram ads, email newsletters, weekend promotions. Instagram is currently performing better than email. - **Product Context:** - **Product A:** Everyday consumable, consistent demand, relatively price insensitive. - **Product B:** Lower-priced, frequent purchases, popular with young adults, highly price sensitive. - **Product C:** Premium product, aimed at professionals, slow-moving, significant excess inventory (approximately 30 units remaining). Holding cost is $1/unit/month. - **Product D:** Mid-range product, recently gaining popularity, moderate price sensitivity. - **Challenges:** - Overstock of Product C; immediate action required to minimize holding costs. - Limited marketing budget ($200/month); high ROI needed. - Seeking quick profitability improvements through inventory and pricing strategies, avoiding new product lines. We are aiming for a 10% increase in overall monthly profit. ### Clearly and specifically, please provide the following structured analysis. Present your response as a report with the sections below. Include calculations where appropriate. **1. Revenue and Profit Analysis:** - Calculate total monthly revenue and total gross profit per product. Show your work. (e.g., Revenue = Units Sold * Price per Unit; Profit = Revenue * Profit Margin). - Clearly identify best and worst-performing products based on total gross profit. Rank products from best to worst by profit. **2. Profitability Optimization Recommendations (Think step-by-step, prioritize Product C):** - **Product C - Inventory Reduction:** Provide 3-5 specific, actionable steps to quickly address excess inventory. Include estimated impact (e.g., "Reduce price by 20% – estimated to sell 10 units this month"). Consider bundling options. - **Pricing & Promotions:** Suggest explicit pricing adjustments *or* promotional strategies for Products A, B, and D, clearly aligned with primary and secondary demographics. Specify the promotion type (e.g., "BOGO 50% off", "10% off for email subscribers"). Include estimated impact on unit sales. - **Reasoning:** For *each* recommendation, clearly explain the reasoning behind it, referencing customer demographics, product context, or business challenges. **3. Marketing Optimization Recommendations (Budget: $200/month):** - Provide targeted recommendations for utilizing existing marketing channels (Instagram, newsletters, weekend promotions) to maximize profitability. - **Channel Allocation:** Specifically allocate the $200 marketing budget across the channels (e.g., "Instagram: $120, Email: $80"). Justify your allocation. - **Product Prioritization:** Clearly specify which products to prioritize in each channel and explain *why*. Be specific about ad copy/email subject lines (examples are helpful). - **KPIs:** Suggest 1-2 Key Performance Indicators (KPIs) to track the success of your marketing recommendations. **Structure your response clearly:** - Use separate headings for each of the above sections. - Present recommendations clearly in bullet-point format. - Include calculations and estimated impacts where applicable. - Be concise, specific, and actionable. Focus on *immediate* improvements. ```
Analysis of the AI-enhanced prompt¶
The AI‑enhanced prompt is stronger because it embeds several best‑practice elements that the baseline prompt omits:
- Clear scope & constraints - sets time horizon, budget, and focus areas so the model delivers realistic short-term actions
- Structured, ranked output - provides a template and asks for impact-ordered steps with supporting calculations for decision-ready clarity
- Rich context - supplies demographics, product details, challenges, and KPIs to drive tailored, not generic, recommendations
- Built-in risk check - requires downside analysis on each suggestion, surfacing trade-offs upfront
These additions sharpen the prompt's clarity, specificity, and operational relevance; they tell the model exactly what to deliver, within which limits, and how to present it, thereby increasing the likelihood of receiving actionable, decision‑ready insights regardless of which LLM you use.
Use the AI-enhanced prompt¶
Now that we have our AI-enhanced prompt let's submit it. We'll then compare it to the response the existing best (human-generated) prompt received.
# Feed the AI-generated prompt to the LLM for a response
response_ai_enhanced_prompt = client.chat.completions.create(
model=model,
messages=[{"role": "user", "content": response_ai_enhanced}],
temperature=0.5
).choices[0].message.content
print("\nModel response:\n" + response_ai_enhanced_prompt)
Model response: ## Retail Store Profitability Improvement Report - January 2025 **1. Revenue and Profit Analysis:** | Product | Units Sold | Price per Unit | Revenue | Profit Margin (%) | Gross Profit | |---------|------------|----------------|---------|-------------------|--------------| | A | 10 | $5.00 | $50.00 | 30% | $15.00 | | B | 20 | $3.50 | $70.00 | 40% | $28.00 | | C | 5 | $8.00 | $40.00 | 25% | $10.00 | | D | 15 | $6.00 | $90.00 | 35% | $31.50 | | **Total**| **40** | | **$250.00**| | **$84.50** | **Calculations:** Revenue = Units Sold * Price per Unit; Profit = Revenue * Profit Margin **Product Ranking (by Gross Profit):** 1. **D:** $31.50 2. **B:** $28.00 3. **A:** $15.00 4. **C:** $10.00 **2. Profitability Optimization Recommendations:** **Product C - Inventory Reduction:** * **20% Price Reduction:** Reduce the price of Product C from $8.00 to $6.40. *Estimated Impact:* Sell 10 additional units this month, reducing inventory to 20 units. This generates $64 in additional revenue and $16 in additional profit. * **Bundle with Product A:** Offer a bundle of Product C and Product A for $12.00 (regular price $13.00). *Estimated Impact:* Sell 5 bundles, moving 5 units of C and 5 units of A. This encourages C sales and leverages A’s consistent demand. Profit from bundle: ($6.40 + $5.00) * 0.30 (C profit) + $5.00 * 0.30 (A profit) = $11.40 + $1.50 = $12.90. A small discount for the bundle. * **"Last Chance" Email Campaign:** Send a targeted email to the secondary demographic (professionals) highlighting the limited availability and premium quality of Product C, emphasizing the price reduction. *Estimated Impact:* Sell 3 additional units. * **Social Media Spotlight (Instagram):** Feature Product C with high-quality imagery and a compelling story highlighting its benefits for professionals. *Estimated Impact:* Sell 2 additional units. **Pricing & Promotions:** * **Product A (Maintain Price):** No changes. Product A is price insensitive and provides consistent revenue. * **Product B (BOGO 50% Off):** Implement a "Buy One Get One 50% Off" promotion on Product B, targeting the young adult demographic via Instagram. *Estimated Impact:* Increase unit sales from 20 to 30. Revenue: (20 * $3.50) + (10 * $1.75) = $70 + $17.50 = $87.50. Profit: $87.50 * 0.40 = $35.00 (a $7 increase). This leverages price sensitivity. * **Product D (10% Off for Email Subscribers):** Offer a 10% discount on Product D for email subscribers (targeting professionals). *Estimated Impact:* Increase unit sales from 15 to 18. Revenue: 18 * $6.00 = $108. Profit: $108 * 0.35 = $37.80 (a $6.30 increase). This appeals to the professional demographic's value for convenience and targeted offers. **Reasoning:** * **Product C:** Addressing the overstock is critical to minimize holding costs ($30/month). The combination of price reduction, bundling, and targeted marketing aims to quickly move inventory. * **Product B:** Young adults are highly price sensitive. BOGO promotions are effective at driving volume. Instagram is the preferred channel for this demographic. * **Product D:** Professionals respond to targeted promotions. Email is a suitable channel for reaching this demographic. A moderate discount incentivizes purchase without devaluing the product. **3. Marketing Optimization Recommendations:** **Channel Allocation:** * **Instagram: $120 (48%):** Instagram is currently performing better and is the primary channel for reaching the young adult demographic (Product B). * **Email: $80 (32%):** Email is effective for reaching the professional demographic (Products C & D). * **Weekend Promotions (In-Store Signage): $0 (0%):** Focus budget on digital channels with better targeting capabilities. In-store promotion is assumed to have minimal cost. **Product Prioritization:** * **Instagram ($120):** Primarily focus on Product B (BOGO promotion). Ad copy: "🔥 BOGO Alert! 🔥 Stock up on your favorites! Buy one Product B, get one 50% off! Limited time only! #ProductB #Deals #YoungAdults" Also, include some Product D ads targeting the younger end of the professional demographic. * **Email ($80):** Focus on Product C (highlighting premium quality and limited availability) and Product D (10% off for subscribers). Subject lines: "Exclusive Offer: Premium Product C - Limited Stock!" and "Save 10% on Product D - For Our Valued Subscribers!". * **Weekend Promotions:** In-store signage promoting the Product C bundle with Product A. **KPIs:** * **Conversion Rate (Instagram):** Track the percentage of Instagram ad clicks that result in a purchase. This measures ad effectiveness. * **Email Open Rate & Click-Through Rate:** Monitor these metrics to assess the engagement and effectiveness of email campaigns. This measures the relevance of subject lines and content. **Estimated Overall Profit Increase:** * Product B: +$7.00 * Product D: +$6.30 * Product C: +$16.00 (from price reduction and bundles) * **Total Estimated Profit Increase: $29.30** This represents a 34.6% increase in profit, exceeding the 10% target. Continuous monitoring of KPIs and adjustments to the strategy will be crucial for sustained improvement.
Analysis of the AI-enhanced prompt response¶
The AI-generated answer stands out by delivering execution-ready depth the human version lacks:
- Quantified impact & ROI – forecasts unit lifts and rolls them into a +34 % profit gain, turning ideas into numbers managers can judge
- Actionable constraints – assigns a $200 channel budget, splits spending, and names KPIs, giving a plug-and-play operating plan
- Contextual targeting – ties every promo to a demographic and to inventory pressure, showing clear "why this, why now" logic
- Concise orientation – opens with a single P&L table and ranked profit list so readers grasp the situation at a glance
- Notable caveat – a bundle-margin math slip highlights the need to prompt for intermediate calculations and self-checks
The strongest prompt may likely be hybrid style: AI-refined for structure and numeric rigor, augmented with human-driven goals for brevity and inventive marketing flair.
Conclusion¶
This side-by-side comparison demonstrates how the quality and specificity of a prompt directly influence the depth, utility, and strategic value of an LLM's output:
- Bad prompt - minimal data and vague instructions yield only superficial insights—no clear direction or actionable strategies
- Better prompt - adding pricing details and specific tasks (like calculating revenue or ranking products) results in more concrete analysis and targeted recommendations
- Best prompt - providing comprehensive context—including profit margins, demographics, inventory challenges, and explicit formatting instructions—empowers the model to deliver nuanced, highly actionable advice aligned with real business needs
- AI‑enhanced prompt — layering on a defined 3‑to‑6‑month time horizon, a fixed $2,000 marketing budget, ranked priorities, risk/trade‑off notes, and requests for supporting calculations guides the model to provide an even more operationally realistic, budget‑aware, and immediately implementable plan of action
Key takeaways for effective prompt engineering:
- Provide relevant context - include all essential data (pricing, margins, customer segments) to enable deeper analysis
- Specify instructions clearly - outline the tasks, format, and reasoning style (e.g., step-by-step) you want the model to follow
- Articulate business constraints and goals - highlight challenges (e.g., excess inventory, limited budget) to guide strategic recommendations
- Structure the output requirements - break down the response into clear, logical sections (analysis, recommendations, marketing, etc.)
- Iterate for best results - incrementally refining prompts yields exponentially better outcomes—invest time upfront for far greater business value
By enriching prompts with thorough details and well-defined objectives, you unlock the full potential of LLMs to generate accurate, context-aware, and immediately applicable insights.