🚀 LLaMA-3.1-8B-Instruct-Uz模型
LLaMA-3.1-8B-Instruct-Uz模型是一个专为乌兹别克语自然语言处理任务设计的模型。它通过使用公开可用和合成构建的乌兹别克语及英语数据进行指令微调,在保留原始知识的同时增强了能力,可广泛应用于机器翻译、摘要生成和对话系统等任务。
🚀 快速开始
LLaMA-3.1-8B-Instruct-Uz模型可以结合transformers
库使用,也可以使用原始的llama
代码库。
使用transformers库
从transformers >= 4.43.0
版本开始,你可以使用Transformers的pipeline
抽象方法或利用Auto
类结合generate()
函数进行对话推理。
确保通过以下命令更新你的transformers库:
pip install --upgrade transformers
import transformers
import torch
model_id = "behbudiy/Llama-3.1-8B-Instruct-Uz"
pipeline = transformers.pipeline(
"text-generation",
model=model_id,
model_kwargs={"torch_dtype": torch.bfloat16},
device_map="auto",
)
messages = [
{"role": "system", "content": "Berilgan gap bo'yicha hissiyot tahlilini bajaring."},
{"role": "user", "content": "Men bu filmni yaxshi ko'raman!"},
]
outputs = pipeline(
messages,
max_new_tokens=256,
)
print(outputs[0]["generated_text"][-1])
💡 使用建议
你可以在huggingface-llama-recipes
中找到关于如何在本地使用该模型、使用torch.compile()
、辅助生成、量化等详细的使用方法。
使用原始llama
代码库
请遵循仓库中的说明进行操作。
✨ 主要特性
- 多语言支持:支持乌兹别克语和英语,可处理多种自然语言处理任务。
- 指令微调:通过混合乌兹别克语和英语数据进行指令微调,增强了模型的能力。
- 广泛应用:适用于机器翻译、摘要生成、对话系统等多种自然语言处理任务。
📦 模型信息
属性 |
详情 |
许可证 |
llama3.1 |
支持语言 |
uz, en |
基础模型 |
models/Meta-Llama-3.1-8B-Instruct |
库名称 |
transformers |
标签 |
llama, text-generation-inference, summarization, translation, question-answering |
数据集 |
yahma/alpaca-cleaned, behbudiy/alpaca-cleaned-uz, behbudiy/translation-instruction |
评估指标 |
bleu, comet, accuracy |
任务类型 |
text-generation |
📊 性能对比
模型名称 |
乌兹别克语到英语的BLEU分数(单样本) |
英语到乌兹别克语的BLEU分数(单样本) |
COMET分数(乌兹别克语到英语) |
COMET分数(英语到乌兹别克语) |
乌兹别克语情感分析 |
乌兹别克语新闻分类 |
MMLU(英语,5样本) |
Llama-3.1 8B Instruct |
23.74 |
6.72 |
84.30 |
82.70 |
68.96 |
55.41 |
65.77 |
Llama-3.1 8B Instruct Uz |
27.42 |
11.58 |
85.63 |
86.53 |
82.42 |
60.84 |
62.78 |
Mistral 7B Instruct |
7.47 |
0.67 |
68.14 |
45.58 |
62.02 |
47.52 |
61.07 |
Mistral 7B Instruct Uz |
29.39 |
16.77 |
86.91 |
88.75 |
79.13 |
59.38 |
55.72 |
Mistral Nemo Instruct |
25.68 |
9.79 |
85.56 |
85.04 |
72.47 |
49.24 |
67.62 |
Mistral Nemo Instruct Uz |
30.49 |
15.52 |
87.04 |
88.01 |
82.05 |
58.2 |
67.36 |
Google Translate |
41.18 |
22.98 |
89.16 |
90.67 |
— |
— |
— |
结果表明,针对乌兹别克语优化的模型在翻译基准测试(BLEU和COMET)、乌兹别克语情感分析和新闻分类任务中始终优于其基础版本。此外,在衡量英语多任务通用语言理解能力的MMLU基准测试中,微调后的模型性能没有显著下降。
🔧 技术细节
开发团队
评估方法
翻译任务
使用FLORES+乌兹别克语 - 英语 / 英语 - 乌兹别克语数据集进行评估,将开发集和测试集合并以创建更大的评估数据。使用以下提示进行单样本乌兹别克语到英语的评估(英语到乌兹别克语评估时,交换“English”和“Uzbek”的位置):
prompt = f'''You are a professional Uzbek-English translator. Your task is to accurately translate the given Uzbek text into English.
Instructions:
1. Translate the text from Uzbek to English.
2. Maintain the original meaning and tone.
3. Use appropriate English grammar and vocabulary.
4. If you encounter an ambiguous or unfamiliar word, provide the most likely translation based on context.
5. Output only the English translation, without any additional comments.
Example:
Uzbek: "Bugun ob-havo juda yaxshi, quyosh charaqlab turibdi."
English: "The weather is very nice today, the sun is shining brightly."
Now, please translate the following Uzbek text into English:
"{sentence}"
'''
乌兹别克语情感分析
使用risqaliyevds/uzbek-sentiment-analysis数据集进行评估,使用GPT-4o API创建二元标签(0: 负面,1: 正面)。使用以下提示进行评估:
prompt = f'''Given the following text, determine the sentiment as either 'Positive' or 'Negative.' Respond with only the word 'Positive' or 'Negative' without any additional text or explanation.
Text: {text}"
'''
乌兹别克语新闻分类
使用risqaliyevds/uzbek-zero-shot-classification数据集,要求模型使用以下提示预测新闻类别:
prompt = f'''Classify the given Uzbek news article into one of the following categories. Provide only the category number as the answer.
Categories:
0 - Politics (Siyosat)
1 - Economy (Iqtisodiyot)
2 - Technology (Texnologiya)
3 - Sports (Sport)
4 - Culture (Madaniyat)
5 - Health (Salomatlik)
6 - Family and Society (Oila va Jamiyat)
7 - Education (Ta'lim)
8 - Ecology (Ekologiya)
9 - Foreign News (Xorijiy Yangiliklar)
Now classify this article:
"{text}"
Answer (number only):"
'''
MMLU评估
在MMLU上进行5样本评估,使用以下模板并提取模型生成的第一个标记来衡量准确率:
template = "The following are multiple choice questions (with answers) about [subject area].
[Example question 1]
A. text
B. text
C. text
D. text
Answer: [Correct answer letter]
.
.
.
[Example question 5]
A. text
B. text
C. text
D. text
Answer: [Correct answer letter]
Now, let's think step by step and then provide only the letter corresponding to the correct answer for the below question, without any additional explanation or comments.
[Actual MMLU test question]
A. text
B. text
C. text
D. text
Answer:"
📚 更多信息
更多详细信息和示例,请参考基础模型:
https://huggingface.co/meta-llama/Meta-Llama-3.1-8B-Instruct
📄 许可证
该模型使用的许可证为llama3.1。