Closed jfoliveiraramos closed 1 year ago
Couple of things.
Add a timeout to your service.
service = new OpenAiService(API_KEY, Duration.ofSeconds(45));
Switch to the newer davinci model.
.model("text-davinci-003")
You probably want to add stops to your submission. Change to fit your interaction. "How are you?\n" with a question mark newline as a stop. Or, "Answer:\n"
public static final List<String> stops = Arrays.asList("\n", " Human:", " AI:");
.stop(stops)
Finally, maybe play w/ the prompt by giving it a few more examples of what's being requested, and play w/ the other params.
.temperature(0.97)
.topP(1.0)
.frequencyPenalty(0.0)
.presencePenalty(0.0)
Hi, thanks for the input! It got better, but there are still some weird interactions going on.
Config:
CompletionRequest request = CompletionRequest.builder()
.model("text-davinci-003")
.maxTokens(2048)
.prompt(message)
.temperature(0.01)
.topP(1.0)
.frequencyPenalty(0.5)
.presencePenalty(0.0)
.stop(stops)
.build();
I am using the stops() you suggested as well.
But here is an example of what's going on:
A couple more ideas.
1) You have to include in your prompt an instruction part. For instance: BoBAlpha is a chat bot that is friendly, helpful and very knowlegeable about technology and media. It answers in three or four sentences.
2) Change the number of completions to .n(5) or more. When you get the completions, iterate through and see if you get different or better answers.
3) Experiment on the Playground to tune your answers. It's not clear from the above what your prompt is asking for.
List<CompletionChoice> choices = service.createCompletion(completionRequest).getChoices();
assertEquals(5, choices.size());
for (CompletionChoice c : choices) {
System.out.println(c.getText());
// or whatever the exact command is. c.toString(() will give you the log_probs and finish reason which might give you clues.
}
Hi, thanks for the help. I have concluded why I was having issues after playing with the playground, like you suggested.
Turns out that the AI is set to complete mode, hence why this happens:
The ", I'm not a Doctor" is him completing the prompt, and then the rest is the actual reply to said prompt.
I am able to turn this off in the playground, but I have no idea how to do it within the Java API. Any tips?
P.S.: Giving him context of being a helpful discord bot was GREAT! Thank you!!
This is the dependency I'm using on my gradle:
implementation 'com.theokanning.openai-gpt3-java:client:0.10.0'
IntellIJ is giving a warning of "Class OpenAI uses or overrides a deprecated API".
Not only this, but it has been exhibiting weird behaviors such as this prompt/answer:
Prompt:
Answer:
This is weird, 2/10 times, it gives a normal response, but it's been this weird.
My OpenAIClass: