From 286b4cb8f4175865fd0736d36e032ad08ca7ad43 Mon Sep 17 00:00:00 2001 From: liushu <1554987494@qq.com> Date: Wed, 26 Apr 2023 20:02:46 +0800 Subject: [PATCH 1/4] add project --- PROJECT.md | 1 + 1 file changed, 1 insertion(+) diff --git a/PROJECT.md b/PROJECT.md index 14c9940..f5654a6 100644 --- a/PROJECT.md +++ b/PROJECT.md @@ -17,6 +17,7 @@ * [ChatGLM-web](https://github.com/NCZkevin/chatglm-web):基于FastAPI和Vue3搭建的ChatGLM演示网站(支持chatglm流式输出、前端调整模型参数、上下文选择、保存图片、知识库问答等功能) * [ChatGLM-6B-Engineering](https://github.com/LemonQu-GIT/ChatGLM-6B-Engineering):基于 ChatGLM-6B 后期调教,网络爬虫及 [Stable Diffusion](https://github.com/AUTOMATIC1111/stable-diffusion-webui) 实现的网络搜索及图片生成 * [ChatGLM-OpenAI-API](https://github.com/ninehills/chatglm-openai-api): 将 ChatGLM-6B 封装为 OpenAI API 风格,并通过 ngrok/cloudflare 对外提供服务,从而将 ChatGLM 快速集成到 OpenAI 的各种生态中。 +* [ChatSQL](https://github.com/yysirs/ChatSQL): 基于ChatGLM+SBERT实现NL2SQL本地化,并直接连接数据库查询数据返回结果,使得生成的SQL语句更具有实用性。 对 ChatGLM-6B 进行微调的开源项目: * [InstructGLM](https://github.com/yanqiangmiffy/InstructGLM):基于ChatGLM-6B进行指令学习,汇总开源中英文指令数据,基于Lora进行指令数据微调,开放了Alpaca、Belle微调后的Lora权重,修复web_demo重复问题 From 0903d2377f8c283175545471708f208f6e933e31 Mon Sep 17 00:00:00 2001 From: hwaking Date: Fri, 28 Apr 2023 14:51:48 +0800 Subject: [PATCH 2/4] Update web_demo2.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 当前MAX_BOXES与MAX_TURNS不生效导致单次对话不终止显存不断增加最后显存溢出问题,修改最大对话轮数和最大历史对话数量使其生效,逻辑为历史最大对话框记录轮数达到MAX_BOXES时截断历史对话为最近MAX_TURNS数。 --- web_demo2.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/web_demo2.py b/web_demo2.py index 226682e..ce976b3 100644 --- a/web_demo2.py +++ b/web_demo2.py @@ -28,6 +28,8 @@ def predict(input, max_length, top_p, temperature, history=None): with container: if len(history) > 0: + if len(history)>MAX_BOXES: + history = history[-MAX_TURNS:] for i, (query, response) in enumerate(history): message(query, avatar_style="big-smile", key=str(i) + "_user") message(response, avatar_style="bottts", key=str(i)) @@ -66,4 +68,4 @@ if 'state' not in st.session_state: if st.button("发送", key="predict"): with st.spinner("AI正在思考,请稍等........"): # text generation - st.session_state["state"] = predict(prompt_text, max_length, top_p, temperature, st.session_state["state"]) \ No newline at end of file + st.session_state["state"] = predict(prompt_text, max_length, top_p, temperature, st.session_state["state"]) From ce66b0ecb50648666285c6d4b45af8f7414f78e5 Mon Sep 17 00:00:00 2001 From: cifangyiquan Date: Fri, 5 May 2023 22:04:01 +0800 Subject: [PATCH 3/4] fix input unicodedecodererror --- cli_demo.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cli_demo.py b/cli_demo.py index da80fff..3559840 100644 --- a/cli_demo.py +++ b/cli_demo.py @@ -2,6 +2,7 @@ import os import platform import signal from transformers import AutoTokenizer, AutoModel +import readline tokenizer = AutoTokenizer.from_pretrained("THUDM/chatglm-6b", trust_remote_code=True) model = AutoModel.from_pretrained("THUDM/chatglm-6b", trust_remote_code=True).half().cuda() From 486edfed8144112489d620678aee2f7c2d939664 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=93=E9=92=A2=E6=B8=85?= <826206919@qq.com> Date: Mon, 8 May 2023 10:58:24 +0800 Subject: [PATCH 4/4] Update main.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix:修复预测时输入输出长度和超过512时,导致所有预测结果为空的bug --- ptuning/main.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ptuning/main.py b/ptuning/main.py index 43ecdf8..49b08b0 100644 --- a/ptuning/main.py +++ b/ptuning/main.py @@ -382,9 +382,10 @@ def main(): # Evaluation results = {} + max_seq_length = data_args.max_source_length + data_args.max_target_length + 1 if training_args.do_eval: logger.info("*** Evaluate ***") - metrics = trainer.evaluate(metric_key_prefix="eval", do_sample=True, top_p=0.7, max_length=512, temperature=0.95) + metrics = trainer.evaluate(metric_key_prefix="eval", do_sample=True, top_p=0.7, max_length=max_seq_length, temperature=0.95) max_eval_samples = data_args.max_eval_samples if data_args.max_eval_samples is not None else len(eval_dataset) metrics["eval_samples"] = min(max_eval_samples, len(eval_dataset)) @@ -393,8 +394,7 @@ def main(): if training_args.do_predict: logger.info("*** Predict ***") - - predict_results = trainer.predict(predict_dataset, metric_key_prefix="predict", max_length=512, do_sample=True, top_p=0.7, temperature=0.95) + predict_results = trainer.predict(predict_dataset, metric_key_prefix="predict", max_length=max_seq_length, do_sample=True, top_p=0.7, temperature=0.95) metrics = predict_results.metrics max_predict_samples = ( data_args.max_predict_samples if data_args.max_predict_samples is not None else len(predict_dataset)