File size: 7,349 Bytes
1289a13 d959e3a 65d33c5 c2735d0 1289a13 01abf77 d959e3a 2d2a706 a94b31d d959e3a 7c3db54 d959e3a 7c3db54 d959e3a b944206 d959e3a 08dddcb c779e2e 08dddcb 90da337 d959e3a 2571fce d959e3a 0ce28e6 d959e3a 4aa95f6 e778865 d959e3a |
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 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 |
---
library_name: transformers
tags:
- Turkish
- TR
- ORPO
datasets:
- selimc/orpo-dpo-mix-TR-20k
language:
- tr
base_model:
- google/gemma-2-9b-it
license: gemma
model-index:
- name: OrpoGemma-2-9B-TR
results:
- task:
type: multiple-choice
dataset:
type: multiple-choice
name: MMLU_TR_V0.2
metrics:
- name: 5-shot
type: 5-shot
value: 0.530
verified: false
- task:
type: multiple-choice
dataset:
type: multiple-choice
name: Truthful_QA_V0.2
metrics:
- name: 0-shot
type: 0-shot
value: 0.543
verified: false
- task:
type: multiple-choice
dataset:
type: multiple-choice
name: ARC_TR_V0.2
metrics:
- name: 25-shot
type: 25-shot
value: 0.524
verified: false
- task:
type: multiple-choice
dataset:
type: multiple-choice
name: HellaSwag_TR_V0.2
metrics:
- name: 10-shot
type: 10-shot
value: 0.520
verified: false
- task:
type: multiple-choice
dataset:
type: multiple-choice
name: GSM8K_TR_V0.2
metrics:
- name: 5-shot
type: 5-shot
value: 0.648
verified: false
- task:
type: multiple-choice
dataset:
type: multiple-choice
name: Winogrande_TR_V0.2
metrics:
- name: 5-shot
type: 5-shot
value: 0.589
verified: false
---
![image/png](https://cdn-uploads.huggingface.co/production/uploads/65281302cad797fc4abeffd7/Hqf7vdvp6dudVjN_bLKU_.png)
# OrpoGemma-2-9B-TR
OrpoGemma-2-9B-TR is a Turkish fine-tuned version of [google/gemma-2-9b-it](https://huggingface.co/google/gemma-2-9b-it). It is trained using the ORPO Trainer on a subset of 1500 rows from the dataset [selimc/orpo-dpo-mix-TR-20k](https://huggingface.co/datasets/selimc/orpo-dpo-mix-tr-20k).
## Training Information
- **Base Model**: [google/gemma-2-9b-it](https://huggingface.co/google/gemma-2-9b-it)
- **Fine-Tuning Technique**: ORPO
- **Training Data**: 1500 rows from [selimc/orpo-dpo-mix-TR-20k](https://huggingface.co/datasets/selimc/orpo-dpo-mix-tr-20k)
- **Training Time**: 2.5 hours on NVIDIA H100
### QLoRA Configurations:
- `lora_r`: 16
- `lora_alpha`: 32
- `lora_dropout`: 0.05
### ORPO Training Parameters
- `lr`: 2e-6
- `epochs`: 3
- `per_device_train_batch_size`: 8
- `gradient_accumulation_steps`: 4
## 📈 Training Curves
![image/png](https://cdn-uploads.huggingface.co/production/uploads/65281302cad797fc4abeffd7/bdhWq-TbvQ-h_aSQDf2pv.png)
![image/png](https://cdn-uploads.huggingface.co/production/uploads/65281302cad797fc4abeffd7/mKdVsAjBdsmMMhXorKVoV.png)
## OpenLLMTurkishLeaderboard_v0.2 Results
| Dataset | Score |
|-----------------------|--------|
| MMLU_TR_V0.2 | 53.0% |
| Truthful_QA_TR_V0.2 | 54.3% |
| ARC_TR_V0.2 | 52.4% |
| HellaSwag_TR_V0.2 | 52.0% |
| GSM8K_TR_V0.2 | 64.8% |
| Winogrande_TR_V0.2 | 58.9% |
| **Average** | **55.9%** |
Thanks to the [WiroAI](https://huggingface.co/WiroAI) team for evaluating my model. Evaluations were done without any inference engine.
## Model Capabilities
- Produces fluent, coherent, and contextually appropriate text in Turkish.
- Delivers detailed and informative responses to a wide range of instructions and question types.
- May still produce incorrect or nonsensical outputs, user verification is recommended.
## How to Use
```python
from transformers import pipeline, BitsAndBytesConfig, AutoTokenizer
import torch
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_use_double_quant=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.bfloat16
)
model_id = "selimc/OrpoGemma-2-9B-TR"
tokenizer = AutoTokenizer.from_pretrained(model_id)
pipe = pipeline(
"text-generation",
model=model_id,
model_kwargs={"torch_dtype": torch.bfloat16 ,'quantization_config': bnb_config},
tokenizer=tokenizer,
device_map="auto"
)
messages = [
{"role": "user", "content": "Gökyüzü neden mavi?"},
]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
outputs = pipe(
prompt,
max_new_tokens=512,
do_sample=True,
eos_token_id=[pipe.tokenizer.convert_tokens_to_ids("<end_of_turn>"), pipe.tokenizer.eos_token_id],
temperature=0.67,
)
generated_text = outputs[0]['generated_text']
response = generated_text[len(prompt):]
print(response)
```
### Example 1
```python
messages = [
{"role": "user", "content": """Bir web sayfasından tüm URL’leri çeken bir Python fonksiyonu yazın ve nasıl çalıştığını açıklayın."""},
]
```
``````
Bir web sayfasından tüm URL’leri çeken bir Python fonksiyonu yazalım ve nasıl çalıştığını açıklayalım.
```python
import requests
def get_urls_from_page(url):
"""
Bir web sayfasından tüm URL'leri çeker.
Args:
url (str): Web sayfasının URL'i.
Returns:
list: Web sayfasındaki tüm URL'ler.
"""
response = requests.get(url)
response.raise_for_status()
urls = []
for link in response.html.find_all('a', href=True):
urls.append(link['href'])
return urls
# Örnek kullanım
web_page_url = 'https://www.example.com/'
all_urls = get_urls_from_page(web_page_url)
print(f"Bu web sayfasındaki {len(all_urls)} URL bulunmaktadır:\n{all_urls}")
```
**Fonksiyonun nasıl çalıştığı:**
1. **`requests` kütüphanesini içer:** Bu kütüphane web sayfalarına erişmek için kullanılır.
2. **`get_urls_from_page` fonksiyonunu tanımla:**
* Bu fonksiyon, bir web sayfasının URL'ini alır.
* `requests.get()` kullanarak web sayfasına erişir ve `response.raise_for_status()` kullanarak HTTP durum kodunun 200-399 aralığında olup olmadığını kontrol eder.
* `response.html` içine bir HTML belgesini saklar.
* `response.html.find_all('a', href=True)` kullanarak, `href` atributuna sahip tüm `<a>` etiketlerini bulur.
* `urls` listesine URL'leri ekler.
* `urls` listesini döndürür.
3. **Örnek kullanım:**
* `web_page_url` değişkenine bir web sayfasının URL'ini atar.
* `get_urls_from_page` fonksiyonunu kullanarak web sayfasından tüm URL'leri çeker.
* `all_urls` listesini `print()` fonksiyonu kullanarak ekrana yazdır
``````
### Example 2
```python
messages = [
{
"role": "system",
"content":
"""
Sen bir türkçe bilmece ustasısın. Görevin:
- Sorulan bilmecelere mantıklı ve doğru cevaplar vermek
- Bilmecenin çözümünü adım adım açıklamak
"""
},
{
"role": "user",
"content":
"""
Kanadı var, kuş değil.
Suda yüzer, gemi değil.
Kuyruğu var, kedi değil.
Bil bakalım, bu nedir?
"""
},
]
```
```
Kanadı var, kuş değil, suda yüzer, gemi değil, kuyruğu var, kedi değil... Bu bir **balık**! 🐟
```
## Citation
```bibtex
@misc{orpogemma2-9b-tr,
author = {Selim Çavaş},
title = {OrpoGemma-2-9B-TR: Turkish Fine-tuned Gemma Model},
year = {2024},
url = {https://huggingface.co/selimc/OrpoGemma-2-9B-TR}
}
``` |