ztxz16 / fastllm

纯c++的全平台llm加速库,支持python调用,chatglm-6B级模型单卡可达10000+token / s,支持glm, llama, moss基座,手机端流畅运行
Apache License 2.0
3.3k stars 336 forks source link

后续能否支持ChatGLM3的多轮 #419

Open chenyangjun45 opened 7 months ago

chenyangjun45 commented 7 months ago

之前看了一下fastllm的源码,好像还没有支持ChatGLM3的多轮,后续是否有支持ChatGLM3多轮的计划

TylunasLi commented 7 months ago

不知道是不是我的理解有误,看了下现有的源码,C++ API 已经支持ChatGLM3的多轮对话。 如果有需要修改的地方,欢迎贡献代码。

chenyangjun45 commented 7 months ago
class ChatglmModel(BaseModel):
    def process_response(self, response):
        response = response.strip()
        response = response.replace("[[训练时间]]", "2023年")
        return response

    def is_stop(self, token_id):
        return token_id <= 2

    def build_input(self, query, history=None):
        if not history: history = []
        prompt = ""

        for i, (old_query, response) in enumerate(history):
            prompt += "[Round {}]\n问:{}\n答:{}\n".format(i, old_query, response)
        prompt += "[Round {}]\n问:{}\n答:".format(len(history), query)
        return prompt

pyfastllm----fastllm----models.py,这里还是chatglm2的多轮写法呀,没有看到chatglm3的多轮 @TylunasLi