XavierSpycy
commited on
Commit
·
91d4d35
1
Parent(s):
c65abb6
First commit
Browse files- .gitattributes +1 -0
- README.md +127 -0
- meta-llama-3-8b-instruct-zh-10k.Q2_K.gguf +3 -0
- meta-llama-3-8b-instruct-zh-10k.Q8_0.gguf +3 -0
- meta-llama-3-8b-instruct-zh-10k.gguf +3 -0
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
*.gguf filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
@@ -1,3 +1,130 @@
|
|
1 |
---
|
2 |
license: apache-2.0
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: apache-2.0
|
3 |
---
|
4 |
+
|
5 |
+
# Meta-Llama-3-8B-Instruct-zh-10k: A Llama🦙 which speaks Chinese / 一只说中文的羊驼🦙
|
6 |
+
|
7 |
+
## Model Details / 模型细节
|
8 |
+
This model, <u>`Meta-Llama-3-8B-Instruct-zh-10k`</u>, was fine-tuned from the original [Meta-Llama-3-8B-Instruct](https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct) due to its underperformance in Chinese. Utilizing the LoRa technology within the [LLaMA-Factory](https://github.com/hiyouga/LLaMA-Factory) utilities, this model was adapted to better handle Chinese through three epochs on three corpora: `alpaca_zh`, `alpaca_gpt4_zh`, and `oaast_sft_zh`, amounting to approximately 10,000 examples. This is reflected in the `10k` in its name.
|
9 |
+
|
10 |
+
由于原模型[Meta-Llama-3-8B-Instruct](https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct)在中文上表现欠佳,于是该模型 <u>`Meta-Llama-3-8B-Instruct-zh-10k`</u> 微调自此。在[LLaMA-Factory](https://github.com/hiyouga/LLaMA-Factory)工具下,利用LoRa 技术,通过`alpaca_zh`、`alpaca_gpt4_zh`和`oaast_sft_zh`三个语料库上、经过三个训练轮次,我们将该模型调整得更好地掌握了中文。三个语料库共计约10,000个样本,这也是其名字中的 `10k` 的由来。
|
11 |
+
|
12 |
+
For efficient inference, the model was converted to the gguf format using [llama.cpp](https://github.com/ggerganov/llama.cpp) and underwent quantization, resulting in a compact model size of about 3.18 GB, suitable for distribution across various devices.
|
13 |
+
|
14 |
+
为了高效的推理,使用 [llama.cpp](https://github.com/ggerganov/llama.cpp),我们将该模型转化为了gguf格式并量化,从而得到了一个压缩到约 3.18 GB 大小的模型,适合分发在各类设备上。
|
15 |
+
|
16 |
+
### LoRa Hardware / LoRa 硬件
|
17 |
+
- RTX 4090D x 1
|
18 |
+
|
19 |
+
> [!NOTE]
|
20 |
+
> The complete fine-tuning process took approximately 12 hours. / 完整微调过程花费约12小时。
|
21 |
+
|
22 |
+
Additional fine-tuning configurations are avaiable at [Hands-On LoRa](https://github.com/XavierSpycy/hands-on-lora) or [Llama3Ops](https://github.com/XavierSpycy/llama-ops).
|
23 |
+
|
24 |
+
更多微调配置可以在我的个人仓库 [Hands-On LoRa](https://github.com/XavierSpycy/hands-on-lora) 或 [Llama3Ops](https://github.com/XavierSpycy/llama-ops) 获得。
|
25 |
+
|
26 |
+
### Other Models / 其他模型
|
27 |
+
- <u>LLaMA-Factory</u>
|
28 |
+
- [Meta-Llama-3-8B-Instruct-zh-10k](https://huggingface.co/XavierSpycy/Meta-Llama-3-8B-Instruct-zh-10k)
|
29 |
+
|
30 |
+
- <u>AutoAWQ</u>
|
31 |
+
- [Meta-Llama-3-8B-Instruct-zh-10k-AWQ](https://huggingface.co/XavierSpycy/Meta-Llama-3-8B-Instruct-zh-10k-AWQ)
|
32 |
+
|
33 |
+
- <u>AutoGPTQ</u>
|
34 |
+
- [Meta-Llama-3-8B-Instruct-zh-10k-GPTQ](https://huggingface.co/XavierSpycy/Meta-Llama-3-8B-Instruct-zh-10k-GPTQ)
|
35 |
+
|
36 |
+
### Model Developer / 模型开发者
|
37 |
+
- **Pretraining**: Meta
|
38 |
+
- **Fine-tuning**: [XavierSpycy @ GitHub ](https://github.com/XavierSpycy) | [XavierSpycy @ 🤗](https://huggingface.co/XavierSpycy)
|
39 |
+
|
40 |
+
- **预训练**: Meta
|
41 |
+
- **微调**: [XavierSpycy @ GitHub](https://github.com/XavierSpycy) | [XavierSpycy @ 🤗 ](https://huggingface.co/XavierSpycy)
|
42 |
+
|
43 |
+
|
44 |
+
### Usage / 用法
|
45 |
+
This model can be utilized like the original <u>Meta-Llama3</u> but offers enhanced performance in Chinese.
|
46 |
+
|
47 |
+
我们能够像原版的<u>Meta-Llama3</u>一样使用该模型,而它提供了提升后的中文能力。
|
48 |
+
|
49 |
+
```python
|
50 |
+
# !pip install accelerate
|
51 |
+
|
52 |
+
import torch
|
53 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
54 |
+
|
55 |
+
model_id = "XavierSpycy/Meta-Llama-3-8B-Instruct-zh-10k"
|
56 |
+
|
57 |
+
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16, device_map="auto")
|
58 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
59 |
+
|
60 |
+
prompt = "你好,你是谁?"
|
61 |
+
|
62 |
+
messages = [
|
63 |
+
{"role": "system", "content": "你是一个乐于助人的助手。"},
|
64 |
+
{"role": "user", "content": prompt}]
|
65 |
+
|
66 |
+
input_ids = tokenizer.apply_chat_template(
|
67 |
+
messages, add_generation_prompt=True, return_tensors="pt").to(model.device)
|
68 |
+
|
69 |
+
terminators = [tokenizer.eos_token_id, tokenizer.convert_tokens_to_ids("<|eot_id|>")]
|
70 |
+
|
71 |
+
outputs = model.generate(
|
72 |
+
input_ids,
|
73 |
+
max_new_tokens=256,
|
74 |
+
eos_token_id=terminators,
|
75 |
+
do_sample=True,
|
76 |
+
temperature=0.6,
|
77 |
+
top_p=0.9)
|
78 |
+
|
79 |
+
response = outputs[0][input_ids.shape[-1]:]
|
80 |
+
|
81 |
+
print(tokenizer.decode(response, skip_special_tokens=True))
|
82 |
+
# 我是一个人工智能助手,旨在帮助用户解决问题和完成任务。
|
83 |
+
# 我是一个虚拟的人工智能助手,能够通过自然语言处理技术理解用户的需求并为用户提供帮助。
|
84 |
+
```
|
85 |
+
|
86 |
+
Further details about the deployment are available in the GitHub repository [Llama3Ops: From LoRa to Deployment with Llama3](https://github.com/XavierSpycy/llama-ops).
|
87 |
+
|
88 |
+
更多关于部署的细节可以在我的个人仓库 [Llama3Ops: From LoRa to Deployment with Llama3](https://github.com/XavierSpycy/llama-ops) 获得。
|
89 |
+
|
90 |
+
## Ethical Considerations, Safety & Risks / 伦理考量、安全性和危险
|
91 |
+
Please refer to [Meta Llama 3's Ethical Considerations](https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct#ethical-considerations-and-limitations) for more information. Key points include bias monitoring, responsible usage guidelines, and transparency in model limitations.
|
92 |
+
|
93 |
+
请参考 [Meta Llama 3's Ethical Considerations](https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct#ethical-considerations-and-limitations),以获取更多细节。关键点包括偏见监控、负责任的使用指南和模型限制的透明度。
|
94 |
+
|
95 |
+
## Limitations / 局限性
|
96 |
+
- The comprehensive abilities of the model have not been fully tested.
|
97 |
+
|
98 |
+
- 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.
|
99 |
+
|
100 |
+
- Additionally, catastrophic forgetting in the fine-tuned model has not been evaluated.
|
101 |
+
|
102 |
+
- 该模型的全面的能力尚未全部测试。
|
103 |
+
|
104 |
+
- 尽管它在中文对话中表现流畅,但需要更多的测评以评估其完整的能力。中文语料库的质量和数量可能都会对模型输出有所制约。
|
105 |
+
|
106 |
+
- 另外,微调模型中的灾难性遗忘尚未评估。
|
107 |
+
|
108 |
+
## Acknowledgements / 致谢
|
109 |
+
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.
|
110 |
+
|
111 |
+
我们感谢 Meta 的开源贡献,这极大地帮助了开发者社区,同时,也感谢致力于提升社区的开发者们的努力。
|
112 |
+
|
113 |
+
## References / 参考资料
|
114 |
+
|
115 |
+
```
|
116 |
+
@article{llama3modelcard,
|
117 |
+
title={Llama 3 Model Card},
|
118 |
+
author={AI@Meta},
|
119 |
+
year={2024},
|
120 |
+
url = {https://github.com/meta-llama/llama3/blob/main/MODEL_CARD.md}}
|
121 |
+
|
122 |
+
@inproceedings{zheng2024llamafactory,
|
123 |
+
title={LlamaFactory: Unified Efficient Fine-Tuning of 100+ Language Models},
|
124 |
+
author={Yaowei Zheng and Richong Zhang and Junhao Zhang and Yanhan Ye and Zheyan Luo and Zhangchi Feng and Yongqiang Ma},
|
125 |
+
booktitle={Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 3: System Demonstrations)},
|
126 |
+
address={Bangkok, Thailand},
|
127 |
+
publisher={Association for Computational Linguistics},
|
128 |
+
year={2024},
|
129 |
+
url={http://arxiv.org/abs/2403.13372}}
|
130 |
+
```
|
meta-llama-3-8b-instruct-zh-10k.Q2_K.gguf
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5634aeaeff78e940e10671bec07e99d1acb15c8f230388df3972e44fa3f7015e
|
3 |
+
size 3179131456
|
meta-llama-3-8b-instruct-zh-10k.Q8_0.gguf
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e675330f4b8e5916823427938b23a18f810183c7f1eb5188430efa104554c04e
|
3 |
+
size 8540770880
|
meta-llama-3-8b-instruct-zh-10k.gguf
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d317b766a878d9c2ed765a412dc043f543f49a9795bd47ab47e7f18fa53b64ac
|
3 |
+
size 16068891200
|