File size: 6,675 Bytes
8de0139
 
 
e73c314
bd418f1
 
e43d29f
8de0139
 
 
 
 
 
e43d29f
 
9e7ace1
 
bd418f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8de0139
 
e43d29f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8de0139
 
 
 
 
 
e43d29f
 
 
 
 
8de0139
 
 
 
 
e43d29f
 
8de0139
 
 
 
 
e43d29f
8de0139
e43d29f
8de0139
e43d29f
8de0139
 
 
e43d29f
8de0139
 
 
e43d29f
8de0139
 
 
e43d29f
8de0139
 
 
 
 
e43d29f
8de0139
 
 
 
 
 
 
e43d29f
8de0139
e43d29f
8de0139
 
 
 
 
 
 
 
 
e43d29f
8de0139
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e43d29f
8de0139
 
 
e43d29f
 
 
 
 
 
 
 
8de0139
 
 
 
 
 
 
 
e43d29f
8de0139
 
 
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
---
base_model: google/gemma-2-9b-it
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 `google/gemma-2-9b-it` on Ukrainian language and literature tasks of ZNO (EIE) & NMT dataset to generate step-by-step solution:

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

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

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


## 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 = "google/gemma-2-9b-it"

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/gemma-2-it-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,
        eos_token_id=[101, 107]
    )[0]))
```


## Model Details

### Model Description

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

- **Developed by:** NLP for UA
- **Model type:** Gemma
- **Language(s) (NLP):** Ukrainian (uk)
- **License:** cc-by-nc-4.0
- **Finetuned from model:** google/gemma-2-9b-it

### 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