Merge branch 'main' of https://huggingface.co/spaces/genaforvena/huivam_finnegans_spaceship
Browse files
app.py
CHANGED
@@ -15,11 +15,15 @@ device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
15 |
model.to(device)
|
16 |
|
17 |
def reply(prompt):
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
21 |
|
22 |
-
|
|
|
23 |
|
24 |
demo = gr.Interface(fn=reply, inputs="text", outputs="text")
|
25 |
demo.launch()
|
|
|
15 |
model.to(device)
|
16 |
|
17 |
def reply(prompt):
|
18 |
+
print("prompt: " + prompt)
|
19 |
+
inputs = tokenizer.encode(prompt, return_tensors="pt")
|
20 |
+
print("tokenized")
|
21 |
+
output = model.generate(inputs, max_new_tokens=100, do_sample=True, top_p=0.95, top_k=50)
|
22 |
+
print("generated")
|
23 |
+
text = tokenizer.decode(output[0], skip_special_tokens=True)
|
24 |
|
25 |
+
print("text: " + text)
|
26 |
+
return text
|
27 |
|
28 |
demo = gr.Interface(fn=reply, inputs="text", outputs="text")
|
29 |
demo.launch()
|