Upload folder using huggingface_hub
Browse files- .gitattributes +1 -0
- README.md +130 -0
- llama3.1-8b-chinese-chat.Q4_0.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 |
+
llama3.1-8b-chinese-chat.Q4_0.gguf filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: llama3.1
|
3 |
+
library_name: transformers
|
4 |
+
pipeline_tag: text-generation
|
5 |
+
base_model: meta-llama/Meta-Llama-3.1-8B-Instruct
|
6 |
+
language:
|
7 |
+
- en
|
8 |
+
- zh
|
9 |
+
tags:
|
10 |
+
- llama-factory
|
11 |
+
- orpo
|
12 |
+
---
|
13 |
+
|
14 |
+
> [!CAUTION]
|
15 |
+
> For optimal performance, we refrain from fine-tuning the model's identity. Thus, inquiries such as "Who are you" or "Who developed you" may yield random responses that are not necessarily accurate.
|
16 |
+
|
17 |
+
> [!IMPORTANT]
|
18 |
+
> If you enjoy our model, please **give it a star on our Hugging Face repo** and kindly [**cite our model**](https://huggingface.co/shenzhi-wang/Llama3.1-8B-Chinese-Chat#citation). Your support means a lot to us. Thank you!
|
19 |
+
|
20 |
+
|
21 |
+
# Updates
|
22 |
+
|
23 |
+
- 🚀🚀🚀 [July 24, 2024] We now introduce [shenzhi-wang/Llama3.1-8B-Chinese-Chat](https://huggingface.co/shenzhi-wang/Llama3.1-8B-Chinese-Chat)! The training dataset contains >100K preference pairs, and it exhibits significant enhancements, especially in **roleplay**, **function calling**, and **math** capabilities!
|
24 |
+
- 🔥 We provide the official **q4_k_m, q8_0, and f16 GGUF** versions of Llama3.1-8B-Chinese-Chat-**v2.1** at https://huggingface.co/shenzhi-wang/Llama3.1-8B-Chinese-Chat/tree/main/gguf!
|
25 |
+
|
26 |
+
|
27 |
+
# Model Summary
|
28 |
+
|
29 |
+
llama3.1-8B-Chinese-Chat is an instruction-tuned language model for Chinese & English users with various abilities such as roleplaying & tool-using built upon the Meta-Llama-3.1-8B-Instruct model.
|
30 |
+
|
31 |
+
Developers: [Shenzhi Wang](https://shenzhi-wang.netlify.app)\*, [Yaowei Zheng](https://github.com/hiyouga)\*, Guoyin Wang (in.ai), Shiji Song, Gao Huang. (\*: Equal Contribution)
|
32 |
+
|
33 |
+
- License: [Llama-3.1 License](https://huggingface.co/meta-llama/Meta-Llama-3.1-8B/blob/main/LICENSE)
|
34 |
+
- Base Model: Meta-Llama-3.1-8B-Instruct
|
35 |
+
- Model Size: 8.03B
|
36 |
+
- Context length: 128K (reported by [Meta-Llama-3.1-8B-Instruct model](https://huggingface.co/meta-llama/Meta-Llama-3.1-8B-Instruct), untested for our Chinese model)
|
37 |
+
|
38 |
+
# 1. Introduction
|
39 |
+
|
40 |
+
This is the first model specifically fine-tuned for Chinese & English users based on the [Meta-Llama-3.1-8B-Instruct model](https://huggingface.co/meta-llama/Meta-Llama-3.1-8B-Instruct). The fine-tuning algorithm used is ORPO [1].
|
41 |
+
|
42 |
+
|
43 |
+
[1] Hong, Jiwoo, Noah Lee, and James Thorne. "Reference-free Monolithic Preference Optimization with Odds Ratio." arXiv preprint arXiv:2403.07691 (2024).
|
44 |
+
|
45 |
+
Training framework: [LLaMA-Factory](https://github.com/hiyouga/LLaMA-Factory).
|
46 |
+
|
47 |
+
Training details:
|
48 |
+
|
49 |
+
- epochs: 3
|
50 |
+
- learning rate: 3e-6
|
51 |
+
- learning rate scheduler type: cosine
|
52 |
+
- Warmup ratio: 0.1
|
53 |
+
- cutoff len (i.e. context length): 8192
|
54 |
+
- orpo beta (i.e. $\lambda$ in the ORPO paper): 0.05
|
55 |
+
- global batch size: 128
|
56 |
+
- fine-tuning type: full parameters
|
57 |
+
- optimizer: paged_adamw_32bit
|
58 |
+
|
59 |
+
|
60 |
+
|
61 |
+
# 2. Usage
|
62 |
+
|
63 |
+
## 2.1 Usage of Our BF16 Model
|
64 |
+
|
65 |
+
1. Please upgrade the `transformers` package to ensure it supports Llama3.1 models. The current version we are using is `4.43.0`.
|
66 |
+
|
67 |
+
2. Use the following Python script to download our BF16 model
|
68 |
+
|
69 |
+
```python
|
70 |
+
from huggingface_hub import snapshot_download
|
71 |
+
snapshot_download(repo_id="shenzhi-wang/Llama3.1-8B-Chinese-Chat", ignore_patterns=["*.gguf"]) # Download our BF16 model without downloading GGUF models.
|
72 |
+
```
|
73 |
+
|
74 |
+
3. Inference with the BF16 model
|
75 |
+
|
76 |
+
```python
|
77 |
+
import torch
|
78 |
+
import transformers
|
79 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
80 |
+
|
81 |
+
model_id = "/Your/Local/Path/to/Llama3.1-8B-Chinese-Chat"
|
82 |
+
dtype = torch.bfloat16
|
83 |
+
|
84 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
85 |
+
model = AutoModelForCausalLM.from_pretrained(
|
86 |
+
model_id,
|
87 |
+
device_map="cuda",
|
88 |
+
torch_dtype=dtype,
|
89 |
+
)
|
90 |
+
|
91 |
+
chat = [
|
92 |
+
{"role": "user", "content": "写一首关于机器å¦ä¹ 的诗。"},
|
93 |
+
]
|
94 |
+
input_ids = tokenizer.apply_chat_template(
|
95 |
+
chat, tokenize=True, add_generation_prompt=True, return_tensors="pt"
|
96 |
+
).to(model.device)
|
97 |
+
|
98 |
+
outputs = model.generate(
|
99 |
+
input_ids,
|
100 |
+
max_new_tokens=8192,
|
101 |
+
do_sample=True,
|
102 |
+
temperature=0.6,
|
103 |
+
top_p=0.9,
|
104 |
+
)
|
105 |
+
response = outputs[0][input_ids.shape[-1] :]
|
106 |
+
print(tokenizer.decode(response, skip_special_tokens=True))
|
107 |
+
```
|
108 |
+
|
109 |
+
## 2.2 Usage of Our GGUF Models
|
110 |
+
|
111 |
+
1. Download our GGUF models from the [gguf_models folder](https://huggingface.co/shenzhi-wang/Llama3.1-8B-Chinese-Chat/tree/main/gguf);
|
112 |
+
2. Use the GGUF models with [LM Studio](https://lmstudio.ai/);
|
113 |
+
3. You can also follow the instructions from https://github.com/ggerganov/llama.cpp/tree/master#usage to use gguf models.
|
114 |
+
|
115 |
+
|
116 |
+
# Citation
|
117 |
+
|
118 |
+
If our Llama3.1-8B-Chinese-Chat is helpful, please kindly cite as:
|
119 |
+
|
120 |
+
```
|
121 |
+
@misc {shenzhi_wang_2024,
|
122 |
+
author = { Wang, Shenzhi and Zheng, Yaowei and Wang, Guoyin and Song, Shiji and Huang, Gao },
|
123 |
+
title = { Llama3.1-8B-Chinese-Chat },
|
124 |
+
year = 2024,
|
125 |
+
url = { https://huggingface.co/shenzhi-wang/Llama3.1-8B-Chinese-Chat },
|
126 |
+
doi = { 10.57967/hf/2779 },
|
127 |
+
publisher = { Hugging Face }
|
128 |
+
}
|
129 |
+
```
|
130 |
+
|
llama3.1-8b-chinese-chat.Q4_0.gguf
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:84a10f0285bf61e15a8b14fe1e9b28bc75d054c163d9ef5346d19a8f108cf2a6
|
3 |
+
size 4661212384
|