openai-java icon indicating copy to clipboard operation
openai-java copied to clipboard

长文本总是无法全部加载出来就结束了,比如让生成一篇文章,往往生成前两句就结束了,请问这个怎么解决?

Open wang1092791404 opened this issue 3 years ago • 6 comments

	OpenAiService service = new OpenAiService(token,180);
	CompletionRequest completionRequest = CompletionRequest.builder()
	        .prompt(queryString)
	        .model("text-davinci-003")
	        .temperature(0.9)
	        .maxTokens(150)
	        .topP(1.0)
	        .frequencyPenalty(0.0)
	        .presencePenalty(0.6)
	        //.echo(true)
	        .user("testuser")
	        .build();

wang1092791404 avatar Feb 06 '23 09:02 wang1092791404

Have you tried just increasing the tokens to 500+. Also, this takes a bit of prompt engineering. If you want more sentences, then include the directive in the prompt? I.e. Generate an essay of 5-8 sentences that does X?

cryptoapebot avatar Feb 06 '23 14:02 cryptoapebot

谢谢,我设置大点的tokens可以解决问题. 还有一个问题 .stop参数具体有啥用? 是设置Human, AI 后,遇到这两个词语就结束会话吗?还是怎么个逻辑? https://platform.openai.com/docs/api-reference/completions/create#completions/create-stop

wang1092791404 avatar Feb 07 '23 02:02 wang1092791404

It just tells the model when to stop and respond. For instance, in a chat app, when it sees the end of the prompt at AI: it meants it wants the model to respond.

	public static final List<String> stops = Arrays.asList("\n", " Human:", " AI:");
					.stop(stops)

cryptoapebot avatar Feb 07 '23 05:02 cryptoapebot

昨天,寻找让ai记得之前提问的方法时,看到有人这么尝试的 。 prompt = “Human: 问题1是XXXX Ai: Human: 我刚才的问题是什么”, 这种形式会得到 “ 问题1是XXXX”的回复。不知道有没有更正确的方式。

另外,当询问现在的日期、时间星期几时,得到的回复是,2020年之类的,除非在prompt中提供了准确的日期时间星期几。 这个问题有没有比较好的处理方法?

使用api怎样来保持聊天逻辑上的连续性?

Yourwon avatar Feb 07 '23 09:02 Yourwon

You can create a fine-tune set once a day that feeds it a daily training set:

What is today's date? February 7th, 2023

https://help.openai.com/en/articles/5528730-fine-tuning-a-classifier-to-improve-truthfulness Other than getting the date right, none of the other data will be up to date unless you fine-tune it on that data also.

cryptoapebot avatar Feb 07 '23 15:02 cryptoapebot

BTW, if the response time takes too long, you probably want to switch to a different model. Try re-running with the model text-ada-001 (or text-ada-002) and see if the quality of results you get are adequate for what you are doing. Both Ada and Babbage models are extremely fast. Davinci is by far the slowest, though the most capable.

cryptoapebot avatar Feb 16 '23 15:02 cryptoapebot