英文:
GPT3 fine tuned model returns additional questions and answers
问题
I have fine tuned a custom dataset using GPT-3. 我已经使用GPT-3对一个自定义数据集进行了微调。
I created a simple program to take user input (a question) and return the correct response. 我创建了一个简单的程序,用于接受用户输入(问题)并返回正确的回答。
The program works, however it returns additional question and answers from the dataset I uploaded to the model. 程序可以运行,但它返回了我上传到模型的数据集中的额外问题和答案。
I tried to reduce the max tokens cap and have set the temperature to 0, but I cannot seem to figure out how to stop the program from returning the additional questions and answers. 我尝试减小最大标记数限制并将温度设置为0,但似乎无法找出如何阻止程序返回额外的问题和答案。
Has anyone encountered this problem and if so how can I fix it? 是否有人遇到过这个问题,如果有,我该如何解决它?
Here is my code: 这是我的代码:
英文:
I have fine tuned a custom dataset using GPT3. I created a simple program to take user input (a question) and return the correct response. The program works, however it returns additional question and answers from the dataset I uploaded to the model.
I tried to reduce the max tokens cap and have set the temperature to 0, but I cannot seem to figure out how to stop the program from returning the additional questions and answers. Has anyone encountered this problem and if so how can I fix it?
Here is my code:
import openai
openai.api_key = "MY_API_KEY"
def respond(prompt):
completions = openai.Completion.create(
engine="MY_FINED_TUNED_MODEL",
prompt=prompt,
max_tokens=50,
n=1,
stop=None,
temperature=0,
)
message = completions.choices[0].text
return message
while True:
prompt = input("Enter your question: ")
if prompt.lower() == "end":
break
response = respond(prompt)
print(response)
答案1
得分: 1
你可以通过在提示中提供更明确的细节,甚至在提示中提供一次性或多次性的示例来处理这个问题。
例如,假设这是一个计算机商店的问答机器人:
question = 'Do you sell computers?'
prompt = f"""充当问答人工智能。您将提供一个问题,您应该根据您的微调数据来回应。根据问题提供最合适的答案。提供一个单一的答案。不提供额外的问题和答案。
示例问题:
Do you sell cars?
示例回答:
抱歉,我们是一家计算机零售商,只销售计算机。
问题:
{question}
回答:"""
根据模型的响应,您还可以使用停止序列。例如,使用\r\n将导致模型在生成新行时停止响应。
如果您提供有关从模型获取的问题和回答类型的更多详细信息,我可以为您提供更好的提示。
英文:
You can handle this by providing more explicit details to the prompt and even providing one-shot or many-shot examples in the prompt.
For example say this was a Q&A bot for a computer store:
question = 'Do you sell computers?'
prompt = f"""Act as a question and answer AI. You will be provided with a question and you should respond based on your fine-tuning data. Provide the most appropriate answer to the question. Provide a single answer. Do not provide additional questions and answers.
Example question:
Do you sell cars?
Example response:
Sorry, we are a computer retailer and only sell computers.
Question:
{question}
Response:"""
Depending on your responses from the model you can also use a stop sequence. For example using \r\n will cause the model to stop responding when it generates a new line.
If you provide more details of the types of questions and responses you are getting from the model I can provide you a better prompt.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论