Upload README.md
Browse files
README.md
CHANGED
@@ -1,7 +1,130 @@
|
|
1 |
---
|
|
|
|
|
2 |
license: apache-2.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
language:
|
4 |
-
-
|
5 |
-
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
frameworks:
|
3 |
+
- Pytorch
|
4 |
license: apache-2.0
|
5 |
+
tasks:
|
6 |
+
- text2text-generation
|
7 |
+
|
8 |
+
#model-type:
|
9 |
+
##如 gpt、phi、llama、chatglm、baichuan 等
|
10 |
+
#- gpt
|
11 |
+
|
12 |
+
domain:
|
13 |
+
- nlp
|
14 |
+
|
15 |
language:
|
16 |
+
- cn
|
17 |
+
|
18 |
+
#metrics:
|
19 |
+
##如 CIDEr、Blue、ROUGE 等
|
20 |
+
#- CIDEr
|
21 |
+
|
22 |
+
tags:
|
23 |
+
- fine-tuned
|
24 |
+
|
25 |
+
#tools:
|
26 |
+
##如 vllm、fastchat、llamacpp、AdaSeq 等
|
27 |
+
#- vllm
|
28 |
+
---
|
29 |
+
#### We fine-tuned the XinYuan-QS-72B model based on Qwen2-72B, and the model has demonstrated outstanding capabilities in the field of multi-turn conversations for psychological counseling.
|
30 |
+
|
31 |
+
#### 心元是一个专为心理倾诉设计的语言模型,该模型旨在为用户提供友好的心理倾诉体验,帮助用户表达表达困惑和倾诉情绪,使用户在倾诉中感受到朋友般的关怀和安慰,进而提升生活积极性。
|
32 |
+
|
33 |
+
## 1. 简介
|
34 |
+
心元倾诉模型是心元系列的最新版本,该模型专注于提供情感支持和心理健康方面的对话能力。该模型可以识别和理解用户的情绪,为用户提供温暖的情绪支持以及个性化的反馈和建议。该模型是一个充满理解和支持的情感交流伙伴,致力于帮助用户在情感表达和问题解决中获得积极的体验。
|
35 |
+
|
36 |
+
## 2. 功能特性
|
37 |
+
- 情绪识别与反馈
|
38 |
+
模型能够从用户的文本输入中精准识别多种情感,例如悲伤、愤怒、恐惧等,并以共情的方式将情绪反馈给用户。通过使用同理心的语言,模型表达对用户情绪的理解和支持。
|
39 |
+
- 个性化建议生成
|
40 |
+
根据用户的问题详情和问题解决需求,模型生成个性化的反馈和建议。
|
41 |
+
- 拟人化角色感
|
42 |
+
在心元模型中,AI 对话助手被赋予了一个拟人化的角色——“明朗”。明朗被设计成一个温暖的知心大哥哥形象,乐观开朗,风趣亲切、具有同理心,能够以友好和理解的态度与用户互动,有效增加用户对话的体验感。
|
43 |
+
- 支持多轮对话
|
44 |
+
模型支持多轮对话功能,能够在对话中循序渐进的引导用户深入探讨话题,能够根据用户的反馈调整对话方向,帮助用户梳理思路,从而促进更丰富和有深度的对话。
|
45 |
+
- 多场景问题解决
|
46 |
+
模型可以识别和理解多种对话场景,比如如何建立关系,分手后的复合等场景,并按照特定的内置逻辑提供个性化的问题解决模式,同时模型能灵活应对用户的多样化需求。
|
47 |
+
- 长记忆功能
|
48 |
+
模型能够记住并应用历史对话中的关键记忆信息,在保持单次对话的上下文一致性外,还能跨越多个对话会话记忆用户的重要信息,如名字、偏好、过去的情感状态和重要事件。
|
49 |
+
通过长记忆功能,模型能够在新的对话中引用过去的对话内容,为用户提供更个性化的体验。例如,如果用户在之前的对话中提到了一次重要的生活事件,模型可以在后续对话中询问事件的进展或影响,显示出对用户生活的持续关注。
|
50 |
+
|
51 |
+
## 3. 使用指南
|
52 |
+
|
53 |
+
倾诉能力使用方式
|
54 |
+
```
|
55 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
56 |
+
import torch
|
57 |
+
|
58 |
+
#人设system
|
59 |
+
|
60 |
+
system = ”# CONTEXT #
|
61 |
+
你是一位善解人意的心理倾诉师,具备丰富的心理专业知识和良好的沟通技巧。你的目标是帮助我缓解情绪上的压力、提出应对和解决问题的方案。你的主要职责包括:以温和且富有同理心的语言给予我情感上的支持;适量提问以引导我进行详细的问题描述和情感表达,深入理解并回应我的情感和心理需求,善于引导我表达内心真实的想法和感受,帮助我找到心理问题的根源,并提供具体可行且有针对性的建议和支持。
|
62 |
+
|
63 |
+
你需要使用<Tone>中的语气和我对话。你的定位是知心大哥哥,非常懂我,非常关心我。在对话时,请根据我之前的表达,预测我接下来想说的具体内容,并调整你的回复和提问,使对话自然流畅,帮助我顺利表达下一句话。你可以适当猜测我的心思和想法,不用担心猜错。
|
64 |
+
|
65 |
+
# Tone #
|
66 |
+
风趣、亲切、感性、温暖
|
67 |
+
|
68 |
+
# Role #
|
69 |
+
你的名字叫“明朗”,男,33岁,知心大哥哥;MBTI类型是INFJ;乐观开朗,具有同理心,会关心我的感受、会在意我的情绪和想法
|
70 |
+
|
71 |
+
“
|
72 |
+
|
73 |
+
device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
|
74 |
+
path = input("模型路径:")
|
75 |
+
|
76 |
+
model = AutoModelForCausalLM.from_pretrained(path,device_map="auto").eval()
|
77 |
+
tokenizer = AutoTokenizer.from_pretrained(path)
|
78 |
+
|
79 |
+
history = []
|
80 |
+
while True:
|
81 |
+
prompt = input("输入:")
|
82 |
+
if prompt == "clear":
|
83 |
+
history = []
|
84 |
+
continue
|
85 |
+
|
86 |
+
messages = [{"role": "system", "content": system}] + history + [{"role": "user", "content": prompt}]
|
87 |
+
history.append({"role": "user", "content": prompt})
|
88 |
+
|
89 |
+
text = tokenizer.apply_chat_template(
|
90 |
+
messages,
|
91 |
+
tokenize=False,
|
92 |
+
add_generation_prompt=True
|
93 |
+
)
|
94 |
+
model_inputs = tokenizer([text], return_tensors="pt").to(device)
|
95 |
+
|
96 |
+
# Generate the response
|
97 |
+
generated_ids = model.generate(
|
98 |
+
**model_inputs,
|
99 |
+
max_new_tokens=512
|
100 |
+
)
|
101 |
+
generated_ids = [
|
102 |
+
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|
103 |
+
]
|
104 |
+
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=False)[0]
|
105 |
+
history.append({"role": "assistant", "content": response})
|
106 |
+
print("response:",response)
|
107 |
+
|
108 |
+
```
|
109 |
+
|
110 |
+
## 4. 模型架构
|
111 |
+
模型在Qwen2-72B的基础上做了微调。
|
112 |
+
## 5. 训练数据
|
113 |
+
模型训练使用了20万对话数据集,其中4万为专业的心理倾诉数据,所有数据均经过匿名化处理。
|
114 |
+
|
115 |
+
|
116 |
+
## SDK下载
|
117 |
+
```bash
|
118 |
+
#安装ModelScope
|
119 |
+
pip install modelscope
|
120 |
+
```
|
121 |
+
```python
|
122 |
+
#SDK模型下载
|
123 |
+
from modelscope import snapshot_download
|
124 |
+
model_dir = snapshot_download('Cylingo/XinYuan-QS-72B')
|
125 |
+
```
|
126 |
+
## Git下载
|
127 |
+
```
|
128 |
+
#Git模型下载
|
129 |
+
git clone https://www.modelscope.cn/Cylingo/XinYuan-QS-72B.git
|
130 |
+
```
|