XavierSpycy
commited on
Commit
·
14bffd0
1
Parent(s):
2cf24c4
First commit
Browse files- README.md +127 -0
- config.json +42 -0
- gptq_model-4bit-128g.safetensors +3 -0
- quantize_config.json +13 -0
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>llama.cpp</u>
|
31 |
+
- [Meta-Llama-3-8B-Instruct-zh-10k-GGUF](https://huggingface.co/XavierSpycy/Meta-Llama-3-8B-Instruct-zh-10k-GGUF)
|
32 |
+
|
33 |
+
- <u>AutoAWQ</u>
|
34 |
+
- [Meta-Llama-3-8B-Instruct-zh-10k-AWQ](https://huggingface.co/XavierSpycy/Meta-Llama-3-8B-Instruct-zh-10k-AWQ)
|
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 |
+
```
|
config.json
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "Meta-Llama-3-8B-Instruct-zh-10k",
|
3 |
+
"architectures": [
|
4 |
+
"LlamaForCausalLM"
|
5 |
+
],
|
6 |
+
"attention_bias": false,
|
7 |
+
"attention_dropout": 0.0,
|
8 |
+
"bos_token_id": 128000,
|
9 |
+
"eos_token_id": 128001,
|
10 |
+
"hidden_act": "silu",
|
11 |
+
"hidden_size": 4096,
|
12 |
+
"initializer_range": 0.02,
|
13 |
+
"intermediate_size": 14336,
|
14 |
+
"max_position_embeddings": 8192,
|
15 |
+
"mlp_bias": false,
|
16 |
+
"model_type": "llama",
|
17 |
+
"num_attention_heads": 32,
|
18 |
+
"num_hidden_layers": 32,
|
19 |
+
"num_key_value_heads": 8,
|
20 |
+
"pretraining_tp": 1,
|
21 |
+
"quantization_config": {
|
22 |
+
"bits": 4,
|
23 |
+
"checkpoint_format": "gptq",
|
24 |
+
"damp_percent": 0.01,
|
25 |
+
"desc_act": true,
|
26 |
+
"group_size": 128,
|
27 |
+
"model_file_base_name": null,
|
28 |
+
"model_name_or_path": null,
|
29 |
+
"quant_method": "gptq",
|
30 |
+
"static_groups": false,
|
31 |
+
"sym": true,
|
32 |
+
"true_sequential": true
|
33 |
+
},
|
34 |
+
"rms_norm_eps": 1e-05,
|
35 |
+
"rope_scaling": null,
|
36 |
+
"rope_theta": 500000.0,
|
37 |
+
"tie_word_embeddings": false,
|
38 |
+
"torch_dtype": "float16",
|
39 |
+
"transformers_version": "4.41.2",
|
40 |
+
"use_cache": true,
|
41 |
+
"vocab_size": 128256
|
42 |
+
}
|
gptq_model-4bit-128g.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9ecbdf87ba4c17ac929e9024e035e03ebdac014c04f53ac580f52b71ce05a31d
|
3 |
+
size 5732943784
|
quantize_config.json
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bits": 4,
|
3 |
+
"group_size": 128,
|
4 |
+
"damp_percent": 0.01,
|
5 |
+
"desc_act": true,
|
6 |
+
"static_groups": false,
|
7 |
+
"sym": true,
|
8 |
+
"true_sequential": true,
|
9 |
+
"model_name_or_path": null,
|
10 |
+
"model_file_base_name": null,
|
11 |
+
"quant_method": "gptq",
|
12 |
+
"checkpoint_format": "gptq"
|
13 |
+
}
|