LeeKinXUn
commited on
Commit
ยท
79afb7d
1
Parent(s):
a1975fd
Add application file
Browse files- app.py +24 -0
- requirements.txt +2 -0
app.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import AutoTokenizer,AutoModel
|
| 2 |
+
import gradio as gr
|
| 3 |
+
from gradio.components import Textbox
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
tokenizer = AutoTokenizer.from_pretrained("THUDM/chatglm-6b-int4", trust_remote_code=True)
|
| 7 |
+
model = AutoModel.from_pretrained("THUDM/chatglm-6b-int4", trust_remote_code=True).half().cuda()
|
| 8 |
+
model.eval()
|
| 9 |
+
|
| 10 |
+
history=[]
|
| 11 |
+
|
| 12 |
+
def ChatGLM_bot(input,history=history):
|
| 13 |
+
if input:
|
| 14 |
+
response,history = model.chat(tokenizer,input,history=history)
|
| 15 |
+
return response
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
inputs = Textbox(line=7,labels='่ฏท่พๅ
ฅไฝ ็้ฎ้ข')
|
| 19 |
+
outputs = Textbox(line=7,labels='ไธ่ฝAI็ๅ็ญ')
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
gr.Interface(fn=ChatGLM_bot,inputs=inputs,outputs=outputs,title='ไธ่ฝ็AIๅฉๆ',
|
| 23 |
+
description='ๆๆฏไธ่ฝ็AIๅฉๆ,ๆจๅฏไปฅ้ฎๆไปปไฝ้ฎ้ข',
|
| 24 |
+
theme=gr.themes.Default()).launch(share=True)
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
protobuf transformers==4.27.1 cpm_kernels
|
| 2 |
+
sentencepiece
|