🚀 多纳-llama3-8B指令量化4位模型
本项目是一个专为高效内存使用而设计的模型仓库,提供了 多纳-llama3-8B指令 模型的4位量化版本。多纳模型是一个仅解码器模型,专门针对波斯语数据进行了训练和微调。此外,它还集成了 Flash Attention 2 技术,以实现更快的推理速度。
🚀 快速开始
你可以使用Transformers的自动类和 generate()
函数进行对话推理。以下是一个使用示例:
import torch
import transformers
from transformers import AutoTokenizer, AutoModelForCausalLM
model_path = "amirMohammadi/Dorna-Llama3-8B-Instruct-Quantized4Bit"
tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModelForCausalLM.from_pretrained(
model_path,
torch_dtype=torch.bfloat16,
device_map="auto",
)
messages = [
{"role": "system",
"content": "You are a helpful Persian assistant. Please answer questions in the asked language."},
{"role": "user", "content": "اصفهان بزرگ تر است یا قم؟"},
]
input_ids = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
return_tensors="pt"
).to(model.device)
terminators = [
tokenizer.eos_token_id,
tokenizer.convert_tokens_to_ids("<|eot_id|>")
]
outputs = model.generate(
input_ids,
max_new_tokens=256,
eos_token_id=terminators,
do_sample=True,
temperature=0.6,
top_p=0.9,
)
response = outputs[0][input_ids.shape[-1]:]
print(tokenizer.decode(response, skip_special_tokens=True))
✨ 主要特性
- 减少内存使用:4位量化降低了内存需求。
- 更快的推理速度:Flash Attention 2加速了处理过程。
- 易于部署:无需额外的库,如LlamaCPP或Candle。
- 即插即用:与Langchain、Haystack、LlamaIndex 2等兼容。
- 对Google Colab友好:可以在配备T4 GPU(GPU内存小于15GB)的Google Colab免费层上运行。
📚 详细文档
非量化版本的评估
本模型在各种任务的问题上进行了评估,包括布尔问题、代码生成、长文本响应、数学、新闻问答、释义、常识问答和摘要等。大多数类别通常有两个主要难度级别:困难和简单。
评估包括人工评估和自动评估(以GPT - 4作为评判)。
在以下表格中,Dorna - 8B - it 是 Dorna - Llama3 - 8B - Instruct 的缩写形式。
整体人工评估结果
模型对比 |
参数 |
胜率 % |
败率 % |
平局率 % |
Dorna - 8B - it vs. Meta - Llama - 3 - 8B - Instruct |
8B |
36.94 |
17.39 |
45.67 |
Dorna - 8B - it vs. GPT 3.5 turbo - 1106 |
N.A. |
32.01 |
26.94 |
41.05 |
Dorna - 8B - it vs. Persian Mind |
7B |
55.77 |
10.49 |
33.74 |
基于类别的人工评估结果
每个类别报告了胜/败/平局的百分比。
模型对比 |
参数 |
复杂布尔问题 |
简单布尔问题 |
代码生成 |
一般长文本响应 |
历史长文本响应 |
复杂数学问题 |
简单数学问题 |
复杂新闻问答 |
简单新闻问答 |
释义 |
简单常识问答 |
困难常识问答 |
摘要 |
Dorna - 8B - it vs. Meta - Llama - 3 - 8B - Instruct |
8B |
0.25/0.25/0.5 |
0.28/0.35/0.38 |
0.6/0.1/0.3 |
0.8/0.08/0.12 |
0.4/0.3/0.3 |
0.28/0.08/0.65 |
0.47/0.00/0.53 |
0.55/0.07/0.38 |
0.43/0.15/0.42 |
0.1/0.05/0.85 |
0.31/0.2/0.49 |
0.59/0.13/0.28 |
0.28/0.2/0.53 |
Dorna - 8B - it vs. GPT 3.5 turbo - 1106 |
N.A. |
0.35/0.35/0.3 |
0.3/0.3/0.4 |
0.1/0.3/.06 |
0.2/0.45/0.35 |
0.46/0.27/0.27 |
0.25/0.1/0.65 |
0.05/0.1/0.85 |
0.12/0.35/0.53 |
0.15/0.1/0.75 |
0.25/0.15/0.6 |
0.3/0.32/0.38 |
0.22/0.53/0.25 |
0.35/0.55/0.1 |
Dorna - 8B - it vs. Persian Mind |
7B |
0.47/0.25/0.28 |
0.57/0.15/0.28 |
0.9/0.1/0.0 |
0.82/0.08/0.1 |
0.4/0.17/0.42 |
0.3/0.0/0.7 |
0.22/0.08/0.7 |
0.72/0.07/0.2 |
0.7/0.0/0.3 |
0.7/0.05/0.25 |
0.51/0.12/0.37 |
0.61/0.1/0.29 |
0.93/0.0/0.07 |
自动评估结果
模型对比 |
参数 |
整体胜率 % |
简单问题胜率 % |
困难问题胜率 % |
Dorna - 8B - it vs. Llama 3 base |
8B |
58.96 |
56.00 |
64.49 |
Dorna - 8B - it vs. Part Mistral |
7B |
77.20 |
73.00 |
85.05 |
Dorna - 8B - it vs. Persian Mind |
7B |
90.88 |
87.50 |
97.20 |
Dorna - 8B - it vs. Neuraorca Gemma 7b |
7B |
86.32 |
86.50 |
85.98 |
Dorna - 8B - it vs. Maral 7b |
7B |
97.39 |
97.00 |
98.13 |
Dorna - 8B - it vs. PersianLlama 7b |
7B |
98.70 |
98.00 |
100.00 |
Dorna - 8B - it vs. Aya - 23 - 8B |
8B |
52.77 |
56.50 |
45.79 |
Dorna - 8B - it vs. Aya - 23 - 35B |
35B |
45.93 |
54.00 |
30.84 |
Dorna - 8B - it vs. Command R |
35B |
58.63 |
61.00 |
54.21 |
📄 许可证
本项目使用Llama3许可证。
💬 联系我们
如果您对本模型有任何疑问,可以通过 Hugging Face社区 与我们联系。