ypwhs / CreativeChatGLM

👋 欢迎来到 ChatGLM 创意世界!你可以使用修订和续写的功能来生成创意内容!
Apache License 2.0
241 stars 31 forks source link

ChatGLM2 #35

Closed ypwhs closed 1 year ago

ypwhs commented 1 year ago

代码测试

def test():
    model_name = 'chatglm2-6b'

    predictor = ChatGLM2(model_name)
    top_p = 0.01
    max_length = 128
    temperature = 0.01

    history = []
    line = '你是谁?'
    last_message = '我是张三丰,我是武当派'
    print(line)
    for x in predictor.predict_continue(
            query=line, latest_message=last_message,
            max_length=max_length, top_p=top_p, temperature=temperature,
            allow_generate=[True], history=history, last_state=[[], None, None]):
        print(x[0][-1][1])

我是张三丰,我是武当派的创始人之一。我在中国武术界和太极拳界都有着重要的地位,被尊称为“张三丰先生”。

WebDemo 测试

image

环境

--------------------Collect environment info--------------------
sys.platform: linux
Python: 3.10.10 (main, Mar 21 2023, 18:45:11) [GCC 11.2.0]
Python executable: /home/ypw/miniconda3/bin/python
PyTorch: 2.0.1+cu118
Gradio: 3.34.0
Transformers: 4.30.1
GPU 0: NVIDIA GeForce RTX 4090
------------------------------Done------------------------------
Loading model THUDM/chatglm2-6b