akoksal commited on
Commit
502f071
1 Parent(s): 83adc1c

Add application file

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoTokenizer, pipeline
3
+ import torch
4
+
5
+ tokenizer = AutoTokenizer.from_pretrained("notexist/ttt")
6
+ tdk = pipeline('text-generation', model='notexist/ttt', tokenizer=tokenizer)
7
+
8
+ def predict(name):
9
+ x = tdk(f"<|endoftext|>{name}\n\n",
10
+ do_sample=True,
11
+ max_length=64,
12
+ top_k=75,
13
+ top_p=0.95,
14
+ num_return_sequences=1,
15
+ repetition_penalty=1.3
16
+ )[0]["generated_text"]
17
+
18
+ return x[len(f"<|endoftext|>{name}\n\n"):]
19
+
20
+
21
+
22
+ iface = gr.Interface(fn=predict, inputs="text", outputs="text")
23
+ iface.launch()