Tong commited on
Commit
e646b3e
·
1 Parent(s): 4d42d17

Add chatglm-6b model

Browse files
Files changed (1) hide show
  1. app.py +15 -4
app.py CHANGED
@@ -1,7 +1,18 @@
1
  import gradio as gr
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
 
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from transformers import AutoTokenizer, AutoModel
3
 
4
+ def chat(text):
5
+ global model, tokenizer
6
+ response, history = model.chat(tokenizer, text, "", 64, 0.7, 0.95)
7
+ return response
8
 
9
+
10
+
11
+
12
+
13
+ if __name__ == '__main__':
14
+ tokenizer = AutoTokenizer.from_pretrained("THUDM/chatglm-6b", trust_remote_code=True)
15
+ model = AutoModel.from_pretrained("THUDM/chatglm-6b", trust_remote_code=True).half().cuda()
16
+ model.eval()
17
+ iface = gr.Interface(fn=chat, inputs="text", outputs="text")
18
+ iface.launch()