【问题标题】:openai using python, returned length problem in "text-davinci-002" modelopenai using python, returned length problem in \"text-davinci-002\" model
【发布时间】:2022-12-28 02:52:43
【问题描述】:

I am trying to use"text-davinci-002"model using"openai". The returned text is a single sentence while the same sentence returns a full text in openAI official example. This is the code used:

response = openai.Completion.create(
            model="email to ask for a promotion",
            prompt=userPrompt,
            temperature=0.76
            )

The output of this code is: *Hello [Employer],

I would like to request a promotion*

while the same sentence in OpenAI website here outputs: * Hello [Employer],

I would like to request a promotion to the position of [position you want]. I have been with the company for [amount of time] and I feel that I have the experience and qualifications needed for the position.*

Thank you in advance

【问题讨论】:

  • The GPT-3 API in its JSON returns a finish_reason field (e.g. "stop"); what does that field say for you?

标签: python openai gpt-3


【解决方案1】:
import openai
openai.api_key = "YOUR_API_KEY"
    
model_name = "text-davinci-002"
prompt = "email to ask for a promotion"

completion = openai.Completion.create(
    model=model_name,
    prompt=prompt,
    n=1,
    stop=None,
    temperature=0.5,
    max_tokens=150
)

generated_text = completion.choices[0].text
print(generated_text)

Model must be a correct model name, in your case "text-davinci-002"

【讨论】:

    猜你喜欢
    • 2022-12-26
    • 2022-12-27
    • 2022-12-02
    • 1970-01-01
    • 2017-04-07
    • 2022-04-20
    • 2022-12-01
    • 2021-02-13
    • 2022-12-27
    相关资源
    最近更新 更多