mirror of https://github.com/THUDM/ChatGLM-6B
Merge branch 'main' of github.com:THUDM/ChatGLM-6B
commit
7836739311
|
@ -35,6 +35,7 @@ ChatGLM-6B 使用了和 ChatGPT 相似的技术,针对中文问答和对话进
|
||||||
* [bibliothecarius](https://github.com/coderabbit214/bibliothecarius):快速构建服务以集成您的本地数据和AI模型,支持ChatGLM等本地化模型接入。
|
* [bibliothecarius](https://github.com/coderabbit214/bibliothecarius):快速构建服务以集成您的本地数据和AI模型,支持ChatGLM等本地化模型接入。
|
||||||
* [闻达](https://github.com/l15y/wenda):大型语言模型调用平台,基于 ChatGLM-6B 实现了类 ChatPDF 功能
|
* [闻达](https://github.com/l15y/wenda):大型语言模型调用平台,基于 ChatGLM-6B 实现了类 ChatPDF 功能
|
||||||
* [JittorLLMs](https://github.com/Jittor/JittorLLMs):最低3G显存或者没有显卡都可运行 ChatGLM-6B FP16, 支持Linux、windows、Mac部署
|
* [JittorLLMs](https://github.com/Jittor/JittorLLMs):最低3G显存或者没有显卡都可运行 ChatGLM-6B FP16, 支持Linux、windows、Mac部署
|
||||||
|
* [ChatGLM-Finetuning](https://github.com/liucongg/ChatGLM-Finetuning):基于ChatGLM-6B模型,进行下游具体任务微调,涉及Freeze、Lora、P-tuning等,并进行实验效果对比。
|
||||||
|
|
||||||
以下是部分针对本项目的教程/文档:
|
以下是部分针对本项目的教程/文档:
|
||||||
* [Windows部署文档](https://github.com/ZhangErling/ChatGLM-6B/blob/main/deployment_windows.md)
|
* [Windows部署文档](https://github.com/ZhangErling/ChatGLM-6B/blob/main/deployment_windows.md)
|
||||||
|
|
16
web_demo2.py
16
web_demo2.py
|
@ -21,7 +21,7 @@ MAX_TURNS = 20
|
||||||
MAX_BOXES = MAX_TURNS * 2
|
MAX_BOXES = MAX_TURNS * 2
|
||||||
|
|
||||||
|
|
||||||
def predict(input, history=None):
|
def predict(input, max_length, top_p, temperature, history=None):
|
||||||
tokenizer, model = get_model()
|
tokenizer, model = get_model()
|
||||||
if history is None:
|
if history is None:
|
||||||
history = []
|
history = []
|
||||||
|
@ -35,7 +35,8 @@ def predict(input, history=None):
|
||||||
message(input, avatar_style="big-smile", key=str(len(history)) + "_user")
|
message(input, avatar_style="big-smile", key=str(len(history)) + "_user")
|
||||||
st.write("AI正在回复:")
|
st.write("AI正在回复:")
|
||||||
with st.empty():
|
with st.empty():
|
||||||
for response, history in model.stream_chat(tokenizer, input, history):
|
for response, history in model.stream_chat(tokenizer, input, history, max_length=max_length, top_p=top_p,
|
||||||
|
temperature=temperature):
|
||||||
query, response = history[-1]
|
query, response = history[-1]
|
||||||
st.write(response)
|
st.write(response)
|
||||||
|
|
||||||
|
@ -49,6 +50,15 @@ prompt_text = st.text_area(label="用户命令输入",
|
||||||
height = 100,
|
height = 100,
|
||||||
placeholder="请在这儿输入您的命令")
|
placeholder="请在这儿输入您的命令")
|
||||||
|
|
||||||
|
max_length = st.sidebar.slider(
|
||||||
|
'max_length', 0, 4096, 2048, step=1
|
||||||
|
)
|
||||||
|
top_p = st.sidebar.slider(
|
||||||
|
'top_p', 0.0, 1.0, 0.6, step=0.01
|
||||||
|
)
|
||||||
|
temperature = st.sidebar.slider(
|
||||||
|
'temperature', 0.0, 1.0, 0.95, step=0.01
|
||||||
|
)
|
||||||
|
|
||||||
if 'state' not in st.session_state:
|
if 'state' not in st.session_state:
|
||||||
st.session_state['state'] = []
|
st.session_state['state'] = []
|
||||||
|
@ -56,4 +66,4 @@ if 'state' not in st.session_state:
|
||||||
if st.button("发送", key="predict"):
|
if st.button("发送", key="predict"):
|
||||||
with st.spinner("AI正在思考,请稍等........"):
|
with st.spinner("AI正在思考,请稍等........"):
|
||||||
# text generation
|
# text generation
|
||||||
st.session_state["state"] = predict(prompt_text, st.session_state["state"])
|
st.session_state["state"] = predict(prompt_text, max_length, top_p, temperature, st.session_state["state"])
|
Loading…
Reference in New Issue