![](https://crypto4nerd.com/wp-content/uploads/2023/07/1qKMWv43x9mVJqoXnuKfbqA.png)
I recently found myself sitting on a small dataset of smartphone specifications. Each entry contained the product’s title, manufacturer, and a few attributes like RAM and storage. However, I realized I needed to add an “Operating System” (OS) attribute to each entry. Given the tedious nature of this task, I thought, “Wouldn’t it be great if I could get an AI to do this for me?”
// Data and examples at the end of the article
Enter OpenAI’s GPT-4, a state-of-the-art language model that has proven to be an incredibly versatile tool capable of completing a wide array of tasks. I decided to test it out in the OpenAI Playground with a simple system message:
“You’re a very helpful task completion AI Assistant specializing in logic and problem solving. Always lay down your thought process, reasoning and analysis, step-by-step.”
## The Magic of a Good Prompt
At first, I simply asked the AI to add the OS to each entry in the dataset. The response was good, but I noticed that the quality and accuracy of the responses improved significantly when I finished each of my prompts with the same phrase sequence: “lay down your thought process, reasoning and analysis, step-by-step.”
It’s fascinating to observe that the AI does not just process data mechanically. It reasons and explains its steps, lending an element of transparency to its actions. This is crucial because it allows users to understand and trust the AI’s output.
## Spotting Inconsistencies
To push the boundaries, I introduced an inconsistency in the dataset: I included a device whose listed RAM in the title didn’t match the RAM in its attributes. I asked the AI if it could spot any errors. Remarkably, it identified the discrepancy and suggested a correction based on its analysis of the input.
In one of my attempts, the AI even autocorrected the inconsistency without being explicitly asked, which was a pleasant surprise. However, I wasn’t able to reproduce this auto-correction, and on reflection, I realized that having consistent input-output behavior is better for most use cases.
## Conclusion: Patience and Clarity Yield Results
This experiment underscored the importance of crafting good prompts for AI. The addition of the phrase “lay down your thought process, reasoning and analysis, step-by-step” not only improved the quality of the responses but also provided a detailed explanation of the AI’s decision-making process.
The downside is that the responses can get lengthy and appear cluttered. However, this “clutter” is necessary if the goal is to obtain high-quality and accurate responses.
In the end, the key is patience. It might take a few attempts to craft the perfect prompt, but the results are well worth the effort. As AI continues to evolve, it’s exciting to explore its potential and push the boundaries of what it can achieve.
// the initial dataset
{"title":"Huawei P Smart Z (64GB) Midnight Black","manufacturer":"Huawei","attributes":[{"attribute_name":"RAM","attribute_value":"4GB"},{"attribute_name":"Storage","attribute_value":"64GB"}]}
{"title":"Apple iPhone 12 Pro (128GB) Gold","manufacturer":"Apple","attributes":[{"attribute_name":"RAM","attribute_value":"6GB"},{"attribute_name":"Storage","attribute_value":"128GB"}]}
{"title":"Apple iPhone 11 (64GB) Yellow","manufacturer":"Apple","attributes":[{"attribute_name":"RAM","attribute_value":"4GB"},{"attribute_name":"Storage","attribute_value":"64GB"}]}
{"title":"Samsung Galaxy Note 20 Ultra (256GB) Mystic Bronze","manufacturer":"Samsung","attributes":[{"attribute_name":"RAM","attribute_value":"12GB"},{"attribute_name":"Storage","attribute_value":"256GB"}]}
{"title":"Samsung Galaxy S20 (128GB) Cosmic Gray","manufacturer":"Samsung","attributes":[{"attribute_name":"RAM","attribute_value":"8GB"},{"attribute_name":"Storage","attribute_value":"128GB"}]}
{"title":"Samsung Galaxy S21+ 5G (128GB) Phantom Violet","manufacturer":"Samsung","attributes":[{"attribute_name":"RAM","attribute_value":"8GB"},{"attribute_name":"Storage","attribute_value":"128GB"}]}
{"title":"Apple iPhone 12 Mini (128GB) Black","manufacturer":"Apple","attributes":[{"attribute_name":"RAM","attribute_value":"4GB"},{"attribute_name":"Storage","attribute_value":"128GB"}]}
{"title":"Huawei Nova 5T (6GB/128GB) Black","manufacturer":"Huawei","attributes":[{"attribute_name":"RAM","attribute_value":"6GB"},{"attribute_name":"Storage","attribute_value":"128GB"}]}
{"title":"Apple iPhone XR (64GB) White","manufacturer":"Apple","attributes":[{"attribute_name":"RAM","attribute_value":"3GB"},{"attribute_name":"Storage","attribute_value":"64GB"}]}
{"title":"Samsung Galaxy A21s (128GB) Black","manufacturer":"Samsung","attributes":[{"attribute_name":"RAM","attribute_value":"4GB"},{"attribute_name":"Storage","attribute_value":"128GB"}]}
{"title":"Samsung Galaxy S20 5G (128GB) Cloud White","manufacturer":"Samsung","attributes":[{"attribute_name":"RAM","attribute_value":"12GB"},{"attribute_name":"Storage","attribute_value":"128GB"}]}
{"title":"Samsung Galaxy A21s (32GB) Red","manufacturer":"Samsung","attributes":[{"attribute_name":"RAM","attribute_value":"3GB"},{"attribute_name":"Storage","attribute_value":"32GB"}]}
{"title":"Apple iPhone 12 Mini (256GB) Black","manufacturer":"Apple","attributes":[{"attribute_name":"RAM","attribute_value":"4GB"},{"attribute_name":"Storage","attribute_value":"256GB"}]}
{"title":"Apple iPhone 11 Pro (256GB) Gold","manufacturer":"Apple","attributes":[{"attribute_name":"RAM","attribute_value":"4GB"},{"attribute_name":"Storage","attribute_value":"256GB"}]}
{"title":"Apple iPhone 8 Plus (64GB) Silver","manufacturer":"Apple","attributes":[{"attribute_name":"RAM","attribute_value":"3GB"},{"attribute_name":"Storage","attribute_value":"64GB"}]}
{"title":"Samsung Galaxy Note 8 (64GB) Midnight Black","manufacturer":"Samsung","attributes":[{"attribute_name":"RAM","attribute_value":"6GB"},{"attribute_name":"Storage","attribute_value":"64GB"}]}
{"title":"Apple iPhone XS Max (256GB) Space Gray","manufacturer":"Apple","attributes":[{"attribute_name":"RAM","attribute_value":"4GB"},{"attribute_name":"Storage","attribute_value":"256GB"}]}
{"title":"Samsung Galaxy S20 FE (128GB) Cloud Lavender","manufacturer":"Samsung","attributes":[{"attribute_name":"RAM","attribute_value":"6GB"},{"attribute_name":"Storage","attribute_value":"128GB"}]}
{"title":"Samsung Galaxy A31 (128GB) Prism Crush Blue","manufacturer":"Samsung","attributes":[{"attribute_name":"RAM","attribute_value":"4GB"},{"attribute_name":"Storage","attribute_value":"128GB"}]}
{"title":"Samsung Galaxy A21s (32GB) White","manufacturer":"Samsung","attributes":[{"attribute_name":"RAM","attribute_value":"3GB"},{"attribute_name":"Storage","attribute_value":"32GB"}]}
{"title":"Xiaomi Poco X5 Pro 5G Dual SIM (8GB/256GB) Κίτρινο","manufacturer":"Xiaomi","attributes":[{"attribute_name":"RAM","attribute_value":"8GB"},{"attribute_name":"Storage","attribute_value":"256GB"}]}
{"title":"Xiaomi Poco F5 5G Dual SIM (12GB/256GB) Μαύρο","manufacturer":"Xiaomi","attributes":[{"attribute_name":"RAM","attribute_value":"8GB"},{"attribute_name":"Storage","attribute_value":"256GB"}]}
## Example prompt and response #1
USER: Please read the data carefully and find a combination of RAM and Storage options that I could use that will return >1 documents. Please laydown your thought process in analyzing and reasoning step-by-step.
ASSISTANT: Let’s take a closer look at the dataset.
1. First, I’ll examine the “RAM” attribute and the “Storage” attribute across all the products.
2. For the “RAM” attribute, the common values include “4GB”, “6GB”, “8GB”, and “12GB”.
3. For the “Storage” attribute, the common values include “64GB”, “128GB”, and “256GB”.
The goal is to find a combination of “RAM” and “Storage” that will match more than one product.
We can start by examining the most common values. Given the dataset’s size and variability, it’s reasonable to start with smaller “RAM” and larger “Storage” values, as these are more likely to be common.
The combination of “RAM”=”4GB” and “Storage”=”128GB” seems like it could be a potential candidate.
Let’s check:
– Apple iPhone 12 Mini (128GB) Black has “RAM”=”4GB” and “Storage”=”128GB”.
– Samsung Galaxy A21s (128GB) Black also has “RAM”=”4GB” and “Storage”=”128GB”.As such, the combination of “RAM”=”4GB” and “Storage”=”128GB” will match these two products at least, meaning your query would return more than one document with these values.
The thought process here was to identify common attribute values and then check the dataset for products that match those values. Since your dataset is relatively small, manual checking is feasible. However, in a larger dataset, you might want to use aggregate functions or similar methods to identify the most common attribute values.
## Example prompt and response #2
USER: Can you spot any mistakes in the dataset? Please lay down your thought process, reasoning and analysis, step-by-step.
ASSISTANT: Sure, let’s go through the dataset step by step and analyze for potential errors or inconsistencies.
1. **Syntax and Formatting**: The first thing to check is the JSON syntax and structure. It seems consistent across all entries, with each object having a “title”, “manufacturer”, and “attributes” key. The “attributes” key contains an array of attribute objects, each with “attribute_name” and “attribute_value” keys. There does not appear to be any syntax errors or missing values.
2. **Consistency of Attribute Names**: All attribute names are consistent across entries — “RAM”, “Storage”, and “OS”.
3. **Consistency of Manufacturers**: The manufacturer names are consistent and seem to match the product titles. There are no spelling errors or inconsistencies in the manufacturer names.
4. **Consistency in Titles**: The titles seem to accurately represent the details of each product, including the manufacturer, product name, and storage capacity.
5. **Logical Consistency in Attributes**: The attribute values seem logical. For example, the RAM values are within the usual range for smartphones, and the storage values match those in the titles. The OS values are correct based on the manufacturers.
6. **Data Types**: The data types are consistent for each attribute. All attribute names and values are strings, which is the expected format.
However, there’s a potential issue with the last two entries:
“`
{“title”:”Xiaomi Poco X5 Pro 5G Dual SIM (8GB/256GB) Κίτρινο”,”manufacturer”:”Xiaomi”,”attributes”:[{“attribute_name”:”RAM”,”attribute_value”:”8GB”},{“attribute_name”:”Storage”,”attribute_value”:”256GB”},{“attribute_name”:”OS”,”attribute_value”:”Android”}]}
{“title”:”Xiaomi Poco F5 5G Dual SIM (12GB/256GB) Μαύρο”,”manufacturer”:”Xiaomi”,”attributes”:[{“attribute_name”:”RAM”,”attribute_value”:”8GB”},{“attribute_name”:”Storage”,”attribute_value”:”256GB”},{“attribute_name”:”OS”,”attribute_value”:”Android”}]}
“`
In the title, the second entry says it has 12GB of RAM, but in the attributes, it says it has 8GB. This inconsistency should be corrected based on the actual product specifications.In the absence of any further data or context, this is the only potential error I have identified.
// and the corrected and enhanced final dataset// ASSISTANT: Understood, here's the complete dataset with the generalized "OS" attribute:
```json
{"title":"Huawei P Smart Z (64GB) Midnight Black","manufacturer":"Huawei","attributes":[{"attribute_name":"RAM","attribute_value":"4GB"},{"attribute_name":"Storage","attribute_value":"64GB"},{"attribute_name":"OS","attribute_value":"Android"}]}
{"title":"Apple iPhone 12 Pro (128GB) Gold","manufacturer":"Apple","attributes":[{"attribute_name":"RAM","attribute_value":"6GB"},{"attribute_name":"Storage","attribute_value":"128GB"},{"attribute_name":"OS","attribute_value":"iOS"}]}
{"title":"Apple iPhone 11 (64GB) Yellow","manufacturer":"Apple","attributes":[{"attribute_name":"RAM","attribute_value":"4GB"},{"attribute_name":"Storage","attribute_value":"64GB"},{"attribute_name":"OS","attribute_value":"iOS"}]}
{"title":"Samsung Galaxy Note 20 Ultra (256GB) Mystic Bronze","manufacturer":"Samsung","attributes":[{"attribute_name":"RAM","attribute_value":"12GB"},{"attribute_name":"Storage","attribute_value":"256GB"},{"attribute_name":"OS","attribute_value":"Android"}]}
{"title":"Samsung Galaxy S20 (128GB) Cosmic Gray","manufacturer":"Samsung","attributes":[{"attribute_name":"RAM","attribute_value":"8GB"},{"attribute_name":"Storage","attribute_value":"128GB"},{"attribute_name":"OS","attribute_value":"Android"}]}
{"title":"Samsung Galaxy S21+ 5G (128GB) Phantom Violet","manufacturer":"Samsung","attributes":[{"attribute_name":"RAM","attribute_value":"8GB"},{"attribute_name":"Storage","attribute_value":"128GB"},{"attribute_name":"OS","attribute_value":"Android"}]}
{"title":"Apple iPhone 12 Mini (128GB) Black","manufacturer":"Apple","attributes":[{"attribute_name":"RAM","attribute_value":"4GB"},{"attribute_name":"Storage","attribute_value":"128GB"},{"attribute_name":"OS","attribute_value":"iOS"}]}
{"title":"Huawei Nova 5T (6GB/128GB) Black","manufacturer":"Huawei","attributes":[{"attribute_name":"RAM","attribute_value":"6GB"},{"attribute_name":"Storage","attribute_value":"128GB"},{"attribute_name":"OS","attribute_value":"Android"}]}
{"title":"Apple iPhone XR (64GB) White","manufacturer":"Apple","attributes":[{"attribute_name":"RAM","attribute_value":"3GB"},{"attribute_name":"Storage","attribute_value":"64GB"},{"attribute_name":"OS","attribute_value":"iOS"}]}
{"title":"Samsung Galaxy A21s (128GB) Black","manufacturer":"Samsung","attributes":[{"attribute_name":"RAM","attribute_value":"4GB"},{"attribute_name":"Storage","attribute_value":"128GB"},{"attribute_name":"OS","attribute_value":"Android"}]}
{"title":"Samsung Galaxy S20 5G (128GB) Cloud White","manufacturer":"Samsung","attributes":[{"attribute_name":"RAM","attribute_value":"12GB"},{"attribute_name":"Storage","attribute_value":"128GB"},{"attribute_name":"OS","attribute_value":"Android"}]}
{"title":"Samsung Galaxy A21s (32GB) Red","manufacturer":"Samsung","attributes":[{"attribute_name":"RAM","attribute_value":"3GB"},{"attribute_name":"Storage","attribute_value":"32GB"},{"attribute_name":"OS","attribute_value":"Android"}]}
{"title":"Apple iPhone 12 Mini (256GB) Black","manufacturer":"Apple","attributes":[{"attribute_name":"RAM","attribute_value":"4GB"},{"attribute_name":"Storage","attribute_value":"256GB"},{"attribute_name":"OS","attribute_value":"iOS"}]}
{"title":"Apple iPhone 11 Pro (256GB) Gold","manufacturer":"Apple","attributes":[{"attribute_name":"RAM","attribute_value":"4GB"},{"attribute_name":"Storage","attribute_value":"256GB"},{"attribute_name":"OS","attribute_value":"iOS"}]}
{"title":"Apple iPhone 8 Plus (64GB) Silver","manufacturer":"Apple","attributes":[{"attribute_name":"RAM","attribute_value":"3GB"},{"attribute_name":"Storage","attribute_value":"64GB"},{"attribute_name":"OS","attribute_value":"iOS"}]}
{"title":"Samsung Galaxy Note 8 (64GB) Midnight Black","manufacturer":"Samsung","attributes":[{"attribute_name":"RAM","attribute_value":"6GB"},{"attribute_name":"Storage","attribute_value":"64GB"},{"attribute_name":"OS","attribute_value":"Android"}]}
{"title":"Apple iPhone XS Max (256GB) Space Gray","manufacturer":"Apple","attributes":[{"attribute_name":"RAM","attribute_value":"4GB"},{"attribute_name":"Storage","attribute_value":"256GB"},{"attribute_name":"OS","attribute_value":"iOS"}]}
{"title":"Samsung Galaxy S20 FE (128GB) Cloud Lavender","manufacturer":"Samsung","attributes":[{"attribute_name":"RAM","attribute_value":"6GB"},{"attribute_name":"Storage","attribute_value":"128GB"},{"attribute_name":"OS","attribute_value":"Android"}]}
{"title":"Samsung Galaxy A31 (128GB) Prism Crush Blue","manufacturer":"Samsung","attributes":[{"attribute_name":"RAM","attribute_value":"4GB"},{"attribute_name":"Storage","attribute_value":"128GB"},{"attribute_name":"OS","attribute_value":"Android"}]}
{"title":"Samsung Galaxy A21s (32GB) White","manufacturer":"Samsung","attributes":[{"attribute_name":"RAM","attribute_value":"3GB"},{"attribute_name":"Storage","attribute_value":"32GB"},{"attribute_name":"OS","attribute_value":"Android"}]}
{"title":"Xiaomi Poco X5 Pro 5G Dual SIM (8GB/256GB) Κίτρινο","manufacturer":"Xiaomi","attributes":[{"attribute_name":"RAM","attribute_value":"8GB"},{"attribute_name":"Storage","attribute_value":"256GB"},{"attribute_name":"OS","attribute_value":"Android"}]}
{"title":"Xiaomi Poco F5 5G Dual SIM (12GB/256GB) Μαύρο","manufacturer":"Xiaomi","attributes":[{"attribute_name":"RAM","attribute_value":"12GB"},{"attribute_name":"Storage","attribute_value":"256GB"},{"attribute_name":"OS","attribute_value":"Android"}]}
```
// ASSISTANT: I have added the "OS" attribute to each object in the dataset, with the value "iOS" for products manufactured by Apple and "Android" for products manufactured by Huawei, Samsung, and Xiaomi.
I diff-checked the contents and the only difference was the addition of the OS and the correction in the last entry.