ollama 如何限制输出的令牌生成:Phi模型

j7dteeu8  于 2个月前  发布在  其他
关注(0)|答案(9)|浏览(108)

从给定的上下文和查询中,模型生成了很好的答案,但是非常长 -> 大约 2000 chars。有没有办法实现 max_output_tokens=200 这样的长度,类似于 pplx 或 openAI API?
这是我的提示模板:

_template = "You are an assistant that delivers short answers to the user inquiry from the provided context.\n\n
context: {conditioned_passages}\n\n
query: {query}
answer:"
xkftehaa

xkftehaa1#

num_predict :
https://github.com/ollama/ollama/blob/main/docs/modelfile.md
我认为默认值实际上是 -1,尽管API文档上说它是128(我曾经有一次不小心让Llemma模型运行了一整夜!)。

baubqpgj

baubqpgj2#

感谢 :),我打算使用 num_predict: 40
我注意到了一个无限制的令牌生成,并在某个时刻停止了。为了防止提前停止,也许可以使用 stop System:
来自

ollama show phi --parameters

输出

stop                           "User:"
stop                           "Assistant:"
stop                           "System:"
kmpatx3s

kmpatx3s3#

bm777,num_predict是否修复了你的问题?如果是的话,你介意关闭(或者我关闭)这个问题吗?

kpbwa7wx

kpbwa7wx4#

@bmizerany somehow 是的。

1szpjjfi

1szpjjfi5#

num_predict解决方案的问题在于,最终的句子会被截断。

vwhgwdsa

vwhgwdsa6#

在某种程度上,它没有正确地切割。@bmizerany

ubof19bj

ubof19bj7#

你找到解决方案了吗?

xfyts7mz

xfyts7mz8#

num_predict '解决方案'的问题在于,最终的句子会被截断。
你找到解决这个问题的方法了吗?

3qpi33ja

3qpi33ja9#

很遗憾,没有,抱歉。

相关问题