Prompt Engineering - Generative AI

Generative AI systems require detailed input context to produce accurate responses from Large Language Models (LLMs). To achieve this, the AI engineer can write prompts through an iterative process. This is called prompt engineering .


Case Study 1 - Statistical Analysis Based on Customer Reviews and Ratings

An Italian restaurant wants to improve its service and food based on customer reviews. The task is to perform statistical analysis to understand these reviews. A summary of all the reviews will also be provided to the restaurant owner.


Step 1

Gathering customer reviews from the restaurant's website can be done using a Python HTML parser, Beautiful Soup. This software is useful for extracting data from HTML (web scraping). Due to website copyright restrictions, a prompt was written to generate 50 reviews. The prompt was refined to produce realistic-sounding responses - both positive and negative. The final prompt, after iterative process, is shown below.

Prompt

Step 2

A prompt was used to generate a tally of ratings. In this case, a histogram is the most suitable plot to represent the tally. The histogram was plotted using the Python library, Matplotlib.

Histogram1

Step 3

A prompt was used to generate tallies based on service and food. The output was then used to create histogram plots to summarize the tallies. Again, these histograms were plotted using the Python library, Matplotlib . Note: The tally doesn’t have to sum up to 50 because some reviews only comment on food or service.

Histogram2.1
Histogram2.1

Step 4

A prompt was used to generate a summary of the positive and negative reviews. This summary was then passed on to the owner to help improve their service and food.