Facico / Chinese-Vicuna

Chinese-Vicuna: A Chinese Instruction-following LLaMA-based Model —— 一个中文低资源的llama+lora方案,结构参考alpaca
https://github.com/Facico/Chinese-Vicuna
Apache License 2.0
4.14k stars 425 forks source link

在实际应用中我如何将num_beams=4,但最终输出的时候可保证输出过程和结果是一致的 #213

Open zjwlgr opened 1 year ago

zjwlgr commented 1 year ago

我使用开源模型进行推理时遇到的疑问

以下为我推理时用到的主要参数 temperature=0.3, top_p=0.75, top_k=60, num_beams=4, max_new_tokens=1024, min_new_tokens=1, repetition_penalty=6,

其中 num_beams=4 ,会输出4个回答,最终会保留一个回答,这样体验不好,实际应用中也不能是这样的呈现方式

但如如果代码改为以下: outputs = tokenizer.batch_decode(generation_output) show_text = PROMPT_DICT['postprocess'](outputs[0]+"" if outputs is not None else '### Response:') 就是说永远取 outputs[0] 数据

但这样会导致输出过程和结果不一致,体验也不好

有没有什么方法既能设置 num_beams=4 ,又能保证输出过程和结果一样呢,有没有什么方法可以解决这个问题?

Facico commented 1 year ago

暂时没有啥好的解决方案,因为现在也基本没有对beam search做流式输出的,我们也期待能有相应的解决方法