Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: gemma
|
3 |
+
language:
|
4 |
+
- tr
|
5 |
+
pipeline_tag: text-generation
|
6 |
+
base_model: google/gemma2-9b
|
7 |
+
tags:
|
8 |
+
- Turkish
|
9 |
+
- gemma2
|
10 |
+
- DPO
|
11 |
+
- SFT
|
12 |
+
- conversational
|
13 |
+
- instruction
|
14 |
+
---
|
15 |
+
<!-- <img src="./cosmosLLaMa2_r2.png"/> -->
|
16 |
+
|
17 |
+
|
18 |
+
# Turkish-Gemma-9b-v0.1
|
19 |
+
|
20 |
+
This is the Turkish-Gemma-9b-v0.1. The model has been developed by combining continual pre-training, supervised fine-tuning (SFT), direct preference optimization (DPO), and merge processeses.
|
21 |
+
|
22 |
+
The Turkish-Gemma-9b-v0.1 is designed for Turkish text generation tasks, providing coherent, contextually relevant continuations and answers. Due to the diverse nature of the training data—which includes large-scale pre-training corpora, instruction-tuning data, and human preference data—the model may exhibit biases. Users should be aware of these and deploy the model responsibly.
|
23 |
+
|
24 |
+
You can easily demo the model here: https://cosmos.yildiz.edu.tr/cosmosgemma
|
25 |
+
|
26 |
+
|
27 |
+
#### Transformers pipeline
|
28 |
+
|
29 |
+
```python
|
30 |
+
import transformers
|
31 |
+
import torch
|
32 |
+
model_id = "ytu-ce-cosmos/Turkish-Gemma-9b-v0.1"
|
33 |
+
pipeline = transformers.pipeline(
|
34 |
+
"text-generation",
|
35 |
+
model=model_id,
|
36 |
+
model_kwargs={"torch_dtype": torch.bfloat16},
|
37 |
+
device_map="auto",
|
38 |
+
)
|
39 |
+
messages = [
|
40 |
+
{"role": "user", "content": "Soru: İsmi RD olan bir fonksiyon ona verilen sayının çarpmaya göre tersini döndürmektedir. Örneğin RD(3)=1/3. Buna göre RD(X)=X ifadesini doğru yapan kaç X değeri vardır?"}
|
41 |
+
]
|
42 |
+
|
43 |
+
outputs = pipeline(
|
44 |
+
messages,
|
45 |
+
max_new_tokens=512,
|
46 |
+
do_sample=True,
|
47 |
+
temperature=0.6,
|
48 |
+
top_p=0.9,
|
49 |
+
)
|
50 |
+
print(outputs[0]["generated_text"][-1])
|
51 |
+
# RD(X) = X ifadesi, bir sayının çarpmaya göre tersinin kendisiyle eşit olması anlamına gelir. Yani, X ile 1/X aynı olmalıdır. Bu durum yalnızca X'in karesi 1 olduğunda gerçekleşir:
|
52 |
+
|
53 |
+
# X² = 1
|
54 |
+
|
55 |
+
# Bu denklemin çözümleri:
|
56 |
+
|
57 |
+
# X = 1 ve X = -1
|
58 |
+
|
59 |
+
# Dolayısıyla, RD(X) = X eşitliğini sağlayan *iki* X değeri vardır: *1* ve *-1*.
|
60 |
+
```
|
61 |
+
|
62 |
+
#### Transformers AutoModelForCausalLM
|
63 |
+
|
64 |
+
```python
|
65 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
66 |
+
import torch
|
67 |
+
|
68 |
+
model_id = "ytu-ce-cosmos/Turkish-Gemma-9b-v0.1"
|
69 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
70 |
+
model = AutoModelForCausalLM.from_pretrained(
|
71 |
+
model_id,
|
72 |
+
torch_dtype=torch.bfloat16,
|
73 |
+
device_map="auto",
|
74 |
+
)
|
75 |
+
|
76 |
+
messages = [
|
77 |
+
{"role": "user", "content": "Soru: İsmi RD olan bir fonksiyon ona verilen sayının çarpmaya göre tersini döndürmektedir. Örneğin RD(3)=1/3. Buna göre RD(X)=X ifadesini doğru yapan kaç X değeri vardır?"}
|
78 |
+
]
|
79 |
+
input_ids = tokenizer.apply_chat_template(
|
80 |
+
messages,
|
81 |
+
add_generation_prompt=True,
|
82 |
+
return_tensors="pt"
|
83 |
+
).to(model.device)
|
84 |
+
|
85 |
+
outputs = model.generate(
|
86 |
+
input_ids,
|
87 |
+
max_new_tokens=512,
|
88 |
+
do_sample=False,
|
89 |
+
)
|
90 |
+
response = outputs[0][input_ids.shape[-1]:]
|
91 |
+
print(tokenizer.decode(response, skip_special_tokens=True))
|
92 |
+
# RD(X) = X ifadesi, bir sayının çarpmaya göre tersinin kendisiyle eşit olması anlamına gelir. Yani, X ile 1/X aynı olmalıdır. Bu durum yalnızca X'in karesi 1 olduğunda gerçekleşir:
|
93 |
+
|
94 |
+
# X² = 1
|
95 |
+
|
96 |
+
# Bu denklemin çözümleri:
|
97 |
+
|
98 |
+
# X = 1 ve X = -1
|
99 |
+
|
100 |
+
# Dolayısıyla, RD(X) = X eşitliğini sağlayan *iki* X değeri vardır: *1* ve *-1*.
|
101 |
+
|
102 |
+
```
|
103 |
+
|
104 |
+
|
105 |
+
# Acknowledgments
|
106 |
+
- Thanks to the generous support from the Hugging Face team, it is possible to download models from their S3 storage 🤗
|
107 |
+
- Computing resources used in this work were provided by the National Center for High Performance Computing of Turkey (UHeM) under grant numbers 1016912023 and
|
108 |
+
1018512024
|
109 |
+
|
110 |
+
### Contact
|
111 |
+
COSMOS AI Research Group, Yildiz Technical University Computer Engineering Department <br>
|
112 |
+
https://cosmos.yildiz.edu.tr/ <br>
|
113 | |
114 |
+
|
115 |
+
---
|
116 |
+
license: gemma2
|
117 |
+
---
|