📋 Model Description
Quantization made by Richard Erkhov.
Meta-Llama-3-8B-Instruct-zh-10k - GGUF
- Model creator: https://huggingface.co/XavierSpycy/
- Original model: https://huggingface.co/XavierSpycy/Meta-Llama-3-8B-Instruct-zh-10k/
Original model description:
license: apache-2.0
language:
- en
- zh
base_model: meta-llama/Meta-Llama-3-8B-Instruct
tags:
- text-generation
- transformers
- lora
- llama.cpp
- autoawq
- auto-gptq
datasets:
- llamafactory/alpacazh
- llamafactory/alpacagpt4_zh
Meta-Llama-3-8B-Instruct-zh-10k: A Llama🦙 which speaks Chinese / 一只说中文的羊驼🦙
Model Details / 模型细节
This model,Meta-Llama-3-8B-Instruct-zh-10k, was fine-tuned from the original Meta-Llama-3-8B-Instruct due to its underperformance in Chinese. Utilizing the LoRa technology within the LLaMA-Factory utilities, this model was adapted to better handle Chinese through three epochs on three corpora: alpacazh, alpacagpt4zh, and oaastsft_zh, amounting to approximately 10,000 examples. This is reflected in the 10k in its name.
由于原模型Meta-Llama-3-8B-Instruct在中文上表现欠佳,于是该模型 Meta-Llama-3-8B-Instruct-zh-10k 微调自此。在LLaMA-Factory工具下,利用LoRa 技术,通过alpacazh、alpacagpt4zh和oaastsft_zh三个语料库上、经过三个训练轮次,我们将该模型调整得更好地掌握了中文。三个语料库共计约10,000个样本,这也是其名字中的 10k 的由来。
For efficient inference, the model was converted to the gguf format using llama.cpp and underwent quantization, resulting in a compact model size of about 3.18 GB, suitable for distribution across various devices.
为了高效的推理,使用 llama.cpp,我们将该模型转化为了gguf格式并量化,从而得到了一个压缩到约 3.18 GB 大小的模型,适合分发在各类设备上。
LoRa Hardware / LoRa 硬件
- RTX 4090D x 1
[!NOTE]
The complete fine-tuning process took approximately 12 hours. / 完整微调过程花费约12小时。
Additional fine-tuning configurations are avaiable at Hands-On LoRa or Llama3Ops.
更多微调配置可以在我的个人仓库 Hands-On LoRa 或 Llama3Ops 获得。
Other Models / 其他模型
- llama.cpp
- AutoAWQ
- AutoGPTQ
Model Developer / 模型开发者
- Pretraining: Meta
- Fine-tuning: XavierSpycy @ GitHub | XavierSpycy @ 🤗
- 预训练: Meta
- 微调: XavierSpycy @ GitHub | XavierSpycy @ 🤗
Usage / 用法
This model can be utilized like the original Meta-Llama3 but offers enhanced performance in Chinese.我们能够像原版的Meta-Llama3一样使用该模型,而它提供了提升后的中文能力。
#### 1. How to use in transformers
# !pip install accelerate
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
model_id = "XavierSpycy/Meta-Llama-3-8B-Instruct-zh-10k"
model = AutoModelForCausalLM.frompretrained(modelid, torchdtype=torch.bfloat16, devicemap="auto")
tokenizer = AutoTokenizer.frompretrained(modelid)
prompt = "你好,你是谁?"
messages = [
{"role": "system", "content": "你是一个乐于助人的助手。"},
{"role": "user", "content": prompt}]
inputids = tokenizer.applychat_template(
messages, addgenerationprompt=True, return_tensors="pt").to(model.device)
terminators = [tokenizer.eostokenid, tokenizer.converttokenstoids("<|eotid|>")]
outputs = model.generate(
input_ids,
maxnewtokens=256,
eostokenid=terminators,
do_sample=True,
temperature=0.6,
top_p=0.9)
response = outputs[0][input_ids.shape[-1]:]
print(tokenizer.decode(response, skipspecialtokens=True))
我是一个人工智能助手,旨在帮助用户解决问题和完成任务。
我是一个虚拟的人工智能助手,能够通过自然语言处理技术理解用户的需求并为用户提供帮助。
#### 2. How to use in llama.cpp / 如何在llama.cpp中使用
# CMAKEARGS="-DLLAMABLAS=ON -DLLAMABLASVENDOR=OpenBLAS # -DLLAMA_CUDA=on" \
pip install llama-cpp-python \
--extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cu121
Please download the model weights first. / 请先下载模型权重。
from llama_cpp import Llama
llm = Llama(
modelpath="/path/to/your/model/Meta-Llama-3-8B-Instruct-zh-10k-GGUF/meta-llama-3-8b-instruct-zh-10k.Q80.gguf",
ngpulayers=-1)
Alternatively / 或者
llm = Llama.from_pretrained(
repo_id="XavierSpycy/Meta-Llama-3-8B-Instruct-zh-10k-GGUF",
filename="*Q8_0.gguf",
verbose=False
)
output = llm(
"Q: 你好,你是谁?A:", # Prompt
max_tokens=256, # Generate up to 32 tokens, set to None to generate up to the end of the context window
stop=["Q:", "\n"], # Stop generating just before the model would generate a new question
echo=True # Echo the prompt back in the output
) # Generate a completion, can also call create_completion
print(output['choices'][0]['text'].split("A:")[1].strip())
我是一个人工智能聊天机器人,我的名字叫做“智慧助手”,我由一群程序员设计和开发的。我的主要任务就是通过与您交流来帮助您解决问题,为您提供相关的建议和支持。
#### 3. How to use with AutoAWQ / 如何与AutoAWQ一起使用
# !pip install autoawq
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
model_id = "XavierSpycy/Meta-Llama-3-8B-Instruct-zh-10k-AWQ"
model = AutoModelForCausalLM.frompretrained(modelid, torchdtype=torch.float16, devicemap="auto")
tokenizer = AutoTokenizer.frompretrained(modelid)
prompt = "你好,你是谁?"
messages = [
{"role": "system", "content": "你是一个乐于助人的助手。"},
{"role": "user", "content": prompt}]
inputids = tokenizer.applychat_template(
messages, addgenerationprompt=True, return_tensors="pt").to(model.device)
terminators = [tokenizer.eostokenid, tokenizer.converttokenstoids("<|eotid|>")]
outputs = model.generate(
input_ids,
maxnewtokens=256,
eostokenid=terminators,
do_sample=True,
temperature=0.6,
top_p=0.9)
response = outputs[0][input_ids.shape[-1]:]
print(tokenizer.decode(response, skipspecialtokens=True))
你好!我是一个人工智能助手,我的目的是帮助人们解决问题,回答问题,提供信息和建议。
#### 4. How to use with AutoGPTQ / 如何与AutoGPTQ一起使用
# !pip install auto-gptq --no-build-isolation
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
model_id = "XavierSpycy/Meta-Llama-3-8B-Instruct-zh-10k-GPTQ"
model = AutoModelForCausalLM.frompretrained(modelid, torchdtype=torch.float16, devicemap="auto")
tokenizer = AutoTokenizer.frompretrained(modelid)
prompt = "什么是机器学习?"
messages = [
{"role": "system", "content": "你是一个乐于助人的助手。"},
{"role": "user", "content": prompt}]
inputids = tokenizer.applychat_template(
messages, addgenerationprompt=True, return_tensors="pt").to(model.device)
terminators = [tokenizer.eostokenid, tokenizer.converttokenstoids("<|eotid|>")]
outputs = model.generate(
input_ids,
maxnewtokens=256,
eostokenid=terminators,
do_sample=True,
temperature=0.6,
top_p=0.9)
response = outputs[0][input_ids.shape[-1]:]
print(tokenizer.decode(response, skipspecialtokens=True))
机器学习是人工智能(AI)的一个分支,它允许计算机从数据中学习并改善其性能。它是一种基于算法的方法,用于从数据中识别模式并进行预测。机器学习算法可以从数据中学习,例如文本、图像和音频,并从中获得知识和见解。
Further details about the deployment are available in the GitHub repository Llama3Ops: From LoRa to Deployment with Llama3.
更多关于部署的细节可以在我的个人仓库 Llama3Ops: From LoRa to Deployment with Llama3 获得。
Ethical Considerations, Safety & Risks / 伦理考量、安全性和风险
Please refer to Meta Llama 3's Ethical Considerations for more information. Key points include bias monitoring, responsible usage guidelines, and transparency in model limitations.请参考 Meta Llama 3's Ethical Considerations,以获取更多细节。关键点包括偏见监控、负责任的使用指南和模型限制的透明度。
Limitations / 局限性
- The comprehensive abilities of the model have not been fully tested.
- While it performs smoothly in Chinese conversations, further benchmarks are required to evaluate its full capabilities. The quality and quantity of the Chinese corpora used may also limit model outputs.
- Based on current observations, it fundamentally meets the standards in common sense, logic, sentiment analysis, safety, writing, code, and function calls. However, there is room for improvement in role-playing, mathematics, and handling complex tasks with the same text but different meanings.
- Additionally, catastrophic forgetting in the fine-tuned model has not been evaluated.
- 该模型的全面的能力尚未全部测试。
- 尽管它在中文对话中表现流畅,但需要更多的测评以评估其完整的能力。中文语料库的质量和数量可能都会对模型输出有所制约。
- 根据目前的观察,它在常识、逻辑、情绪分析、安全性、写作、代码和函数调用上基本达标,然而,在角色扮演、数学、复杂的同文异义等任务上有待提高。
- 另外,微调模型中的灾难性遗忘尚未评估。
Acknowledgements / 致谢
We thank Meta for their open-source contributions, which have greatly benefited the developer community, and acknowledge the collaborative efforts of developers in enhancing this community.我们感谢 Meta 的开源贡献,这极大地帮助了开发者社区,同时,也感谢致力于提升社区的开发者们的努力。
References / 参考资料
@article{llama3modelcard,
title={Llama 3 Model Card},
author={AI@Meta},
year={2024},
url = {https://github.com/meta-llama/llama3/blob/main/MODEL_CARD.md}}
@inproceedings{zheng2024llamafactory,
title={LlamaFactory: Unified Efficient Fine-Tuning of 100+ Language Models},
author={Yaowei Zheng and Richong Zhang and Junhao Zhang and Yanhan Ye and Zheyan Luo and Zhangchi Feng and Yongqiang Ma},
booktitle={Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 3: System Demonstrations)},
address={Bangkok, Thailand},
publisher={Association for Computational Linguistics},
year={2024},
url={http://arxiv.org/abs/2403.13372}}
📂 GGUF File List
| 📁 Filename | 📦 Size | ⚡ Download |
|---|---|---|
|
Meta-Llama-3-8B-Instruct-zh-10k.IQ3_M.gguf
LFS
Q3
|
3.52 GB | Download |
|
Meta-Llama-3-8B-Instruct-zh-10k.IQ3_S.gguf
LFS
Q3
|
3.43 GB | Download |
|
Meta-Llama-3-8B-Instruct-zh-10k.IQ3_XS.gguf
LFS
Q3
|
3.28 GB | Download |
|
Meta-Llama-3-8B-Instruct-zh-10k.IQ4_NL.gguf
LFS
Q4
|
4.38 GB | Download |
|
Meta-Llama-3-8B-Instruct-zh-10k.IQ4_XS.gguf
LFS
Q4
|
4.18 GB | Download |
|
Meta-Llama-3-8B-Instruct-zh-10k.Q2_K.gguf
LFS
Q2
|
2.96 GB | Download |
|
Meta-Llama-3-8B-Instruct-zh-10k.Q3_K.gguf
LFS
Q3
|
3.74 GB | Download |
|
Meta-Llama-3-8B-Instruct-zh-10k.Q3_K_L.gguf
LFS
Q3
|
4.03 GB | Download |
|
Meta-Llama-3-8B-Instruct-zh-10k.Q3_K_M.gguf
LFS
Q3
|
3.74 GB | Download |
|
Meta-Llama-3-8B-Instruct-zh-10k.Q3_K_S.gguf
LFS
Q3
|
3.41 GB | Download |
|
Meta-Llama-3-8B-Instruct-zh-10k.Q4_0.gguf
Recommended
LFS
Q4
|
4.34 GB | Download |
|
Meta-Llama-3-8B-Instruct-zh-10k.Q4_1.gguf
LFS
Q4
|
4.78 GB | Download |
|
Meta-Llama-3-8B-Instruct-zh-10k.Q4_K.gguf
LFS
Q4
|
4.58 GB | Download |
|
Meta-Llama-3-8B-Instruct-zh-10k.Q4_K_M.gguf
LFS
Q4
|
4.58 GB | Download |
|
Meta-Llama-3-8B-Instruct-zh-10k.Q4_K_S.gguf
LFS
Q4
|
4.37 GB | Download |
|
Meta-Llama-3-8B-Instruct-zh-10k.Q5_0.gguf
LFS
Q5
|
5.21 GB | Download |
|
Meta-Llama-3-8B-Instruct-zh-10k.Q5_1.gguf
LFS
Q5
|
5.65 GB | Download |
|
Meta-Llama-3-8B-Instruct-zh-10k.Q5_K.gguf
LFS
Q5
|
5.34 GB | Download |
|
Meta-Llama-3-8B-Instruct-zh-10k.Q5_K_M.gguf
LFS
Q5
|
5.34 GB | Download |
|
Meta-Llama-3-8B-Instruct-zh-10k.Q5_K_S.gguf
LFS
Q5
|
5.21 GB | Download |
|
Meta-Llama-3-8B-Instruct-zh-10k.Q6_K.gguf
LFS
Q6
|
6.14 GB | Download |
|
Meta-Llama-3-8B-Instruct-zh-10k.Q8_0.gguf
LFS
Q8
|
7.95 GB | Download |