Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,6 +6,9 @@ import os
|
|
| 6 |
tokenizer = GPT2Tokenizer.from_pretrained("gpt2")
|
| 7 |
model = GPT2LMHeadModel.from_pretrained("gpt2")
|
| 8 |
|
|
|
|
|
|
|
|
|
|
| 9 |
# Load your custom dataset from the uploaded file (stroon_tutor.txt)
|
| 10 |
def load_custom_dataset(file_path):
|
| 11 |
with open(file_path, "r", encoding="utf-8") as file:
|
|
@@ -46,7 +49,6 @@ trainer = Trainer(
|
|
| 46 |
trainer.train()
|
| 47 |
|
| 48 |
# Example usage of the fine-tuned model after training
|
| 49 |
-
# This is the part where you test the fine-tuned model
|
| 50 |
inputs = tokenizer("Hello, how are you?", return_tensors="pt")
|
| 51 |
outputs = model.generate(**inputs, max_length=50)
|
| 52 |
|
|
|
|
| 6 |
tokenizer = GPT2Tokenizer.from_pretrained("gpt2")
|
| 7 |
model = GPT2LMHeadModel.from_pretrained("gpt2")
|
| 8 |
|
| 9 |
+
# Add a padding token to the tokenizer
|
| 10 |
+
tokenizer.pad_token = tokenizer.eos_token
|
| 11 |
+
|
| 12 |
# Load your custom dataset from the uploaded file (stroon_tutor.txt)
|
| 13 |
def load_custom_dataset(file_path):
|
| 14 |
with open(file_path, "r", encoding="utf-8") as file:
|
|
|
|
| 49 |
trainer.train()
|
| 50 |
|
| 51 |
# Example usage of the fine-tuned model after training
|
|
|
|
| 52 |
inputs = tokenizer("Hello, how are you?", return_tensors="pt")
|
| 53 |
outputs = model.generate(**inputs, max_length=50)
|
| 54 |
|