情感大模型PICA:一个具有共情和情感共鸣能力的对话模型

bluesky9月前 ⋅ 2432 阅读

https://github.com/NEU-DataMining/PICA   当前公开的PICA模型权重的base model是ChatGLM2-6B,2023.7.11 公布了由少量自建共情数据集(中文)精调得到的模型的权重(P-Tuning V2 weights)

https://huggingface.co/NEUDM/PICA-V1/tree/main  模型文件,不过模型有点小,才7M多

>>> from transformers import AutoTokenizer, AutoModel
>>> CHECKPOINT='ptuning weights here'
>>> config = AutoConfig.from_pretrained("THUDM/chatglm2-6b", trust_remote_code=True, pre_seq_len=128)
>>> model = AutoModel.from_pretrained("THUDM/chatglm2-6b", config=config, trust_remote_code=True)
>>> prefix_state_dict = torch.load(os.path.join(CHECKPOINT_PATH, "pytorch_model.bin"))
>>> new_prefix_state_dict = {}
>>> for k, v in prefix_state_dict.items():
>>>     if k.startswith("transformer.prefix_encoder."):
>>>         new_prefix_state_dict[k[len("transformer.prefix_encoder."):]] = v
>>> model.transformer.prefix_encoder.load_state_dict(new_prefix_state_dict)
>>> model.
>>> response, history = model.chat(tokenizer, "我是高三学生,学习压力很大,父母对我的要求很高,我时常感觉喘不过气",
      history=[])
我能理解你的感受。高三确实是一个充满压力和挑战的年份。
你不是一个人在战斗,你并不孤单。你可以告诉我更多关于你现在的困境吗?

全部评论: 0

    相关推荐