File size: 5,758 Bytes
ea29e73
4d9c8eb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ea29e73
4d9c8eb
 
 
 
 
 
 
 
 
 
 
ea29e73
4d9c8eb
 
 
 
 
 
 
 
 
 
 
 
 
3158c60
4d9c8eb
 
3158c60
4d9c8eb
3158c60
4d9c8eb
3158c60
4d9c8eb
3158c60
4d9c8eb
 
 
 
 
3158c60
4d9c8eb
 
 
 
 
 
 
 
 
 
 
3158c60
4d9c8eb
 
 
3158c60
4d9c8eb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
widget:
  - text: "Türkiye'nin başkenti neresidir?"
    example_title: "Başkent"
  - text: "Su kıtlığı sorunlarına karşı çözümler neler olabilir?"
    example_title: "Su Kıtlığı"
  - text: "Yapay zeka işsizlik riski yaratıyor mu?"
    example_title: "Yapay Zeka İşsizlik Riski"
  - text: "Aşağıdaki makale için bir başlık önerin: Bu makale, işletmelerin müşterilerle iletişim kurma biçiminde devrim yaratmada internetin oynadığı rolü incelemektedir."
    example_title: "Başlık Üret"
  - text: "Aşağıdaki bağlamda orijinal bir şey söyleyin: Bir iş görüşmesini yeni bitirdiniz ve işverene bu pozisyona olan ilginizi göstermek istiyorsunuz."
    example_title: "Role Gir"
  - text: "Bir şirketin siber güvenliğini güçlendirmek için alınması gereken önlemler nelerdir?"
    example_title: "Siber Güvenlik"
  - text: "En popüler 5 programlama dili nedir?"
    example_title: "Programlama Dilleri"
  - text: "İnsanlık tarihinde en büyük etki yaratan birkaç icadı say."
    example_title: "İcatlar"
  - text: "Çok sayıda kitap okumak bir çocuğa hangi becerileri kazandırır?"
    example_title: "Kitap Okumak"
  - text: "Şu konuyla ilgili 5 anahtar kelimeden oluşan bir liste oluşturun: iklim değişikliği"
    example_title: "İklim Değişikliği Anahtar Kelimeler"
  - text: "Bilgisayarların faydaları nelerdir?"
    example_title: "Bilgisayarların Faydaları"

license: mit
language:
- tr
pipeline_tag: text-generation
base_model: ytu-ce-cosmos/turkish-gpt2-medium

tags:
- Turkish
- turkish
- gpt2
- instruction-tuning
- alpaca
---
<img src="./model_cover.png" width="400px"/>

# turkish-gpt2-medium-350m-instruct-v0.1

Derived from ytu-ce-cosmos/turkish-gpt2-medium, this model is a Turkish Language Model (LLM) finetuned with a dataset consisting of 35K instructions.
Due to the diverse nature of the training data, which includes websites, books, and other text sources, this model can exhibit biases and generate wrong answers. Users should be aware of these biases and use the model responsibly.

## Quickstart

```python
import torch
from transformers import AutoTokenizer, GPT2LMHeadModel
from transformers import pipeline

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
device_id = 0 if torch.cuda.is_available() else -1

model = GPT2LMHeadModel.from_pretrained("ytu-ce-cosmos/turkish-gpt2-medium-350m-instruct-v0.1").to(device)

tokenizer = AutoTokenizer.from_pretrained("ytu-ce-cosmos/turkish-gpt2-medium-350m-instruct-v0.1")

text_generator = pipeline('text-generation', model=model, tokenizer=tokenizer, device=device_id, max_new_tokens=256)

def get_model_response(instruction):
    instruction_prompt = f"### Kullanıcı:\n{instruction}\n### Asistan:\n"
    result = text_generator(instruction_prompt)
    generated_response = result[0]['generated_text']
    return generated_response[len(instruction_prompt):]

model_response = get_model_response("Evde egzersiz yapmanın avantajlarını açıkla.")
print(model_response)
"""
Evde egzersiz yapmak, gelişmiş fiziksel ve zihinsel sağlık için harika bir yoldur. Düzenli egzersizin, artan enerji seviyeleri, gelişmiş kas gücü ve esnekliği, gelişmiş uyku kalitesi ve daha iyi genel esenlik dahil olmak üzere birçok faydası vardır. Evde egzersiz yapmak ayrıca stresi azaltmaya, kas gücünü artırmaya ve genel sağlığı iyileştirmeye yardımcı olabilir.
"""
```

To use the chat template:

```python
chat_generator = pipeline("conversational", model=model, tokenizer=tokenizer, device=device_id, max_new_tokens=256)

messages = [
    {"role": "user", "content": "Evde egzersiz yapmanın avantajlarını açıkla."}
]

chat_outputs = chat_generator(messages)
print(chat_outputs)
"""
Conversation id: 236ffc4a-2a36-4191-92fb-90d6753df1ae
user: Evde egzersiz yapmanın avantajlarını açıkla.
assistant: Evde egzersiz yapmak, gelişmiş fiziksel ve zihinsel sağlık için sayısız avantaj sunar. Düzenli egzersiz, stresi azaltmaya, kas gücünü artırmaya ve genel sağlığı iyileştirmeye yardımcı olabilir. Ayrıca, evde egzersiz yapmak, daha iyi uyku kalitesi, artan enerji seviyeleri ve gelişmiş bilişsel işlevler gibi daha iyi fiziksel ve zihinsel sağlık sonuçları sağlayabilir. Evde egzersiz yapmak ayrıca, gelişmiş esneklik, denge ve koordinasyon, gelişmiş kalp sağlığı ve gelişmiş kemik sağlığı dahil olmak üzere gelişmiş fiziksel ve zihinsel sağlık yararları sağlayabilir.
"""
```

----------

### Training Details

- We've meticulously fine-tuned this model with a 35,000-instruction Turkish dataset to enhance its precision and adaptability.

- By employing LoRA (Low-Rank Adaptation), we have successfully propelled this model to the pinnacle of its performance capabilities.
- **LoRA** Config:
    * rank = 256
    * lora_alpha = 512
    * lora_dropout = 0.05
    * bias="none"
    * task_type="CAUSAL_LM"

- In addition to monitoring loss, we successfully integrated Rouge calculations into our system's evaluation metrics.
- One of the innovative techniques we adopted involved employing a model to cleanse our data.

*Further details will be provided in the forthcoming paper.*

----------

### Model Description
- **Developed by:** ytu-ce-cosmos
- **Finetuned from model :** `ytu-ce-cosmos/turkish-gpt2-medium`

# Acknowledgments
- Thanks to the generous support from the Hugging Face team, it is possible to download models from their S3 storage 🤗

----------

### Citation
Paper coming soon 😊

----------

### Framework versions

- PEFT 0.9.0

### Contact
COSMOS AI Research Group, Yildiz Technical University Computer Engineering Department <br>
https://cosmos.yildiz.edu.tr/ <br>
cosmos@yildiz.edu.tr