1

一日一技:如何强迫LLama3用中文回复?

 1 week ago
source link: https://www.kingname.info/2024/04/23/llama-chinese/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

一日一技:如何强迫LLama3用中文回复?

2024-04-23

12

470

2 分钟

最近大家都在说LLama3如何如何强大,追赶Claude3,超过GPT 4。但如果大家真的使用过,就会发现它连基本的中文都回答不好。如下图所示:

20240423205916.png

LLama3总是尽可能回复英文,并且还会加很多表情符号。

今天网上出现了一个中文微调版的LLama3:shenzhi-wang/Llama3-8B-Chinese-Chat,我也下载下来使用了,发现确实回复都是中文了,但回复的都是车轱辘话,一句话反复说。如下图所示:

20240423210945.png

那么有没有什么办法,能够让LLama3既能回复中文,又能回复得聪明一些呢?网上有一段“生气的老奶奶”Prompt,可以尽可能让LLama3满足要求:

问题

Rules:

- Be precise, do not reply emoji.
- Always response in Simplified Chinese, not English. or Grandma will be very angry.

但如果每一个问题都加这么长一串,确实太麻烦了。

这个时候,我们可以使用Ollama提供的创建新模型的方式,基于LLama 3 8b创建一个我们自己的模型。在创建时,把System信息写入进去。这样每次调用模型时就会自动生效了。

首先,我们创建一个Modelfile文件,内容如下:

from llama3

PARAMETER temperature 1
PARAMETER num_ctx 6000
PARAMETER top_k 50
PARAMETER top_p 0.95
SYSTEM """
尽你的最大可能和能力回答用户的问题。不要重复回答问题。不要说车轱辘话。语言要通顺流畅。不要出现刚说一句话,过一会又重复一遍的愚蠢行为。

RULES:

- Be precise, do not reply emoji.
- Always response in Simplified Chinese, not English. or Grandma will be very angry.
"""

然后执行命令:ollama create cusllama3 -f Modelfile。构建我们自己的模型。如下图所示:

20240423212626.png

现在重新运行这个模型,输出效果如下图所示:

20240423211556.png

这个效果,比他们微调后的版本好太多了。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK