Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,13 +1,13 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
-
|
|
|
|
| 5 |
|
|
|
|
|
|
|
| 6 |
def generate_response(prompt):
|
| 7 |
-
global pipe
|
| 8 |
-
if pipe is None:
|
| 9 |
-
pipe = pipeline("text-generation", model="Qwen/Qwen2.5-0.5B-Instruct", device="cpu")
|
| 10 |
-
|
| 11 |
output = pipe(prompt, max_new_tokens=256, do_sample=True, temperature=0.7)
|
| 12 |
return output[0]['generated_text']
|
| 13 |
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import spaces
|
| 3 |
from transformers import pipeline
|
| 4 |
|
| 5 |
+
# device="cpu" sildik, model GPU'ya yüklenecek
|
| 6 |
+
pipe = pipeline("text-generation", model="Qwen/Qwen2.5-0.5B-Instruct")
|
| 7 |
|
| 8 |
+
# Bu etiket, fonksiyon her çalıştığında arka planda Nvidia RTX 6000'i koda bağlar
|
| 9 |
+
@spaces.GPU
|
| 10 |
def generate_response(prompt):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
output = pipe(prompt, max_new_tokens=256, do_sample=True, temperature=0.7)
|
| 12 |
return output[0]['generated_text']
|
| 13 |
|