模型简介
模型特点
模型能力
使用案例
🚀 Llama3-8B-Chinese-Chat
Llama3-8B-Chinese-Chat是基于Meta-Llama-3-8B-Instruct模型,为中英文用户量身打造的指令调优语言模型。它具备角色扮演、工具使用等多种能力,能有效减少“中文问题英文回答”以及中英文混答的情况,在角色扮演、函数调用和数学计算等方面表现出色。
🚀 快速开始
我们在 此GitHub仓库 中提供了下载、使用和复现我们各类模型的详细说明。如果您喜欢我们的模型,烦请给我们的GitHub仓库点个星,同时也请在我们的HuggingFace仓库上点击“点赞”,感谢支持!
❗️❗️❗️注意:主分支包含 Llama3-8B-Chinese-Chat-v2.1 的 f16 GGUF文件。如果您想使用Llama3-8B-Chinese-Chat-v1 的f16 GGUF文件,请参考 “v1” 分支;若想使用Llama3-8B-Chinese-Chat-v2 的f16 GGUF文件,请参考 “v2” 分支。
❗️❗️❗️注意:为实现最佳性能,我们未对模型的身份进行微调。因此,像“你是谁”或“谁开发了你”这类问题的回答可能是随机的,不一定准确。
✨ 主要特性
- 多语言支持:支持中文和英文,满足不同语言用户的需求。
- 能力多样:具备角色扮演、函数调用、数学计算、写作、编码等多种能力。
- 性能提升:相比v1,v2.1的训练数据集扩大了5倍(约100K偏好对),在角色扮演、函数调用和数学能力方面有显著提升,且在中文回答中更不易夹杂英文单词。
📦 安装指南
复现Llama3-8B-Chinese-Chat-v2
若要复现Llama3-8B-Chinese-Chat-v2(若要复现Llama3-8B-Chinese-Chat-v1,请参考 此链接):
git clone https://github.com/hiyouga/LLaMA-Factory.git
git reset --hard 32347901d4af94ccd72b3c7e1afaaceb5cb3d26a # 若为Llama3-8B-Chinese-Chat-v1: 836ca0558698206bbf4e3b92533ad9f67c9f9864
cd LLaMA-Factory
# 我们用于Llama3-8B-Chinese-Chat-v2的数据集即将发布。若您想复现Llama3-8B-Chinese-Chat-v1,可设置 `Your_Dataset_Name_or_PATH=dpo_mix_en,dpo_mix_zh`。
deepspeed --num_gpus 8 src/train_bash.py \
--deepspeed ${Your_Deepspeed_Config_Path} \
--stage orpo \
--do_train \
--model_name_or_path meta-llama/Meta-Llama-3-8B-Instruct \
--dataset ${Your_Dataset_Name_or_PATH} \
--template llama3 \
--finetuning_type full \
--output_dir ${Your_Output_Path} \
--per_device_train_batch_size 1 \
--per_device_eval_batch_size 1 \
--gradient_accumulation_steps 8 \
--lr_scheduler_type cosine \
--log_level info \
--logging_steps 5 \
--save_strategy epoch \
--save_total_limit 3 \
--save_steps 100 \
--learning_rate 5e-6 \
--num_train_epochs 3.0 \
--plot_loss \
--do_eval false \
--max_steps -1 \
--bf16 true \
--seed 42 \
--warmup_ratio 0.1 \
--cutoff_len 8192 \
--flash_attn true \
--orpo_beta 0.05 \
--optim paged_adamw_32bit
💻 使用示例
基础用法
from llama_cpp import Llama
model = Llama(
"/Your/Path/To/GGUF/File",
verbose=False,
n_gpu_layers=-1,
)
system_prompt = "You are a helpful assistant."
def generate_reponse(_model, _messages, _max_tokens=8192):
_output = _model.create_chat_completion(
_messages,
stop=["<|eot_id|>", "<|end_of_text|>"],
max_tokens=_max_tokens,
)["choices"][0]["message"]["content"]
return _output
# 以下是一些示例
messages = [
{
"role": "system",
"content": system_prompt,
},
{"role": "user", "content": "写一首诗吧"},
]
print(generate_reponse(model, messages))
📚 详细文档
模型概述
Llama3-8B-Chinese-Chat是基于Meta-Llama-3-8B-Instruct模型,为中英文用户打造的指令调优语言模型,具备角色扮演、工具使用等多种能力。
- 开发者:Shenzhi Wang*、Yaowei Zheng*、Guoyin Wang (in.ai)、Shiji Song、Gao Huang。(*: 同等贡献)
- 许可证:Llama-3 License
- 基础模型:Meta-Llama-3-8B-Instruct
- 模型大小:8.03B
- 上下文长度:8K
模型更新
Llama3-8B-Chinese-Chat-v2.1 [2024年5月6日]
- 训练数据集相比v1扩大了5倍(约100K偏好对),在角色扮演、函数调用和数学能力方面有显著提升,在数学计算上优于v2,且中文回答中更不易夹杂英文单词。
- 提供官方 q4_0 GGUF 版本:https://huggingface.co/shenzhi-wang/Llama3-8B-Chinese-Chat-GGUF-4bit
- 提供官方 q8_0 GGUF 版本:https://huggingface.co/shenzhi-wang/Llama3-8B-Chinese-Chat-GGUF-8bit
- 提供官方 f16 GGUF 版本:https://huggingface.co/shenzhi-wang/Llama3-8B-Chinese-Chat-GGUF-f16
- 提供官方 Ollama模型(q4_0 GGUF):wangshenzhi/llama3-8b-chinese-chat-ollama-q4,使用命令
ollama run wangshenzhi/llama3-8b-chinese-chat-ollama-q4
可快速使用。 - 提供官方 Ollama模型(q8_0 GGUF):wangshenzhi/llama3-8b-chinese-chat-ollama-q8,使用命令
ollama run wangshenzhi/llama3-8b-chinese-chat-ollama-q8
可快速使用。 - 提供官方 Ollama模型(f16 GGUF):wangshenzhi/llama3-8b-chinese-chat-ollama-fp16,使用命令
ollama run wangshenzhi/llama3-8b-chinese-chat-ollama-fp16
可快速使用。 - 提供Llama3-8B-Chinese-Chat-v2的在线交互式演示:https://huggingface.co/spaces/llamafactory/Llama3-8B-Chinese-Chat
Llama3-8B-Chinese-Chat-v2 [2024年4月29日]
- 训练数据集相比v1扩大了5倍(约100K偏好对),在角色扮演、函数调用和数学能力方面有显著提升。
- 提供官方f16 GGUF版本:https://huggingface.co/shenzhi-wang/Llama3-8B-Chinese-Chat-GGUF-f16/tree/v2
- 提供官方8位量化GGUF版本:https://huggingface.co/shenzhi-wang/Llama3-8B-Chinese-Chat-GGUF-8bit/tree/v2
- 提供Llama3-8B-Chinese-Chat-v2的在线交互式演示:https://huggingface.co/spaces/llamafactory/Llama3-8B-Chinese-Chat
Llama3-8B-Chinese-Chat-v1
- 提供官方Ollama模型(f16 GGUF):wangshenzhi/llama3-8b-chinese-chat-ollama-f16,使用命令
ollama run wangshenzhi/llama3-8b-chinese-chat-ollama-fp16
可快速使用。 - 提供官方Ollama模型(8位量化GGUF):wangshenzhi/llama3-8b-chinese-chat-ollama-q8,使用命令
ollama run wangshenzhi/llama3-8b-chinese-chat-ollama-q8
可快速使用。 - 提供官方f16 GGUF版本:shenzhi-wang/Llama3-8B-Chinese-Chat-GGUF-f16-v1
- 提供官方8位量化GGUF版本:shenzhi-wang/Llama3-8B-Chinese-Chat-GGUF-8bit-v1
- 在中国,可从 Gitee AI仓库 下载v1模型。
模型示例
以下是Llama3-8B-Chinese-Chat-v2.1 生成的一些示例,涵盖角色扮演、函数调用、数学计算、弱智吧问答、安全、写作和编码等方面。
- 角色扮演示例:包含扮演泰勒·斯威夫特、周杰伦、莎士比亚、诸葛亮等角色的问答。
- 函数调用示例:展示了如何调用互联网搜索、发送邮件等工具。
- 数学计算示例:解答了如年龄计算、数学应用题等问题。
- 弱智吧问答示例:对一些有趣的问题给出了回答。
- 安全示例:拒绝提供制造非法药物等违法信息。
- 写作示例:生成了关于人工智能的综述、诗歌等内容。
- 编码示例:用Python实现了快速排序算法(递归和非递归版本),用C++实现了KMP算法。
引用说明
如果我们的Llama3-8B-Chinese-Chat对您有帮助,请按以下格式引用:
@misc {shenzhi_wang_2024,
author = {Wang, Shenzhi and Zheng, Yaowei and Wang, Guoyin and Song, Shiji and Huang, Gao},
title = { Llama3-8B-Chinese-Chat (Revision 6622a23) },
year = 2024,
url = { https://huggingface.co/shenzhi-wang/Llama3-8B-Chinese-Chat },
doi = { 10.57967/hf/2316 },
publisher = { Hugging Face }
}
🔧 技术细节
模型介绍
Llama3-8B-Chinese-Chat是首个基于 Meta-Llama-3-8B-Instruct模型,通过ORPO [1] 为中英文用户进行专门微调的模型。
- 与原始的 Meta-Llama-3-8B-Instruct模型 相比,Llama3-8B-Chinese-Chat-v1模型显著减少了“中文问题英文回答”以及中英文混答的情况。
- 与 Llama3-8B-Chinese-Chat-v1 相比,Llama3-8B-Chinese-Chat-v2模型的训练数据量大幅增加(从20K增加到100K),性能显著提升,尤其是在角色扮演、工具使用和数学计算方面。
[1] Hong, Jiwoo, Noah Lee, and James Thorne. "Reference-free Monolithic Preference Optimization with Odds Ratio." arXiv preprint arXiv:2403.07691 (2024).
训练框架
训练详情
- 轮数:2
- 学习率:5e-6
- 学习率调度器类型:余弦
- 热身比例:0.1
- 截断长度(即上下文长度):8192
- orpo beta(即ORPO论文中的 $\lambda$):0.05
- 全局批量大小:128
- 微调类型:全参数
- 优化器:paged_adamw_32bit
📄 许可证
本模型遵循 Llama-3 License。



