File size: 2,154 Bytes
7440193
 
 
 
 
 
 
ad75e5a
9dcc525
69bcbf3
 
 
 
 
 
5cc7705
 
69bcbf3
 
 
0da3f06
69bcbf3
 
 
 
 
 
 
 
 
 
 
 
ba2da2d
0c7ede3
 
ba2da2d
69bcbf3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9eddab3
69bcbf3
 
 
 
0da3f06
56e6ab5
69bcbf3
 
 
0da3f06
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
---
language:
- tr
tags:
- '#Turkish '
- '#turkish'
- '#gpt2'
pipeline_tag: text-generation
---

# Model Card for Model ID


gpt2 fine-tuned with Turkish corpus data.

Warning: Since the model is trained on a large dataset, it may produce unethical texts. Please be careful in this regard. No liability is accepted.


### Training Data

- Dataset size: ~3 million data (Wikipedia, News and etc.)


## Using model

```Python
from tokenizers import (decoders, models, normalizers, pre_tokenizers, processors, trainers, Tokenizer)
from transformers import GPT2Tokenizer, GPT2TokenizerFast, GPT2Model, GPT2LMHeadModel
from transformers import TextDataset, DataCollatorForLanguageModeling, Trainer, TrainingArguments
import torch

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
print(device)

model = GPT2LMHeadModel.from_pretrained("erythropygia/gpt2-turkish-base").to(device)
tokenizer = GPT2TokenizerFast.from_pretrained("erythropygia/gpt2-turkish-base")
tokenizer.pad_token = tokenizer.eos_token
                                             
def generate_output(text):
    # Input text for completion
    input_text = text

    # Tokenize the input text
    input_ids = tokenizer.encode(input_text, return_tensors="pt").to(device)

    # Generate text completions with specified parameters
    output_text = model.generate(input_ids, 
                                 no_repeat_ngram_size = 3,
                                 max_length=50,
                                 repetition_penalty=1.1,
                                 top_k=100,
                                 top_p=0.7,
                                 temperature = 0.8,
                                 do_sample=True,
                                 num_return_sequences=1)[0]

    # Decode the generated token IDs to text
    completed_text = tokenizer.decode(output_text, skip_special_tokens=False)

    #print("Input Text:", input_text)
    return completed_text

print(generate_output("Türkiye'nin en çok tercih "))
```

#### Training Hyperparameters

- **Epochs:** 4
- **LearningRate:** 4e-4


#### Training Results
 **training_loss:** 3.7089332405925295