Trying to get GPT-3 to analyse a CSV-file

Hi!

I have a CSV-file with about 150 reviews of a hotel with columns such as “Rating”, “Review” and “Date”. I want GPT-3 to look at the data and perform things like summarizing the reviews with ratings of 2 or below and those with more than 3 and class them as “good” or “bad”. I can manage to go through each line and summarize some of them, but too many and we go above the token limit. Is there any way to have it look at the entire CSV-file and not just one row at a time and draw conclusions? Currently I have this code for 1 star reviews:

one_star_reviews = df[df[‘Rating’] == 1][‘Description’]
keywords =
reviews =
for review in one_star_reviews:
response = openai.Completion.create(
engine=“text-ada-001”,
prompt=f"Summarize the following review: {review}",
temperature=0.5,
max_tokens=1024,
n=1,
stop=None,
)
keywords.append(response.choices[0].text.strip())

keywords2 =
response2 = openai.Completion.create(
engine=“text-ada-001”,
prompt=f"Based on the {keywords}, write a short essay on the status of the reviews",
temperature=0.5,
max_tokens=1024,
n=1,
stop=None,
)
keywords2.append(response2.choices[0].text.strip())

1 Like