模型简介
模型特点
模型能力
使用案例
🚀 Llama3-8B-Chinese-Chat
Llama3-8B-Chinese-Chat是一款基于Meta-Llama-3-8B-Instruct模型,为中英用户量身打造的指令调优语言模型。它具备角色扮演、工具使用等多种能力,能有效满足不同场景下的交流需求。
🚀 快速开始
我们在 此GitHub仓库 中提供了下载、使用和复现各种模型的详细说明。如果您喜欢我们的模型,烦请为我们的GitHub仓库点个星,同时也请在HuggingFace仓库上点击“喜欢”,感谢您的支持!
❗️❗️❗️注意:本仓库仅包含 Llama3-8B-Chinese-Chat-v2.1 的 q4_0 GGUF文件。若您想使用Llama3-8B-Chinese-Chat-v1,请参考 此链接;若想使用Llama3-8B-Chinese-Chat-v2,请参考 此链接。
❗️❗️❗️注意:为实现最佳性能,我们未对模型身份进行微调。因此,诸如“你是谁”或“你是由谁开发的”等问题,可能会得到随机且不一定准确的回答。
✨ 主要特性
- 多语言支持:支持中文和英文,满足不同语言背景用户的需求。
- 性能提升:相比原始的Meta-Llama-3-8B-Instruct模型,显著减少了“中文问题英文回答”以及回复中中英文混杂的问题。
- 数据增强:与Llama3-8B-Chinese-Chat-v1相比,v2模型的训练数据量大幅增加(从20K增至100K),在角色扮演、工具使用和数学等方面表现更优。
- 持续优化:Llama3-8B-Chinese-Chat-v2.1在数学能力上超越v2,且中文回复中更不易夹杂英文单词。
📦 安装指南
复现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 |
训练数据 | Llama3-8B-Chinese-Chat-v2.1的训练数据集相比v1扩大了5倍(约100K偏好对),该数据集即将发布。 |
开发者 | Shenzhi Wang*、Yaowei Zheng*、Guoyin Wang (in.ai)、Shiji Song、Gao Huang。(*: 同等贡献) |
许可证 | Llama-3许可证 |
基础模型 | Meta-Llama-3-8B-Instruct |
模型大小 | 8.03B |
上下文长度 | 8K |
模型更新
Llama3-8B-Chinese-Chat-v2.1 [2024年5月6日]
- 训练数据集相比v1扩大了5倍(约100K偏好对),在角色扮演、函数调用和数学能力方面有显著提升。
- 相比v2,在数学能力上更胜一筹,且中文回复中更不易夹杂英文单词。
- 提供官方的 q4_0 GGUF、q8_0 GGUF 和 f16 GGUF 版本,分别可在 此处、此处 和 此处 获取。
- 提供官方的 Ollama模型,可通过以下命令快速使用:
- q4_0 GGUF版本:
ollama run wangshenzhi/llama3-8b-chinese-chat-ollama-q4
- q8_0 GGUF版本:
ollama run wangshenzhi/llama3-8b-chinese-chat-ollama-q8
- f16 GGUF版本:
ollama run wangshenzhi/llama3-8b-chinese-chat-ollama-fp16
- q4_0 GGUF版本:
- 提供 在线交互演示。
Llama3-8B-Chinese-Chat-v2
- 训练数据集相比v1扩大了5倍(约100K偏好对),在角色扮演、工具使用和数学能力方面有显著提升。
- 提供官方的 f16 GGUF 和 8bit量化GGUF 版本,分别可在 此处 和 此处 获取。
- 提供 在线交互演示。
Llama3-8B-Chinese-Chat-v1
- 提供官方的 f16 GGUF 和 8bit量化GGUF 版本,分别可在 此处 和 此处 获取。
- 提供官方的 Ollama模型,可通过以下命令快速使用:
- f16 GGUF版本:
ollama run wangshenzhi/llama3-8b-chinese-chat-ollama-fp16
- 8bit量化GGUF版本:
ollama run wangshenzhi/llama3-8b-chinese-chat-ollama-q8
- f16 GGUF版本:
- 若您在中国,可从 Gitee AI仓库 下载v1模型。
示例展示
以下是Llama3-8B-Chinese-Chat-v2.1生成的部分示例,涵盖角色扮演、函数调用、数学、弱智吧、安全、写作和编码等方面。
- 角色扮演示例:包含扮演Taylor Swift、周杰伦、莎士比亚、诸葛亮等角色的对话。
- 函数调用示例:展示了使用工具进行互联网搜索、发送邮件等操作的示例。
- 数学示例:包含年龄计算、数学竞赛获奖人数计算等数学问题的解答。
- 弱智吧示例:提供了一些有趣的问答,如蓝牙耳机维修、午餐肉食用时间等问题的回复。
- 安全示例:强调了不提供制造非法药物信息的原则,并给出合法寻求疼痛管理帮助的建议。
- 写作示例:包含人工智能综述、诗歌创作等内容。
- 编码示例:提供了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 }
}
🔧 技术细节
本模型是基于 Meta-Llama-3-8B-Instruct模型,通过ORPO [1] 方法专门为中英用户进行微调的首个模型。与原始模型相比,Llama3-8B-Chinese-Chat-v1显著减少了“中文问题英文回答”以及回复中中英文混杂的问题;与v1相比,v2模型的训练数据量大幅增加,性能显著提升。
[1] Hong, Jiwoo, Noah Lee, and James Thorne. "Reference-free Monolithic Preference Optimization with Odds Ratio." arXiv preprint arXiv:2403.07691 (2024).
训练框架:LLaMA-Factory。
训练细节:
- 训练轮数:2
- 学习率:5e-6
- 学习率调度器类型:cosine
- 热身比例:0.1
- 截断长度(即上下文长度):8192
- orpo beta(即ORPO论文中的 $\lambda$):0.05
- 全局批量大小:128
- 微调类型:全参数
- 优化器:paged_adamw_32bit
📄 许可证
本模型遵循 Llama-3许可证。



