Update README.md
Browse files
README.md
CHANGED
|
@@ -32,4 +32,91 @@ widget:
|
|
| 32 |
- text: "[INST] who holds this neighborhood? [/INST]"
|
| 33 |
---
|
| 34 |
|
| 35 |
-
# Dragoman: English-Ukrainian Machine Translation Model
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
- text: "[INST] who holds this neighborhood? [/INST]"
|
| 33 |
---
|
| 34 |
|
| 35 |
+
# Dragoman: English-Ukrainian Machine Translation Model
|
| 36 |
+
|
| 37 |
+
## Model Description
|
| 38 |
+
|
| 39 |
+
The Dragoman is a sentence-level SOTA English-Ukrainian translation model. It's trained using a two-phase pipeline: pretraining on cleaned [Paracrawl](https://huggingface.co/datasets/Helsinki-NLP/opus_paracrawl) dataset and unsupervised data selection phase on [turuta/Multi30k-uk](https://huggingface.co/datasets/turuta/Multi30k-uk).
|
| 40 |
+
|
| 41 |
+
By using a two-phase data cleaning and data selection approach we have achieved SOTA performance on FLORES-101 English-Ukrainian devtest subset with **BLEU** `32.34`.
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
## Model Details
|
| 45 |
+
|
| 46 |
+
- **Developed by:** Yurii Paniv, Dmytro Chaplynskyi, Nikita Trynus, Volodymyr Kyrylov
|
| 47 |
+
- **Model type:** Translation model
|
| 48 |
+
- **Language(s):**
|
| 49 |
+
- Source Language: English
|
| 50 |
+
- Target Language: Ukrainian
|
| 51 |
+
- **License:** Apache 2.0
|
| 52 |
+
|
| 53 |
+
## Model Use Cases
|
| 54 |
+
|
| 55 |
+
We designed this model for sentence-level English -> Ukrainian translation.
|
| 56 |
+
Performance on multi-sentence texts is not guaranteed, please be aware.
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
#### Running the model
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
```python
|
| 63 |
+
# pip install bitsandbytes transformers peft torch
|
| 64 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 65 |
+
import torch
|
| 66 |
+
|
| 67 |
+
config = PeftConfig.from_pretrained("lang-uk/dragoman")
|
| 68 |
+
quant_config = BitsAndBytesConfig(
|
| 69 |
+
load_in_4bit=True,
|
| 70 |
+
bnb_4bit_quant_type="nf4",
|
| 71 |
+
bnb_4bit_compute_dtype=float16,
|
| 72 |
+
bnb_4bit_use_double_quant=False,
|
| 73 |
+
)
|
| 74 |
+
|
| 75 |
+
model = MistralForCausalLM.from_pretrained(
|
| 76 |
+
"mistralai/Mistral-7B-v0.1", quantization_config=quant_config
|
| 77 |
+
)
|
| 78 |
+
model = PeftModel.from_pretrained(model, "lang-uk/dragoman").to("cuda")
|
| 79 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
| 80 |
+
"mistralai/Mistral-7B-v0.1", use_fast=False, add_bos_token=False
|
| 81 |
+
)
|
| 82 |
+
|
| 83 |
+
input_text = "[INST] who holds this neighborhood? [/INST]" # model input should adhere to this format
|
| 84 |
+
input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")
|
| 85 |
+
|
| 86 |
+
outputs = model.generate(**input_ids)
|
| 87 |
+
print(tokenizer.decode(outputs[0]))
|
| 88 |
+
```
|
| 89 |
+
|
| 90 |
+
### Training Dataset and Resources
|
| 91 |
+
|
| 92 |
+
Training code: [lang-uk/dragoman](https://github.com/lang-uk/dragoman)
|
| 93 |
+
Cleaned Paracrawl: [lang-uk/paracrawl_3m](https://huggingface.co/datasets/lang-uk/paracrawl_3m)
|
| 94 |
+
Cleaned Multi30K: [lang-uk/multi30k-extended-17k](https://huggingface.co/datasets/lang-uk/multi30k-extended-17k)
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
### Benchmark Results against other models on FLORES-101 devset
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
| **Model** | **BLEU** $\uparrow$ | **spBLEU** | **chrF** | **chrF++** |
|
| 102 |
+
|---------------------------------------------|---------------------|-------------|----------|------------|
|
| 103 |
+
| **Finetuned** | | | | |
|
| 104 |
+
| Dragoman P, 10 beams | 30.38 | 37.93 | 59.49 | 56.41 |
|
| 105 |
+
| Dragoman PT, 10 beams | **32.34** | **39.93** | **60.72**| **57.82** |
|
| 106 |
+
|---------------------------------------------|---------------------|-------------|----------|------------|
|
| 107 |
+
| **Zero shot and few shot** | | | | |
|
| 108 |
+
| LLaMa-2-7B 2-shot | 20.1 | 26.78 | 49.22 | 46.29 |
|
| 109 |
+
| RWKV-5-World-7B 0-shot | 21.06 | 26.20 | 49.46 | 46.46 |
|
| 110 |
+
| gpt-4 10-shot | 29.48 | 37.94 | 58.37 | 55.38 |
|
| 111 |
+
| gpt-4-turbo-preview 0-shot | 30.36 | 36.75 | 59.18 | 56.19 |
|
| 112 |
+
| Google Translate 0-shot | 25.85 | 32.49 | 55.88 | 52.48 |
|
| 113 |
+
|---------------------------------------------|---------------------|-------------|----------|------------|
|
| 114 |
+
| **Pretrained** | | | | |
|
| 115 |
+
| NLLB 3B, 10 beams | 30.46 | 37.22 | 58.11 | 55.32 |
|
| 116 |
+
| OPUS-MT, 10 beams | 32.2 | 39.76 | 60.23 | 57.38 |
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
|