模型概述
模型特點
模型能力
使用案例
🚀 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許可證。



