0

This happens to probably 10% of responses I get. For whatever reason, the last bits of my prompt somehow spill into it, at the start of it. Like there will be a period, or a question mark, or sometimes a few of the last letters from the prompt, that get removed from the prompt, and somehow find their way into BOTH the response that gets printed inside of the Visual Studio Code terminal, AND in the outputted version that gets written to a corresponding Excel spreadsheet.

Any reason why this might happen?

Some example responses:

.

Most apples are colored red.

Also

?

Most rocks are colored gray.

Another example:

for it.

Most oceans are colored blue.

The period, the question mark, " for it" somehow get transposed FROM the end of the prompt, and tacked onto the response. And they even get removed from the prompt that was originally in the Excel spreadsheet to begin with.

Could this be a bug with xlsxwriter? open ai? Some combo of both?

Code here:

import xlsxwriter
import openpyxl

import os
import openai

filename = f'testing-openai-gpt3-requests-v1.xlsx'
wb = openpyxl.load_workbook(filename, read_only=False)
sheet = wb.active

# print("starting number of ideas is:")
# print(sheet.max_row)

for x in range(sheet.max_row):
    c = sheet.cell(row = x+1, column = 1)
    # print(c.value) 

    myCurrentText = c.value 
    myCurrentPrompt = "What is the color of most of the following objects: " + myCurrentBusinessIdea

    openai.api_key = [none of your business]

    response = openai.Completion.create(
    model = "text-davinci-003",
    prompt = myCurrentPrompt,
    max_tokens = 1000,
    )

    TheOutputtedSummary = response['choices'][0]['text']

    print(TheOutputtedSummary)
    sheet.cell(row = x+1, column = 6).value = TheOutputtedSummary


wb.save(str(filename))
print('All finished!')
king_anton
  • 167
  • 8

1 Answers1

0

GPT-3 is a powerful language model capable of generating human-like text based on the input provided. However, it is important to ensure that the input text is clear and well-formatted in order to get the desired output.

One way to avoid issues with incomplete sentences is to ensure that your input text always ends with a full stop or other appropriate punctuation. This can help GPT-3 understand that the input text is complete, and prevent it from generating text that appears to be part of the input.

Here's how I solved the issue on a project I worked on. The project is a website featuring Amazon products, and it includes descriptions of the products based on reviews from purchasers.

It is important to be as clear as possible when generating a prompt for GPT-3, as this can help ensure that the model produces the desired output. Here's an example of a clear and well-formatted prompt:

"I will ask you a question and provide you with a list of objects.

Please tell me the colour of most of the following objects:

[dynamic text]

END OF THE LIST."

  • For whatever reason, this seemed to solve the issue: for the "stop:" parameter? I inserted some super unique character strings "||||1|", and I would append that to the end of my text strings. It's probably not the ideal technical fix, but it worked to effectively get me the correctly formatted outputs. – king_anton Jan 09 '23 at 21:06
  • You could also have used the "END OF THE LIST." string. GPT-3 is capable of understanding it. – Antonio Ercole De Luca Jan 11 '23 at 19:39