me = """Give me a table of tablet specifications for ten popular tablets.
Include the following attributes: price, memory, storage, color, brand, battery life"""
# ChatGPT:
data = """
Brand,Model,Price,Memory,Storage,Color,Battery Life
Apple,iPad Pro,$999,8GB,128GB,Silver,10 hours
Samsung,Galaxy Tab S7,$649,6GB,128GB,Black,15 hours
Microsoft,Surface Pro 7,$749,8GB,128GB,Platinum,10.5 hours
Amazon,Fire HD 10,$149,3GB,32GB,Black,12 hours
Apple,iPad Air,$599,4GB,64GB,Space Gray,10 hours
Lenovo,Tab P11 Pro,$499,6GB,128GB,Slate Grey,15 hours
Samsung,Galaxy Tab A7,$229,3GB,32GB,Gold,13 hours
Google,Pixel Slate,$799,8GB,64GB,Midnight Blue,12 hours
Huawei,MediaPad M5,$349,4GB,64GB,Champagne Gold,11 hours
Asus,ZenPad 3S 10,$299,4GB,64GB,Silver,10 hours
"""
This is a reduction of the bulk prompting process as much as possible. Assuming you have a clean structured dataset like the one below, and of course assuming these are related items, then it becomes easy to create a prompt template to create prompts in bulk and scale the process of creating articles, product descriptions, etc.
Get some data
Create a DataFrame
from io import StringIO
import pandas as pd
df = pd.read_csv(StringIO(data))
df.columns = df.columns.str.lower()
df
brand | model | price | memory | storage | color | battery life | |
---|---|---|---|---|---|---|---|
0 | Apple | iPad Pro | $999 | 8GB | 128GB | Silver | 10 hours |
1 | Samsung | Galaxy Tab S7 | $649 | 6GB | 128GB | Black | 15 hours |
2 | Microsoft | Surface Pro 7 | $749 | 8GB | 128GB | Platinum | 10.5 hours |
3 | Amazon | Fire HD 10 | $149 | 3GB | 32GB | Black | 12 hours |
4 | Apple | iPad Air | $599 | 4GB | 64GB | Space Gray | 10 hours |
5 | Lenovo | Tab P11 Pro | $499 | 6GB | 128GB | Slate Grey | 15 hours |
6 | Samsung | Galaxy Tab A7 | $229 | 3GB | 32GB | Gold | 13 hours |
7 | Pixel Slate | $799 | 8GB | 64GB | Midnight Blue | 12 hours | |
8 | Huawei | MediaPad M5 | $349 | 4GB | 64GB | Champagne Gold | 11 hours |
9 | Asus | ZenPad 3S 10 | $299 | 4GB | 64GB | Silver | 10 hours |
Create a prompt template
It is important to keep in mind a few things:
- The names of the variables inserted in curly braces should be the same as the names of the columns in the
DataFrame
(case sensitive). - The sequence has to also be the same.
- In a real-life situation, you will probably need to do more processing to cater for missing data and/or special cases.
prompt_template = """
Create a product description for a tablet, encouraging the reader to buy it.
Focus on the brand: {brand}.
Talk about the model: {model}.
Include the price: {price}.
Mention memory: {memory} and storage: {storage}.
Tell the user what color is is: {color}.
Talk about its battery life: {battery life}
"""
A loop to generate the prompts dynamically
Create a product description for a tablet, encouraging the reader to buy it.
Focus on the brand: Apple.
Talk about the model: iPad Pro.
Include the price: $999.
Mention memory: 8GB and storage: 128GB.
Tell the user what color it is: Silver.
Talk about its battery life: 10 hours
Create a product description for a tablet, encouraging the reader to buy it.
Focus on the brand: Samsung.
Talk about the model: Galaxy Tab S7.
Include the price: $649.
Mention memory: 6GB and storage: 128GB.
Tell the user what color it is: Black.
Talk about its battery life: 15 hours
Create a product description for a tablet, encouraging the reader to buy it.
Focus on the brand: Microsoft.
Talk about the model: Surface Pro 7.
Include the price: $749.
Mention memory: 8GB and storage: 128GB.
Tell the user what color it is: Platinum.
Talk about its battery life: 10.5 hours
Create a product description for a tablet, encouraging the reader to buy it.
Focus on the brand: Amazon.
Talk about the model: Fire HD 10.
Include the price: $149.
Mention memory: 3GB and storage: 32GB.
Tell the user what color it is: Black.
Talk about its battery life: 12 hours
Create a product description for a tablet, encouraging the reader to buy it.
Focus on the brand: Apple.
Talk about the model: iPad Air.
Include the price: $599.
Mention memory: 4GB and storage: 64GB.
Tell the user what color it is: Space Gray.
Talk about its battery life: 10 hours
Create a product description for a tablet, encouraging the reader to buy it.
Focus on the brand: Lenovo.
Talk about the model: Tab P11 Pro.
Include the price: $499.
Mention memory: 6GB and storage: 128GB.
Tell the user what color it is: Slate Grey.
Talk about its battery life: 15 hours
Create a product description for a tablet, encouraging the reader to buy it.
Focus on the brand: Samsung.
Talk about the model: Galaxy Tab A7.
Include the price: $229.
Mention memory: 3GB and storage: 32GB.
Tell the user what color it is: Gold.
Talk about its battery life: 13 hours
Create a product description for a tablet, encouraging the reader to buy it.
Focus on the brand: Google.
Talk about the model: Pixel Slate.
Include the price: $799.
Mention memory: 8GB and storage: 64GB.
Tell the user what color it is: Midnight Blue.
Talk about its battery life: 12 hours
Create a product description for a tablet, encouraging the reader to buy it.
Focus on the brand: Huawei.
Talk about the model: MediaPad M5.
Include the price: $349.
Mention memory: 4GB and storage: 64GB.
Tell the user what color it is: Champagne Gold.
Talk about its battery life: 11 hours
Create a product description for a tablet, encouraging the reader to buy it.
Focus on the brand: Asus.
Talk about the model: ZenPad 3S 10.
Include the price: $299.
Mention memory: 4GB and storage: 64GB.
Tell the user what color it is: Silver.
Talk about its battery life: 10 hours