Spaces:
Runtime error
Runtime error
update
Browse files
app.py
CHANGED
|
@@ -5,19 +5,35 @@ import torch
|
|
| 5 |
tokenizer = AutoTokenizer.from_pretrained("notexist/ttt")
|
| 6 |
tdk = pipeline('text-generation', model='notexist/ttt', tokenizer=tokenizer)
|
| 7 |
|
| 8 |
-
def predict(name):
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
|
|
|
| 17 |
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
|
|
|
| 20 |
|
| 21 |
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
iface.launch()
|
|
|
|
| 5 |
tokenizer = AutoTokenizer.from_pretrained("notexist/ttt")
|
| 6 |
tdk = pipeline('text-generation', model='notexist/ttt', tokenizer=tokenizer)
|
| 7 |
|
| 8 |
+
def predict(name, sl, topk, topp):
|
| 9 |
+
if name == "":
|
| 10 |
+
x = tdk(f"<|endoftext|>",
|
| 11 |
+
do_sample=True,
|
| 12 |
+
max_length=64,
|
| 13 |
+
top_k=topk,
|
| 14 |
+
top_p=topp,
|
| 15 |
+
num_return_sequences=1,
|
| 16 |
+
repetition_penalty=sl
|
| 17 |
+
)[0]["generated_text"]
|
| 18 |
|
| 19 |
+
return x[len(f"<|endoftext|>"):]
|
| 20 |
+
else:
|
| 21 |
+
x = tdk(f"<|endoftext|>{name}\n\n",
|
| 22 |
+
do_sample=True,
|
| 23 |
+
max_length=64,
|
| 24 |
+
top_k=topk,
|
| 25 |
+
top_p=topp,
|
| 26 |
+
num_return_sequences=1,
|
| 27 |
+
repetition_penalty=sl
|
| 28 |
+
)[0]["generated_text"]
|
| 29 |
|
| 30 |
+
return x[len(f"<|endoftext|>{name}\n\n"):]
|
| 31 |
|
| 32 |
|
| 33 |
+
|
| 34 |
+
iface = gr.Interface(fn=predict, inputs=["text",\
|
| 35 |
+
gr.inputs.Slider(0, 3, default=1.1, label="repetition_penalty"),\
|
| 36 |
+
gr.inputs.Slider(0, 100, default=75, label="top_k"),\
|
| 37 |
+
gr.inputs.Slider(0, 1, default=0.95, label="top_p")]
|
| 38 |
+
, outputs="text")
|
| 39 |
iface.launch()
|