Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,9 +4,12 @@ import torch
|
|
| 4 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 5 |
|
| 6 |
# Load the model and tokenizer
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
tokenizer = AutoTokenizer.from_pretrained("openai-community/gpt2-medium", clean_up_tokenization_spaces=True)
|
| 8 |
|
| 9 |
-
model = AutoModelForCausalLM.from_pretrained("openai-community/gpt2-medium")
|
| 10 |
|
| 11 |
# Define the initial prompt for the system
|
| 12 |
system_prompt = """
|
|
|
|
| 4 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 5 |
|
| 6 |
# Load the model and tokenizer
|
| 7 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 8 |
+
model = AutoModelForCausalLM.from_pretrained("openai-community/gpt2-medium")
|
| 9 |
+
model.to(device)
|
| 10 |
+
|
| 11 |
tokenizer = AutoTokenizer.from_pretrained("openai-community/gpt2-medium", clean_up_tokenization_spaces=True)
|
| 12 |
|
|
|
|
| 13 |
|
| 14 |
# Define the initial prompt for the system
|
| 15 |
system_prompt = """
|