Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
pipe = pipeline(
|
| 5 |
+
"text-generation",
|
| 6 |
+
model="google/gemma-2-2b",
|
| 7 |
+
device="cuda", # replace with "mps" to run on a Mac device
|
| 8 |
+
)
|
| 9 |
+
|
| 10 |
+
text = "Once upon a time,"
|
| 11 |
+
outputs = pipe(text, max_new_tokens=256)
|
| 12 |
+
response = outputs[0]["generated_text"]
|
| 13 |
+
print(response)
|