RichardErkhov
commited on
uploaded readme
Browse files
README.md
ADDED
@@ -0,0 +1,302 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Quantization made by Richard Erkhov.
|
2 |
+
|
3 |
+
[Github](https://github.com/RichardErkhov)
|
4 |
+
|
5 |
+
[Discord](https://discord.gg/pvy7H8DZMG)
|
6 |
+
|
7 |
+
[Request more models](https://github.com/RichardErkhov/quant_request)
|
8 |
+
|
9 |
+
|
10 |
+
Meta-Llama-3-8B-Instruct-zh-10k - GGUF
|
11 |
+
- Model creator: https://huggingface.co/XavierSpycy/
|
12 |
+
- Original model: https://huggingface.co/XavierSpycy/Meta-Llama-3-8B-Instruct-zh-10k/
|
13 |
+
|
14 |
+
|
15 |
+
| Name | Quant method | Size |
|
16 |
+
| ---- | ---- | ---- |
|
17 |
+
| [Meta-Llama-3-8B-Instruct-zh-10k.Q2_K.gguf](https://huggingface.co/RichardErkhov/XavierSpycy_-_Meta-Llama-3-8B-Instruct-zh-10k-gguf/blob/main/Meta-Llama-3-8B-Instruct-zh-10k.Q2_K.gguf) | Q2_K | 2.96GB |
|
18 |
+
| [Meta-Llama-3-8B-Instruct-zh-10k.IQ3_XS.gguf](https://huggingface.co/RichardErkhov/XavierSpycy_-_Meta-Llama-3-8B-Instruct-zh-10k-gguf/blob/main/Meta-Llama-3-8B-Instruct-zh-10k.IQ3_XS.gguf) | IQ3_XS | 3.28GB |
|
19 |
+
| [Meta-Llama-3-8B-Instruct-zh-10k.IQ3_S.gguf](https://huggingface.co/RichardErkhov/XavierSpycy_-_Meta-Llama-3-8B-Instruct-zh-10k-gguf/blob/main/Meta-Llama-3-8B-Instruct-zh-10k.IQ3_S.gguf) | IQ3_S | 3.43GB |
|
20 |
+
| [Meta-Llama-3-8B-Instruct-zh-10k.Q3_K_S.gguf](https://huggingface.co/RichardErkhov/XavierSpycy_-_Meta-Llama-3-8B-Instruct-zh-10k-gguf/blob/main/Meta-Llama-3-8B-Instruct-zh-10k.Q3_K_S.gguf) | Q3_K_S | 3.41GB |
|
21 |
+
| [Meta-Llama-3-8B-Instruct-zh-10k.IQ3_M.gguf](https://huggingface.co/RichardErkhov/XavierSpycy_-_Meta-Llama-3-8B-Instruct-zh-10k-gguf/blob/main/Meta-Llama-3-8B-Instruct-zh-10k.IQ3_M.gguf) | IQ3_M | 3.52GB |
|
22 |
+
| [Meta-Llama-3-8B-Instruct-zh-10k.Q3_K.gguf](https://huggingface.co/RichardErkhov/XavierSpycy_-_Meta-Llama-3-8B-Instruct-zh-10k-gguf/blob/main/Meta-Llama-3-8B-Instruct-zh-10k.Q3_K.gguf) | Q3_K | 3.74GB |
|
23 |
+
| [Meta-Llama-3-8B-Instruct-zh-10k.Q3_K_M.gguf](https://huggingface.co/RichardErkhov/XavierSpycy_-_Meta-Llama-3-8B-Instruct-zh-10k-gguf/blob/main/Meta-Llama-3-8B-Instruct-zh-10k.Q3_K_M.gguf) | Q3_K_M | 3.74GB |
|
24 |
+
| [Meta-Llama-3-8B-Instruct-zh-10k.Q3_K_L.gguf](https://huggingface.co/RichardErkhov/XavierSpycy_-_Meta-Llama-3-8B-Instruct-zh-10k-gguf/blob/main/Meta-Llama-3-8B-Instruct-zh-10k.Q3_K_L.gguf) | Q3_K_L | 4.03GB |
|
25 |
+
| [Meta-Llama-3-8B-Instruct-zh-10k.IQ4_XS.gguf](https://huggingface.co/RichardErkhov/XavierSpycy_-_Meta-Llama-3-8B-Instruct-zh-10k-gguf/blob/main/Meta-Llama-3-8B-Instruct-zh-10k.IQ4_XS.gguf) | IQ4_XS | 4.18GB |
|
26 |
+
| [Meta-Llama-3-8B-Instruct-zh-10k.Q4_0.gguf](https://huggingface.co/RichardErkhov/XavierSpycy_-_Meta-Llama-3-8B-Instruct-zh-10k-gguf/blob/main/Meta-Llama-3-8B-Instruct-zh-10k.Q4_0.gguf) | Q4_0 | 4.34GB |
|
27 |
+
| [Meta-Llama-3-8B-Instruct-zh-10k.IQ4_NL.gguf](https://huggingface.co/RichardErkhov/XavierSpycy_-_Meta-Llama-3-8B-Instruct-zh-10k-gguf/blob/main/Meta-Llama-3-8B-Instruct-zh-10k.IQ4_NL.gguf) | IQ4_NL | 4.38GB |
|
28 |
+
| [Meta-Llama-3-8B-Instruct-zh-10k.Q4_K_S.gguf](https://huggingface.co/RichardErkhov/XavierSpycy_-_Meta-Llama-3-8B-Instruct-zh-10k-gguf/blob/main/Meta-Llama-3-8B-Instruct-zh-10k.Q4_K_S.gguf) | Q4_K_S | 4.37GB |
|
29 |
+
| [Meta-Llama-3-8B-Instruct-zh-10k.Q4_K.gguf](https://huggingface.co/RichardErkhov/XavierSpycy_-_Meta-Llama-3-8B-Instruct-zh-10k-gguf/blob/main/Meta-Llama-3-8B-Instruct-zh-10k.Q4_K.gguf) | Q4_K | 4.58GB |
|
30 |
+
| [Meta-Llama-3-8B-Instruct-zh-10k.Q4_K_M.gguf](https://huggingface.co/RichardErkhov/XavierSpycy_-_Meta-Llama-3-8B-Instruct-zh-10k-gguf/blob/main/Meta-Llama-3-8B-Instruct-zh-10k.Q4_K_M.gguf) | Q4_K_M | 4.58GB |
|
31 |
+
| [Meta-Llama-3-8B-Instruct-zh-10k.Q4_1.gguf](https://huggingface.co/RichardErkhov/XavierSpycy_-_Meta-Llama-3-8B-Instruct-zh-10k-gguf/blob/main/Meta-Llama-3-8B-Instruct-zh-10k.Q4_1.gguf) | Q4_1 | 4.78GB |
|
32 |
+
| [Meta-Llama-3-8B-Instruct-zh-10k.Q5_0.gguf](https://huggingface.co/RichardErkhov/XavierSpycy_-_Meta-Llama-3-8B-Instruct-zh-10k-gguf/blob/main/Meta-Llama-3-8B-Instruct-zh-10k.Q5_0.gguf) | Q5_0 | 5.21GB |
|
33 |
+
| [Meta-Llama-3-8B-Instruct-zh-10k.Q5_K_S.gguf](https://huggingface.co/RichardErkhov/XavierSpycy_-_Meta-Llama-3-8B-Instruct-zh-10k-gguf/blob/main/Meta-Llama-3-8B-Instruct-zh-10k.Q5_K_S.gguf) | Q5_K_S | 5.21GB |
|
34 |
+
| [Meta-Llama-3-8B-Instruct-zh-10k.Q5_K.gguf](https://huggingface.co/RichardErkhov/XavierSpycy_-_Meta-Llama-3-8B-Instruct-zh-10k-gguf/blob/main/Meta-Llama-3-8B-Instruct-zh-10k.Q5_K.gguf) | Q5_K | 5.34GB |
|
35 |
+
| [Meta-Llama-3-8B-Instruct-zh-10k.Q5_K_M.gguf](https://huggingface.co/RichardErkhov/XavierSpycy_-_Meta-Llama-3-8B-Instruct-zh-10k-gguf/blob/main/Meta-Llama-3-8B-Instruct-zh-10k.Q5_K_M.gguf) | Q5_K_M | 5.34GB |
|
36 |
+
| [Meta-Llama-3-8B-Instruct-zh-10k.Q5_1.gguf](https://huggingface.co/RichardErkhov/XavierSpycy_-_Meta-Llama-3-8B-Instruct-zh-10k-gguf/blob/main/Meta-Llama-3-8B-Instruct-zh-10k.Q5_1.gguf) | Q5_1 | 5.65GB |
|
37 |
+
| [Meta-Llama-3-8B-Instruct-zh-10k.Q6_K.gguf](https://huggingface.co/RichardErkhov/XavierSpycy_-_Meta-Llama-3-8B-Instruct-zh-10k-gguf/blob/main/Meta-Llama-3-8B-Instruct-zh-10k.Q6_K.gguf) | Q6_K | 6.14GB |
|
38 |
+
| [Meta-Llama-3-8B-Instruct-zh-10k.Q8_0.gguf](https://huggingface.co/RichardErkhov/XavierSpycy_-_Meta-Llama-3-8B-Instruct-zh-10k-gguf/blob/main/Meta-Llama-3-8B-Instruct-zh-10k.Q8_0.gguf) | Q8_0 | 7.95GB |
|
39 |
+
|
40 |
+
|
41 |
+
|
42 |
+
|
43 |
+
Original model description:
|
44 |
+
---
|
45 |
+
license: apache-2.0
|
46 |
+
language:
|
47 |
+
- en
|
48 |
+
- zh
|
49 |
+
base_model: meta-llama/Meta-Llama-3-8B-Instruct
|
50 |
+
tags:
|
51 |
+
- text-generation
|
52 |
+
- transformers
|
53 |
+
- lora
|
54 |
+
- llama.cpp
|
55 |
+
- autoawq
|
56 |
+
- auto-gptq
|
57 |
+
datasets:
|
58 |
+
- llamafactory/alpaca_zh
|
59 |
+
- llamafactory/alpaca_gpt4_zh
|
60 |
+
---
|
61 |
+
|
62 |
+
# Meta-Llama-3-8B-Instruct-zh-10k: A Llama🦙 which speaks Chinese / 一只说中文的羊驼🦙
|
63 |
+
|
64 |
+
## Model Details / 模型细节
|
65 |
+
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.
|
66 |
+
|
67 |
+
由于原模型[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` 的由来。
|
68 |
+
|
69 |
+
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.
|
70 |
+
|
71 |
+
为了高效的推理,使用 [llama.cpp](https://github.com/ggerganov/llama.cpp),我们将该模型转化为了gguf格式并量化,从而得到了一个压缩到约 3.18 GB 大小的模型,适合分发在各类设备上。
|
72 |
+
|
73 |
+
### LoRa Hardware / LoRa 硬件
|
74 |
+
- RTX 4090D x 1
|
75 |
+
|
76 |
+
> [!NOTE]
|
77 |
+
> The complete fine-tuning process took approximately 12 hours. / 完整微调过程花费约12小时。
|
78 |
+
|
79 |
+
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).
|
80 |
+
|
81 |
+
更多微调配置可以在我的个人仓库 [Hands-On LoRa](https://github.com/XavierSpycy/hands-on-lora) 或 [Llama3Ops](https://github.com/XavierSpycy/llama-ops) 获得。
|
82 |
+
|
83 |
+
### Other Models / 其他模型
|
84 |
+
- <u>llama.cpp</u>
|
85 |
+
- [Meta-Llama-3-8B-Instruct-zh-10k-GGUF](https://huggingface.co/XavierSpycy/Meta-Llama-3-8B-Instruct-zh-10k-GGUF)
|
86 |
+
|
87 |
+
- <u>AutoAWQ</u>
|
88 |
+
- [Meta-Llama-3-8B-Instruct-zh-10k-AWQ](https://huggingface.co/XavierSpycy/Meta-Llama-3-8B-Instruct-zh-10k-AWQ)
|
89 |
+
|
90 |
+
- <u>AutoGPTQ</u>
|
91 |
+
- [Meta-Llama-3-8B-Instruct-zh-10k-GPTQ](https://huggingface.co/XavierSpycy/Meta-Llama-3-8B-Instruct-zh-10k-GPTQ)
|
92 |
+
|
93 |
+
### Model Developer / 模型开发者
|
94 |
+
- **Pretraining**: Meta
|
95 |
+
- **Fine-tuning**: [XavierSpycy @ GitHub ](https://github.com/XavierSpycy) | [XavierSpycy @ 🤗](https://huggingface.co/XavierSpycy)
|
96 |
+
|
97 |
+
- **预训练**: Meta
|
98 |
+
- **微调**: [XavierSpycy @ GitHub](https://github.com/XavierSpycy) | [XavierSpycy @ 🤗 ](https://huggingface.co/XavierSpycy)
|
99 |
+
|
100 |
+
|
101 |
+
### Usage / 用法
|
102 |
+
This model can be utilized like the original <u>Meta-Llama3</u> but offers enhanced performance in Chinese.
|
103 |
+
|
104 |
+
我们能够像原版的<u>Meta-Llama3</u>一样使用该模型,而它提供了提升后的中文能力。
|
105 |
+
|
106 |
+
#### 1. How to use in transformers
|
107 |
+
```python
|
108 |
+
# !pip install accelerate
|
109 |
+
|
110 |
+
import torch
|
111 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
112 |
+
|
113 |
+
model_id = "XavierSpycy/Meta-Llama-3-8B-Instruct-zh-10k"
|
114 |
+
|
115 |
+
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16, device_map="auto")
|
116 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
117 |
+
|
118 |
+
prompt = "你好,你是谁?"
|
119 |
+
|
120 |
+
messages = [
|
121 |
+
{"role": "system", "content": "你是一个乐于助人的助手。"},
|
122 |
+
{"role": "user", "content": prompt}]
|
123 |
+
|
124 |
+
input_ids = tokenizer.apply_chat_template(
|
125 |
+
messages, add_generation_prompt=True, return_tensors="pt").to(model.device)
|
126 |
+
|
127 |
+
terminators = [tokenizer.eos_token_id, tokenizer.convert_tokens_to_ids("<|eot_id|>")]
|
128 |
+
|
129 |
+
outputs = model.generate(
|
130 |
+
input_ids,
|
131 |
+
max_new_tokens=256,
|
132 |
+
eos_token_id=terminators,
|
133 |
+
do_sample=True,
|
134 |
+
temperature=0.6,
|
135 |
+
top_p=0.9)
|
136 |
+
|
137 |
+
response = outputs[0][input_ids.shape[-1]:]
|
138 |
+
|
139 |
+
print(tokenizer.decode(response, skip_special_tokens=True))
|
140 |
+
# 我是一个人工智能助手,旨在帮助用户解决问题和完成任务。
|
141 |
+
# 我是一个虚拟的人工智能助手,能够通过自然语言处理技术理解用户的需求并为用户提供帮助。
|
142 |
+
```
|
143 |
+
|
144 |
+
#### 2. How to use in llama.cpp / 如何在llama.cpp中使用
|
145 |
+
|
146 |
+
|
147 |
+
```python
|
148 |
+
# CMAKE_ARGS="-DLLAMA_BLAS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS # -DLLAMA_CUDA=on" \
|
149 |
+
# pip install llama-cpp-python \
|
150 |
+
# --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cu121
|
151 |
+
|
152 |
+
# Please download the model weights first. / 请先下载模型���重。
|
153 |
+
|
154 |
+
from llama_cpp import Llama
|
155 |
+
|
156 |
+
llm = Llama(
|
157 |
+
model_path="/path/to/your/model/Meta-Llama-3-8B-Instruct-zh-10k-GGUF/meta-llama-3-8b-instruct-zh-10k.Q8_0.gguf",
|
158 |
+
n_gpu_layers=-1)
|
159 |
+
|
160 |
+
# Alternatively / 或者
|
161 |
+
# llm = Llama.from_pretrained(
|
162 |
+
# repo_id="XavierSpycy/Meta-Llama-3-8B-Instruct-zh-10k-GGUF",
|
163 |
+
# filename="*Q8_0.gguf",
|
164 |
+
# verbose=False
|
165 |
+
# )
|
166 |
+
|
167 |
+
output = llm(
|
168 |
+
"Q: 你好,你是谁?A:", # Prompt
|
169 |
+
max_tokens=256, # Generate up to 32 tokens, set to None to generate up to the end of the context window
|
170 |
+
stop=["Q:", "\n"], # Stop generating just before the model would generate a new question
|
171 |
+
echo=True # Echo the prompt back in the output
|
172 |
+
) # Generate a completion, can also call create_completion
|
173 |
+
|
174 |
+
print(output['choices'][0]['text'].split("A:")[1].strip())
|
175 |
+
|
176 |
+
# 我是一个人工智能聊天机器人,我的名字叫做“智慧助手”,我由一群程序员设计和开发的。我的主要任务就是通过与您交流来帮助您解决问题,为您提供相关的建议和支持。
|
177 |
+
```
|
178 |
+
|
179 |
+
#### 3. How to use with AutoAWQ / 如何与AutoAWQ一起使用
|
180 |
+
```python
|
181 |
+
# !pip install autoawq
|
182 |
+
|
183 |
+
import torch
|
184 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
185 |
+
|
186 |
+
model_id = "XavierSpycy/Meta-Llama-3-8B-Instruct-zh-10k-AWQ"
|
187 |
+
|
188 |
+
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float16, device_map="auto")
|
189 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
190 |
+
|
191 |
+
prompt = "你好,你是谁?"
|
192 |
+
|
193 |
+
messages = [
|
194 |
+
{"role": "system", "content": "你是一个乐于助人的助手。"},
|
195 |
+
{"role": "user", "content": prompt}]
|
196 |
+
|
197 |
+
input_ids = tokenizer.apply_chat_template(
|
198 |
+
messages, add_generation_prompt=True, return_tensors="pt").to(model.device)
|
199 |
+
|
200 |
+
terminators = [tokenizer.eos_token_id, tokenizer.convert_tokens_to_ids("<|eot_id|>")]
|
201 |
+
|
202 |
+
outputs = model.generate(
|
203 |
+
input_ids,
|
204 |
+
max_new_tokens=256,
|
205 |
+
eos_token_id=terminators,
|
206 |
+
do_sample=True,
|
207 |
+
temperature=0.6,
|
208 |
+
top_p=0.9)
|
209 |
+
|
210 |
+
response = outputs[0][input_ids.shape[-1]:]
|
211 |
+
|
212 |
+
print(tokenizer.decode(response, skip_special_tokens=True))
|
213 |
+
# 你好!我是一个人工智能助手,我的目的是帮助人们解决问题,回答问题,提供信息和建议。
|
214 |
+
```
|
215 |
+
|
216 |
+
#### 4. How to use with AutoGPTQ / 如何与AutoGPTQ一起使用
|
217 |
+
```python
|
218 |
+
# !pip install auto-gptq --no-build-isolation
|
219 |
+
|
220 |
+
import torch
|
221 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
222 |
+
|
223 |
+
model_id = "XavierSpycy/Meta-Llama-3-8B-Instruct-zh-10k-GPTQ"
|
224 |
+
|
225 |
+
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float16, device_map="auto")
|
226 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
227 |
+
|
228 |
+
prompt = "什么是机器学习?"
|
229 |
+
|
230 |
+
messages = [
|
231 |
+
{"role": "system", "content": "你是一个乐于助人的助手。"},
|
232 |
+
{"role": "user", "content": prompt}]
|
233 |
+
|
234 |
+
input_ids = tokenizer.apply_chat_template(
|
235 |
+
messages, add_generation_prompt=True, return_tensors="pt").to(model.device)
|
236 |
+
|
237 |
+
terminators = [tokenizer.eos_token_id, tokenizer.convert_tokens_to_ids("<|eot_id|>")]
|
238 |
+
|
239 |
+
outputs = model.generate(
|
240 |
+
input_ids,
|
241 |
+
max_new_tokens=256,
|
242 |
+
eos_token_id=terminators,
|
243 |
+
do_sample=True,
|
244 |
+
temperature=0.6,
|
245 |
+
top_p=0.9)
|
246 |
+
|
247 |
+
response = outputs[0][input_ids.shape[-1]:]
|
248 |
+
|
249 |
+
print(tokenizer.decode(response, skip_special_tokens=True))
|
250 |
+
# 机器学习是人工智能(AI)的一个分支,它允许计算机从数据中学习并改善其性能。它是一种基于算法的方法,用于从数据中识别模式并进行预测。机器学习算法可以从数据中学习,例如文本、图像和音频,并从中获得知识和见解。
|
251 |
+
```
|
252 |
+
|
253 |
+
Further details about the deployment are available in the GitHub repository [Llama3Ops: From LoRa to Deployment with Llama3](https://github.com/XavierSpycy/llama-ops).
|
254 |
+
|
255 |
+
更多关于部署的细节可以在我的个人仓库 [Llama3Ops: From LoRa to Deployment with Llama3](https://github.com/XavierSpycy/llama-ops) 获得。
|
256 |
+
|
257 |
+
## Ethical Considerations, Safety & Risks / 伦理考量、安全性和风险
|
258 |
+
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.
|
259 |
+
|
260 |
+
请参考 [Meta Llama 3's Ethical Considerations](https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct#ethical-considerations-and-limitations),以获取更多细节。关键点包括偏见监控、负责任的使用指南和模型限制的透明度。
|
261 |
+
|
262 |
+
## Limitations / 局限性
|
263 |
+
- The comprehensive abilities of the model have not been fully tested.
|
264 |
+
|
265 |
+
- 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.
|
266 |
+
|
267 |
+
- 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.
|
268 |
+
|
269 |
+
- Additionally, catastrophic forgetting in the fine-tuned model has not been evaluated.
|
270 |
+
|
271 |
+
- 该模型的全面的能力尚未全部测试。
|
272 |
+
|
273 |
+
- 尽管它在中文对话中表现流畅,但需要更多的测评以评估其完整的能力。中文语料库的质量和数量可能都会对模型输出有所制约。
|
274 |
+
|
275 |
+
- 根据目前的观察,它在常识、逻辑、情绪分析、安全性、写作、代码和函数调用上基本达标,然而,在角色扮演、数学、复杂的同文异义等任务上有待提高。
|
276 |
+
|
277 |
+
- 另外,微调模型中的灾难性遗忘尚未评估。
|
278 |
+
|
279 |
+
## Acknowledgements / 致谢
|
280 |
+
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.
|
281 |
+
|
282 |
+
我们感谢 Meta 的开源贡献,这极大地帮助了开发者社区,同时,也感谢致力于提升社区的开发者们的努力。
|
283 |
+
|
284 |
+
## References / 参考资料
|
285 |
+
|
286 |
+
```
|
287 |
+
@article{llama3modelcard,
|
288 |
+
title={Llama 3 Model Card},
|
289 |
+
author={AI@Meta},
|
290 |
+
year={2024},
|
291 |
+
url = {https://github.com/meta-llama/llama3/blob/main/MODEL_CARD.md}}
|
292 |
+
|
293 |
+
@inproceedings{zheng2024llamafactory,
|
294 |
+
title={LlamaFactory: Unified Efficient Fine-Tuning of 100+ Language Models},
|
295 |
+
author={Yaowei Zheng and Richong Zhang and Junhao Zhang and Yanhan Ye and Zheyan Luo and Zhangchi Feng and Yongqiang Ma},
|
296 |
+
booktitle={Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 3: System Demonstrations)},
|
297 |
+
address={Bangkok, Thailand},
|
298 |
+
publisher={Association for Computational Linguistics},
|
299 |
+
year={2024},
|
300 |
+
url={http://arxiv.org/abs/2403.13372}}
|
301 |
+
```
|
302 |
+
|