Skip to content

Commit

Permalink
add web ui postprocess
Browse files Browse the repository at this point in the history
  • Loading branch information
hiyouga committed Jul 22, 2023
1 parent fda94d5 commit 7c76ad6
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ cd ChatGLM-Efficient-Tuning
pip install -r requirements.txt
```

If you want to enable LoRA(QLoRA) or Freeze quantization on Windows, you will be required to install a pre-built version of `bitsandbytes` library, which supports CUDA 11.1 to 12.1.
If you want to enable the quantized LoRA (QLoRA) on the Windows platform, you will be required to install a pre-built version of `bitsandbytes` library, which supports CUDA 11.1 to 12.1.

```bash
pip install https://github.com/jllllll/bitsandbytes-windows-webui/releases/download/wheels/bitsandbytes-0.39.1-py3-none-win_amd64.whl
Expand Down
4 changes: 2 additions & 2 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ cd ChatGLM-Efficient-Tuning
pip install -r requirements.txt
```

对于 Windows 用户,若要启用 LoRA(QLoRA) 或 Freeze 的量化微调,请下载预构建的 `bitsandbytes` 包,目前支持 CUDA 11.1 到12.1。
如果要在 Windows 平台上开启量化 LoRA(QLoRA),需要安装预编译的 `bitsandbytes` 库, 支持 CUDA 11.1 到 12.1.

```bash
pip install https://github.com/jllllll/bitsandbytes-windows-webui/releases/download/wheels/bitsandbytes-0.39.1-py3-none-win_amd64.whl
Expand Down Expand Up @@ -399,7 +399,7 @@ python src/export_model.py \

## 声明

本项目受益于 [ChatGLM-6B](https://github.com/THUDM/ChatGLM-6B)[ChatGLM-Tuning](https://github.com/mymusise/ChatGLM-Tuning)[yuanzhoulvpi2017/zero_nlp](https://github.com/yuanzhoulvpi2017/zero_nlp)感谢作者的付出
本项目受益于 [ChatGLM-6B](https://github.com/THUDM/ChatGLM-6B)[ChatGLM-Tuning](https://github.com/mymusise/ChatGLM-Tuning)[yuanzhoulvpi2017/zero_nlp](https://github.com/yuanzhoulvpi2017/zero_nlp)感谢以上诸位作者的付出

## Star History

Expand Down
8 changes: 8 additions & 0 deletions src/glmtuner/webui/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ def predict(
query, history, prefix, max_length=max_length, top_p=top_p, temperature=temperature
):
response += new_text
response = self.postprocess(response)
new_history = history + [(query, response)]
chatbot[-1] = [query, response]
yield chatbot, new_history

def postprocess(self, response: str) -> str:
blocks = response.split("```")
for i, block in enumerate(blocks):
if i % 2 == 0:
blocks[i] = block.replace("<", "&lt;").replace(">", "&gt;")
return "```".join(blocks)
2 changes: 1 addition & 1 deletion src/glmtuner/webui/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ def create_ui() -> gr.Blocks:
if __name__ == "__main__":
demo = create_ui()
demo.queue()
demo.launch(server_name="0.0.0.0", share=False, inbrowser=True)
demo.launch(server_name="0.0.0.0", server_port=7860, share=False, inbrowser=True)
2 changes: 1 addition & 1 deletion src/train_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
def main():
demo = create_ui()
demo.queue()
demo.launch(server_name="0.0.0.0", share=False, inbrowser=True)
demo.launch(server_name="0.0.0.0", server_port=7860, share=False, inbrowser=True)


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion src/web_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def main():
lang.change(manager.gen_label, [lang], [lang] + list(chat_elems.values()))

demo.queue()
demo.launch(server_name="0.0.0.0", share=False, inbrowser=True)
demo.launch(server_name="0.0.0.0", server_port=7860, share=False, inbrowser=True)


if __name__ == "__main__":
Expand Down

0 comments on commit 7c76ad6

Please sign in to comment.