Views
No views yet
32.34.1# pip install bitsandbytes transformers peft torch
2from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
3from peft import PeftConfig, PeftModel
4import torch
5
6config = PeftConfig.from_pretrained("lang-uk/dragoman")
7quant_config = BitsAndBytesConfig(
8 load_in_4bit=True,
9 bnb_4bit_quant_type="nf4",
10 bnb_4bit_compute_dtype=torch.float16,
11 bnb_4bit_use_double_quant=False,
12)
13
14model = AutoModelForCausalLM.from_pretrained(
15 "mistralai/Mistral-7B-v0.1", quantization_config=quant_config
16)
17model = PeftModel.from_pretrained(model, "lang-uk/dragoman").to("cuda")
18tokenizer = AutoTokenizer.from_pretrained(
19 "mistralai/Mistral-7B-v0.1", use_fast=False, add_bos_token=False
20)
21
22input_text = "[INST] who holds this neighborhood? [/INST]" # model input should adhere to this format
23input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")
24
25outputs = model.generate(**input_ids, num_beams=10)
26print(tokenizer.decode(outputs[0]))python -m mlx_lm.generate --model lang-uk/dragoman-4bit --prompt '[INST] who holds this neighborhood? [/INST]' --temp 0 --max-tokens 100ggml-adapter-model.bin from this repository like this:./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| Model | BLEU $\uparrow$ | spBLEU | chrF | chrF++ |
|---|---|---|---|---|
| Finetuned | ||||
| Dragoman P, 10 beams | 30.38 | 37.93 | 59.49 | 56.41 |
| Dragoman PT, 10 beams | 32.34 | 39.93 | 60.72 | 57.82 |
| --------------------------------------------- | --------------------- | ------------- | ---------- | ------------ |
| Zero shot and few shot | ||||
| LLaMa-2-7B 2-shot | 20.1 | 26.78 | 49.22 | 46.29 |
| RWKV-5-World-7B 0-shot | 21.06 | 26.20 | 49.46 | 46.46 |
| gpt-4 10-shot | 29.48 | 37.94 | 58.37 | 55.38 |
| gpt-4-turbo-preview 0-shot | 30.36 | 36.75 | 59.18 | 56.19 |
| Google Translate 0-shot | 25.85 | 32.49 | 55.88 | 52.48 |
| --------------------------------------------- | --------------------- | ------------- | ---------- | ------------ |
| Pretrained | ||||
| NLLB 3B, 10 beams | 30.46 | 37.22 | 58.11 | 55.32 |
| OPUS-MT, 10 beams | 32.2 | 39.76 | 60.23 | 57.38 |
@inproceedings{paniv-etal-2024-dragoman,
title = "Setting up the Data Printer with Improved {E}nglish to {U}krainian Machine Translation",
author = "Paniv, Yurii and
Chaplynskyi, Dmytro and
Trynus, Nikita and
Kyrylov, Volodymyr",
editor = "Romanyshyn, Mariana and
Romanyshyn, Nataliia and
Hlybovets, Andrii and
Ignatenko, Oleksii",
booktitle = "Proceedings of the Third Ukrainian Natural Language Processing Workshop (UNLP) @ LREC-COLING 2024",
month = may,
year = "2024",
address = "Torino, Italia",
publisher = "ELRA and ICCL",
url = "https://aclanthology.org/2024.unlp-1.6",
pages = "41--50",
abstract = "To build large language models for Ukrainian we need to expand our corpora with large amounts of new algorithmic tasks expressed in natural language. Examples of task performance expressed in English are abundant, so with a high-quality translation system our community will be enabled to curate datasets faster. To aid this goal, we introduce a recipe to build a translation system using supervised finetuning of a large pretrained language model with a noisy parallel dataset of 3M pairs of Ukrainian and English sentences followed by a second phase of training using 17K examples selected by k-fold perplexity filtering on another dataset of higher quality. Our decoder-only model named Dragoman beats performance of previous state of the art encoder-decoder models on the FLORES devtest set.",
}