Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

联通的兄弟,在ollama的模型仓库上传一下,或者发一下ollama的modelfile #8

Open
zhqfdn opened this issue Apr 26, 2024 · 8 comments

Comments

@zhqfdn
Copy link

zhqfdn commented Apr 26, 2024

联通的兄弟,在ollama的模型仓库上传一下,或者发一下ollama的modelfile

@xx025
Copy link

xx025 commented Apr 26, 2024

我是写的 Modefile , 模型可以运行起来

FROM converted.bin
#TEMPLATE "[INST] {{ .Prompt }} [/INST]"
TEMPLATE """{{ if .System }}<|start_header_id|>system<|end_header_id|>

{{ .System }}<|eot_id|>{{ end }}{{ if .Prompt }}<|start_header_id|>user<|end_header_id|>

{{ .Prompt }}<|eot_id|>{{ end }}<|start_header_id|>assistant<|end_header_id|>

{{ .Response }}<|eot_id|>"""
PARAMETER num_keep 24
PARAMETER stop "<|start_header_id|>"
PARAMETER stop "<|end_header_id|>"
PARAMETER stop "<|eot_id|>"

但是它似乎不是很正常(表现很差)

image

下面是我转换的方法

# 转换
python llm/llama.cpp/convert.py \
~/Unichat-llama3-Chinese --outtype f16 \
--outfile ~/Unichat/converted.bin \
--vocab-type bpe

# 量化
llm/llama.cpp/quantize \
~/Unichat/converted.bin \
~/Unichat/quantized.bin q4_0

# 根据 Modefile 制作Ollama 模型 
 ollama create unichat-llama3-chinese-8b -f Modelfile

@zhqfdn
Copy link
Author

zhqfdn commented Apr 26, 2024 via email

@zhqfdn
Copy link
Author

zhqfdn commented Apr 26, 2024

注意: --vocab-type 指定分词算法,默认值是 spm,联通用的是 bpe,需要指定。
python3 ./convert.py ./Unichat-llama3-Chinese-8B-28K --vocab-type bpe --outfile ./Unichat-llama3-Chinese-8B-28K_F32.gguf

上面先转成 F32格式的 GGUF,再执行量化转为F16、Q4_0
quantize ./Unichat-llama3-Chinese-8B-28K_F32.gguf ./Unichat-llama3-Chinese-8B-28K_F16.gguf F16
quantize ./Unichat-llama3-Chinese-8B-28K_F32.gguf ./Unichat-llama3-Chinese-8B-28K_Q4.gguf Q4_0

测试模型
main -m ./Unichat-llama3-Chinese-8B-28K_Q4_0.gguf -n 256 -p "百度公司"

然后在ollama 中导入模型

Modelfile 内容如下

FROM ./Unichat-llama3-Chinese-8B-28K_Q4.gguf

TEMPLATE """
{{ if .System }}<|start_header_id|>system<|end_header_id|>
{{ .System }}<|eot_id|>{{ end }}{{ if .Prompt }}<|start_header_id|>user<|end_header_id|>
{{ .Prompt }}<|eot_id|>{{ end }}<|start_header_id|>assistant<|end_header_id|>
{{ .Response }}<|eot_id|>
"""

SYSTEM """

"""

PARAMETER stop "<|start_header_id|>"
PARAMETER stop "<|end_header_id|>"
PARAMETER stop "<|eot_id|>"

PARAMETER repeat_penalty 1.15
PARAMETER temperature 0.6
PARAMETER top_p 1

导入模型到 Ollama 库
ollama create Unichat-llama3-Chinese-28K:8b -f Modelfile

@zhqfdn
Copy link
Author

zhqfdn commented Apr 26, 2024

按上面导入到OLLAMA 库,我没上传到OLLAMA

@xx025
Copy link

xx025 commented Apr 27, 2024

Ollama 社区下载UnicomLLM/Unichat-llama3-Chinese-8B模型

非官方, 已上传下文附加参数的更新版本

直接尝试我的在线部署


#8 (comment)

当我 按照 UnicomLLM/Unichat-llama3-Chinese-8B#快速开始的参数设定时,它似乎表现好一点


image

@xx025
Copy link

xx025 commented Apr 27, 2024

你转换成gguf是不是没指定分词模式? 在上面哪个回复里有写

---------- 该邮件从移动设备发送
--------------原始邮件-------------- 发件人:"Rycbar123 @.>; 发送时间:2024年4月26日(星期五) 晚上11:09 收件人:"UnicomAI/Unichat-llama3-Chinese" @.>; 抄送:"luffy @.>;"Author @.>; 主题:Re: [UnicomAI/Unichat-llama3-Chinese] 联通的兄弟,在ollama的模型仓库上传一下,或者发一下ollama的modelfile (Issue #8) ----------------------------------- 我这也写 Modefile , 模型似乎可以正常运行 FROM converted.bin #TEMPLATE "[INST] {{ .Prompt }} [/INST]" TEMPLATE """{{ if .System }}<|start_header_id|>system<|end_header_id|> {{ .System }}<|eot_id|>{{ end }}{{ if .Prompt }}<|start_header_id|>user<|end_header_id|> {{ .Prompt }}<|eot_id|>{{ end }}<|start_header_id|>assistant<|end_header_id|> {{ .Response }}<|eot_id|>""" PARAMETER num_keep 24 PARAMETER stop "<|start_header_id|>" PARAMETER stop "<|end_header_id|>" PARAMETER stop "<|eot_id|>" 但是它似乎不是很正常 image.png (view on web) — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

#8 (comment) 转换方法,最后面的参数我指定了--vocab-type bpe

python llm/llama.cpp/convert.py \
~/Unichat-llama3-Chinese --outtype f16 \
--outfile ~/Unichat/converted.bin \
--vocab-type bpe

@grainYao
Copy link

我添加了参数--vocab-type bpe,报错FileNotFoundError: Could not find any of ['vocab.json'],这个文件是在模型文件中的吗,没找到

@UnicomAI
Copy link
Owner

Ollama 社区下载UnicomLLM/Unichat-llama3-Chinese-8B模型

非官方, 已上传下文附加参数的更新版本

直接尝试我的在线部署

#8 (comment)

当我 按照 UnicomLLM/Unichat-llama3-Chinese-8B#快速开始的参数设定时,它似乎表现好一点

![image](https://private-user-images.githubusercontent.com/71559822/326147632-ad9ddcb2-6492-4bc8-bf1b-bfe316eb824d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTQzNzM5OTcsIm5iZiI6MTcxNDM3MzY5NywicGF0aCI6Ii83MTU1OTgyMi8zMjYxNDc2MzItYWQ5ZGRjYjItNjQ5Mi00YmM4LWJmMWItYmZlMzE2ZWI4MjRkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA0MjklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNDI5VDA2NTQ1N1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTdkY2E3MGJjYmZjZDYzNzI3MmVkZjkwN2U2NThjNWMzNjgyZWU1YjdhNzJlOGZlMjI0NGY1OWIzNTA2OTY4YzAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.vlZ1R_yirMBs1QnzFn98W60ZTdLGFM8UpHfNJKVmw5I)

8b模型和llama3官方模板不一样,参考tokenizer_config.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants