Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,13 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
-
pipe = pipeline("text-generation", model="TinyLlama/TinyLlama-1.1B-Chat-v1.0", device=-1)
|
| 5 |
|
| 6 |
def responder(prompt):
|
| 7 |
-
respuesta = pipe(prompt, max_new_tokens=
|
| 8 |
return respuesta
|
| 9 |
|
| 10 |
with gr.Blocks() as demo:
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
+
import torch
|
| 4 |
+
|
| 5 |
+
device = 0 if torch.cuda.is_available() else -1
|
| 6 |
+
pipe = pipeline("text-generation", model="TinyLlama/TinyLlama-1.1B-Chat-v1.0", device=device)
|
| 7 |
|
|
|
|
| 8 |
|
| 9 |
def responder(prompt):
|
| 10 |
+
respuesta = pipe(prompt, max_new_tokens=80, do_sample=True, temperature=0.7)[0]['generated_text']
|
| 11 |
return respuesta
|
| 12 |
|
| 13 |
with gr.Blocks() as demo:
|