chatglm.cpp
chatglm.cpp copied to clipboard
怎么样模拟steam chat和steam generate
现在只有在interactive model可以利用history, 怎么模拟steam_chat?
https://huggingface.co/THUDM/chatglm-6b/blob/a70fe6b0a3cf1675b3aec07e3b7bb7a8ce73c6ae/modeling_chatglm.py#L1319
https://huggingface.co/THUDM/chatglm-6b/blob/a70fe6b0a3cf1675b3aec07e3b7bb7a8ce73c6ae/modeling_chatglm.py#L1293
流式输出在c++和python api都支持了的,可以参考下对应的例子:
- C++:需要实现streamer,每生成一个token都会回调streamer的put方法。 https://github.com/li-plus/chatglm.cpp/blob/12f6865bf166eb34b5d5876a55e439382ad37648/main.cpp#L194
- Python:支持类似huggingface的stream_chat接口,每次返回一个decode后的token。 https://github.com/li-plus/chatglm.cpp/blob/12f6865bf166eb34b5d5876a55e439382ad37648/examples/cli_chat.py#L72-L83