Update README.md
Browse files
README.md
CHANGED
@@ -69,4 +69,94 @@ model-index:
|
|
69 |
type: 5-shot
|
70 |
value: 0.5529
|
71 |
verified: false
|
72 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
type: 5-shot
|
70 |
value: 0.5529
|
71 |
verified: false
|
72 |
+
---
|
73 |
+
|
74 |
+
<img src="https://huggingface.co/Metin/Gemma-2-9b-it-TR-DPO-V1/resolve/main/gemma2_9b_it_dpo_tr_v1.png"
|
75 |
+
alt="Logo of Gemma and country code 'TR' in the bottom right corner" width="420"/>
|
76 |
+
|
77 |
+
# Gemma-2-9b-it-TR-DPO-V1
|
78 |
+
|
79 |
+
Gemma-2-9b-it-TR-DPO-V1 is a finetuned version of [gemma-2-9b-it](https://huggingface.co/google/gemma-2-9b-it).
|
80 |
+
It is trained on a preference dataset which is generated synthetically.
|
81 |
+
|
82 |
+
## Training Info
|
83 |
+
|
84 |
+
- **Base Model**: [gemma-2-9b-it](https://huggingface.co/google/gemma-2-9b-it)
|
85 |
+
- **Training Data**: A synthetically generated preference dataset consisting of 10K samples was used. No proprietary data was utilized.
|
86 |
+
- **Training Time**: 2 hours on a single NVIDIA H100
|
87 |
+
|
88 |
+
- **QLoRA Configs**:
|
89 |
+
- lora_r: 64
|
90 |
+
- lora_alpha: 32
|
91 |
+
- lora_dropout: 0.05
|
92 |
+
- lora_target_linear: true
|
93 |
+
|
94 |
+
The aim was to finetune the model to enhance the output format and content quality for the Turkish language. It is not necessarily smarter than the base model, but its outputs are more likable and preferable.
|
95 |
+
|
96 |
+
Compared to the base model, Gemma-2-9b-it-TR-DPO-V1 is more fluent and coherent in Turkish. It can generate more informative and detailed answers for a given instruction.
|
97 |
+
|
98 |
+
It should be noted that the model will still generate incorrect or nonsensical outputs, so please verify the outputs before using them.
|
99 |
+
|
100 |
+
## How to use
|
101 |
+
|
102 |
+
You can use the below code snippet to use the model:
|
103 |
+
|
104 |
+
```python
|
105 |
+
from transformers import BitsAndBytesConfig
|
106 |
+
import transformers
|
107 |
+
import torch
|
108 |
+
|
109 |
+
bnb_config = BitsAndBytesConfig(
|
110 |
+
load_in_4bit=True,
|
111 |
+
bnb_4bit_use_double_quant=True,
|
112 |
+
bnb_4bit_quant_type="nf4",
|
113 |
+
bnb_4bit_compute_dtype=torch.bfloat16
|
114 |
+
)
|
115 |
+
|
116 |
+
model_id = "Metin/Gemma-2-9b-it-TR-DPO-V1"
|
117 |
+
|
118 |
+
pipeline = transformers.pipeline(
|
119 |
+
"text-generation",
|
120 |
+
model=model_id,
|
121 |
+
model_kwargs={"torch_dtype": torch.bfloat16 ,'quantization_config': bnb_config},
|
122 |
+
device_map="auto",
|
123 |
+
)
|
124 |
+
|
125 |
+
messages = [
|
126 |
+
{"role": "user", "content": "Python'da bir öğenin bir listede geçip geçmediğini nasıl kontrol edebilirim?"},
|
127 |
+
]
|
128 |
+
|
129 |
+
prompt = pipeline.tokenizer.apply_chat_template(
|
130 |
+
messages,
|
131 |
+
tokenize=False,
|
132 |
+
add_generation_prompt=True
|
133 |
+
)
|
134 |
+
|
135 |
+
terminators = [
|
136 |
+
pipeline.tokenizer.eos_token_id,
|
137 |
+
pipeline.tokenizer.convert_tokens_to_ids("<|eot_id|>")
|
138 |
+
]
|
139 |
+
|
140 |
+
outputs = pipeline(
|
141 |
+
prompt,
|
142 |
+
max_new_tokens=512,
|
143 |
+
eos_token_id=terminators,
|
144 |
+
do_sample=True,
|
145 |
+
temperature=0.2,
|
146 |
+
top_p=0.9,
|
147 |
+
)
|
148 |
+
|
149 |
+
print(outputs[0]["generated_text"][len(prompt):])
|
150 |
+
```
|
151 |
+
|
152 |
+
## OpenLLMTurkishLeaderboard_v0.2 benchmark results
|
153 |
+
|
154 |
+
- **MMLU_TR_V0.2**: 51.69%
|
155 |
+
- **Truthful_QA_TR_V0.2**: 54.72%
|
156 |
+
- **ARC_TR_V0.2**: 52.82%
|
157 |
+
- **HellaSwag_TR_V0.2**: 51.16%
|
158 |
+
- **GSM8K_TR_V0.2**: 65.07%
|
159 |
+
- **Winogrande_TR_V0.2**: 55.29%
|
160 |
+
- **Average**: 55.13%
|
161 |
+
|
162 |
+
These scores may differ from what you will get when you run the same benchmarks, as I did not use any inference engine (vLLM, TensorRT-LLM, etc.)
|