Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,21 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
4 |
-
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
3 |
|
4 |
+
generated_text = tokenizer.decode(output[0])
|
5 |
+
print(generated_text)
|
6 |
|
7 |
+
def GenerateResp(prompt):
|
8 |
+
model = AutoModelForCausalLM.from_pretrained('rexwang8/qilin-lit-6b')
|
9 |
+
tokenizer = AutoTokenizer.from_pretrained('rexwang8/lit-6b')
|
10 |
+
|
11 |
+
#prompt = '''I had eyes but couldn't see Mount Tai!'''
|
12 |
+
|
13 |
+
input_ids = tokenizer.encode(prompt, return_tensors='pt')
|
14 |
+
output = model.generate(input_ids, do_sample=True, temperature=1.0, top_p=0.9, repetition_penalty=1.2, max_length=len(input_ids[0])+100, pad_token_id=tokenizer.eos_token_id)
|
15 |
+
return output
|
16 |
+
|
17 |
+
|
18 |
+
inputbox = gr.Textbox(label="Input",lines=3,placeholder='Type anything. The longer the better since it gives Qilin more context. Qilin is trained on english translated eastern (mostly chinese) webnovels.')
|
19 |
+
output = gr.Textbox(label="GPT-VC",lines=8)
|
20 |
+
iface = gr.Interface(fn=GenerateResp, inputs="inputbox", outputs="output")
|
21 |
+
iface.launch()
|