license: apache-2.0
datasets:
- Helsinki-NLP/opus_paracrawl
- turuta/Multi30k-uk
language:
- uk
- en
metrics:
- bleu
library_name: peft
pipeline_tag: text-generation
base_model: mistralai/Mistral-7B-v0.1
tags:
- translation
model-index:
- name: Dragoman
results:
- task:
type: translation # 必填。示例:automatic-speech-recognition
name: English-Ukrainian Translation # 可选。示例:Speech Recognition
dataset:
type: facebook/flores # 必填。示例:common_voice。使用来自 https://hf.co/datasets 的数据集ID
name: FLORES-101 # 必填。数据集的友好名称。示例:Common Voice (French)
config: eng_Latn-ukr_Cyrl # 可选。用于
load_dataset()
的数据集配置名称。示例:fr in load_dataset("common_voice", "fr")
。更多信息请参阅 datasets
文档:https://huggingface.co/docs/datasets/package_reference/loading_methods#datasets.load_dataset.name
split: devtest # 可选。示例:test
metrics:
- type: bleu # 必填。示例:wer。使用来自 https://hf.co/metrics 的指标ID
value: 32.34 # 必填。示例:20.90
name: Test BLEU # 可选。示例:Test WER
widget:
- text: "[INST] who holds this neighborhood? [/INST]"
Dragoman:英乌机器翻译模型
模型描述
Dragoman 是一个句子级别的英乌翻译模型,达到了当前最先进的性能。它采用两阶段训练流程:首先在清洗过的 Paracrawl 数据集上进行预训练,然后在 turuta/Multi30k-uk 上进行无监督数据筛选。
通过两阶段的数据清洗和筛选方法,我们在 FLORES-101 英乌开发测试子集上取得了 BLEU 值为 32.34
的最优性能。
模型详情
- 开发者: Yurii Paniv, Dmytro Chaplynskyi, Nikita Trynus, Volodymyr Kyrylov
- 模型类型: 翻译模型
- 语言:
- 许可证: Apache 2.0
模型用途
该模型专为句子级别的英语到乌克兰语翻译设计。对于多句文本的翻译性能无法保证,请注意。
运行模型
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
from peft import PeftConfig, PeftModel
import torch
config = PeftConfig.from_pretrained("lang-uk/dragoman")
quant_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.float16,
bnb_4bit_use_double_quant=False,
)
model = AutoModelForCausalLM.from_pretrained(
"mistralai/Mistral-7B-v0.1", quantization_config=quant_config
)
model = PeftModel.from_pretrained(model, "lang-uk/dragoman").to("cuda")
tokenizer = AutoTokenizer.from_pretrained(
"mistralai/Mistral-7B-v0.1", use_fast=False, add_bos_token=False
)
input_text = "[INST] who holds this neighborhood? [/INST]"
input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")
outputs = model.generate(**input_ids, num_beams=10)
print(tokenizer.decode(outputs[0]))
在苹果电脑上使用 mlx-lm 运行模型
我们将 Dragoman PT 适配器合并到基础模型中,并将量化版本上传至 https://huggingface.co/lang-uk/dragoman-4bit。
您可以使用 mlx-lm 运行该模型。
python -m mlx_lm.generate --model lang-uk/dragoman-4bit --prompt '[INST] who holds this neighborhood? [/INST]' --temp 0 --max-tokens 100
MLX 是在搭载 M1 芯片或更新型号的苹果电脑上使用语言模型的推荐方式。
使用 llama.cpp 运行模型
我们将 Dragoman PT 适配器转换为 GGLA 格式。
您可以下载 GGUF 格式的 Mistral-7B-v0.1 基础模型(例如 mistral-7b-v0.1.Q4_K_M.gguf),并使用本仓库中的 ggml-adapter-model.bin
:
./main -ngl 32 -m mistral-7b-v0.1.Q4_K_M.gguf --color -c 4096 --temp 0 --repeat_penalty 1.1 -n -1 -p "[INST] who holds this neighborhood? [/INST]" --lora ./ggml-adapter-model.bin
训练数据集与资源
训练代码: lang-uk/dragoman
清洗后的 Paracrawl: lang-uk/paracrawl_3m
清洗后的 Multi30K: lang-uk/multi30k-extended-17k