File size: 6,887 Bytes
b97030e
 
 
4ea644b
83aba5e
 
a350d67
b97030e
 
 
 
 
 
e73735f
 
83aba5e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b97030e
 
e73735f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b97030e
 
 
 
 
 
e73735f
 
 
 
 
b97030e
 
 
 
 
e73735f
 
b97030e
 
 
 
 
e73735f
b97030e
e73735f
b97030e
e73735f
b97030e
 
 
e73735f
b97030e
 
 
e73735f
b97030e
 
 
e73735f
b97030e
 
 
 
 
e73735f
b97030e
 
 
 
 
 
 
e73735f
b97030e
e73735f
b97030e
 
 
 
 
 
 
 
 
e73735f
b97030e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e73735f
b97030e
 
 
e73735f
 
 
 
 
 
 
 
b97030e
 
 
 
 
 
 
 
e73735f
b97030e
 
a350d67
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
---
base_model: meta-llama/Llama-3.1-8B-Instruct
library_name: peft
license: cc-by-nc-4.0
language:
- uk
pipeline_tag: text-generation
---

# Model Card for Model ID

<!-- Provide a quick summary of what the model is/does. -->

**This model is CC BY NC 4.0 (allowing only non-commercial use) and should not be used outside of research purposes.**

Presented in [Empowering Smaller Models: Tuning LLaMA and Gemma with Chain-of-Thought for Ukrainian Exam Tasks (arXiv:2503.13988)](https://arxiv.org/abs/2503.13988)

PEFT 4bit tuning of `meta-llama/Llama-3.1-8B-Instruct` on Ukrainian language and literature tasks of ZNO (EIE) & NMT dataset to generate step-by-step solution:

```
<|begin_of_text|><|start_header_id|>system<|end_header_id|>

Cutting Knowledge Date: December 2023
Today Date: 26 Jul 2024

<|eot_id|><|start_header_id|>user<|end_header_id|>

Дайте розгорнуту відповідь на завдання, починаючи з ключового слова "Відповідь:" та використовуючи лише наведені нижче варіанти.

Завдання: З’ясуйте, якими частинами мови є виділені слова в реченні (цифра позначає наступне слово).
Сучасна людина, щоб бути (1)успішною, має вчитися (2)впродовж (3)усього життя, (4)опановуючи нові галузі знань.

Варіанти відповіді:
А – займенник
Б – прикметник
В – форма дієслова (дієприкметник)
Г – форма дієслова (дієприслівник)
Д – прийменник<|eot_id|><|start_header_id|>assistant<|end_header_id|>

Відповідь:
Завдання перевіряє ваше вміння правильно визначати частини мови.
Необхідно бути дуже уважним, тому що частиномовна приналежність конкретного слова часто залежить від контексту. Проаналізуймо кожне із запропонованих слів.
Слово у успішної є прислівником, виражає спосіб дії, не змінюється.
Слово впродовж – це прийменник, службова частина мови, яка разом з відмінковими закінченнями іменників, займенників і числівників виражає відношення між словами в реченні.
Слово усесь – займенник, службова частина мови, який вказує на предмет, але не називає його.
Слово опановуючи – дієприслівник (особлива форма дієслова), відповідає на питання що роблячи?.
Відповідь: 1–Б, 2–Д, 3–А, 4–Г.<|eot_id|>
```


## Inference code

```
import torch
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig

quantization_config = BitsAndBytesConfig(
    load_in_4bit=True,
    bnb_4bit_compute_dtype=torch.float16, # computation in fp16
    bnb_4bit_use_double_quant=True,       # enables double quantization for better accuracy
    bnb_4bit_quant_type="nf4"             # choose "nf4" (normal float4) or other types as supported
)

base_model = "unsloth/Llama-3.1-8B-Instruct"

tokenizer = AutoTokenizer.from_pretrained(base_model, max_sequence_length=3072, model_max_length=3072)
model_base = AutoModelForCausalLM.from_pretrained(base_model, quantization_config=quantization_config, device_map="auto", torch_dtype=torch.float16, use_flash_attention_2=False)
model = PeftModel.from_pretrained(model_base, "NLPForUA/Llama-3.1-8B-Instruct-zno-cot", quantization_config=quantization_config, device_map="auto", torch_dtype=torch.float16, use_flash_attention_2=False)

print(tokenizer.decode(
    model.generate(
        input_ids=inputs,
        max_new_tokens=1024,
        use_cache=True,
        temperature=0.0,
        do_sample=False,
        repetition_penalty=1.0,
        pad_token_id=tokenizer.eos_token_id
    )[0]))
```


## Model Details

### Model Description

<!-- Provide a longer summary of what this model is. -->

- **Developed by:** NLP for UA
- **Model type:** LLaMA
- **Language(s) (NLP):** Ukrainian (uk)
- **License:** cc-by-nc-4.0
- **Finetuned from model:** unsloth/Llama-3.1-8B-Instruct

### Model Sources [optional]

<!-- Provide the basic links for the model. -->

- **Repository:** [github.com/NLPForUA/ZNO](https://github.com/NLPForUA/ZNO)
- **Paper:** [Empowering Smaller Models: Tuning LLaMA and Gemma with Chain-of-Thought for Ukrainian Exam Tasks (arXiv:2503.13988)](https://arxiv.org/abs/2503.13988)

## Uses

### Direct Use

The model can be used directly for generating step-by-step solutions to Ukrainian language and literature exam tasks. Input should follow the format shown in the example above.

### Downstream Use

The model could be fine-tuned further for other Ukrainian language tasks or integrated into educational applications.

### Out-of-Scope Use

This model is specifically trained for Ukrainian exam tasks. It may not perform well on other languages or tasks.

## Bias, Risks, and Limitations

The model may exhibit biases present in the training data. It is crucial to critically evaluate its outputs and be aware of potential inaccuracies. Further analysis is needed to fully characterize biases and limitations.

### Recommendations

Users should be aware of the potential biases and limitations of the model and use its output critically. Further evaluation is needed to fully assess the model's capabilities and limitations.

## Training Details

### Training Data

[More Information Needed - Link to Dataset Card and description]

### Training Procedure

[More Information Needed]

#### Training Hyperparameters

- **Training regime:** 4-bit quantization

#### Speeds, Sizes, Times

[More Information Needed]

## Evaluation

### Testing Data, Factors & Metrics

#### Testing Data

[More Information Needed - Link to Dataset Card and description]

#### Factors

[More Information Needed]

#### Metrics

[More Information Needed]

### Results

#### Summary

[More Information Needed]

## Citation

**BibTeX:**

```bibtex
@article{EmpoweringSmallerModels,
  author = {Mykyta Syromiatnikov, Victoria Ruvinskaya, and Nataliia Komleva},
  title = {Empowering Smaller Models: Tuning LLaMA and Gemma with Chain-of-Thought for Ukrainian Exam Tasks},
  journal = {arXiv preprint arXiv:2503.13988},
  year = {2025}
}
```

**APA:**

[More Information Needed]

## Model Card Contact

[More Information Needed]

### Framework versions

- PEFT 0.14.0