Upload merged DeepSeek-ZhenHuan model
Browse files
.ipynb_checkpoints/README-checkpoint.md
ADDED
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- zh
|
4 |
+
- en
|
5 |
+
tags:
|
6 |
+
- deepseek
|
7 |
+
- chinese
|
8 |
+
- chat
|
9 |
+
- roleplay
|
10 |
+
license: apache-2.0
|
11 |
+
---
|
12 |
+
|
13 |
+
# 甄嬛 AI 助手模型
|
14 |
+
|
15 |
+
这是一个基于 DeepSeek-7B-Chat 模型微调的甄嬛主题聊天助手。模型具有以下特点:
|
16 |
+
|
17 |
+
## 功能特点
|
18 |
+
|
19 |
+
1. 完美模拟甄嬛的语言风格和性格特征
|
20 |
+
2. 支持中文对话,精通宫廷用语
|
21 |
+
3. 了解甄嬛传的剧情和背景
|
22 |
+
4. 可以进行角色扮演互动
|
23 |
+
|
24 |
+
## 使用方法
|
25 |
+
|
26 |
+
```python
|
27 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
28 |
+
import torch
|
29 |
+
|
30 |
+
# 加载模型和tokenizer
|
31 |
+
model = AutoModelForCausalLM.from_pretrained(
|
32 |
+
"fage13141/zhenhuantimodel",
|
33 |
+
torch_dtype=torch.float16,
|
34 |
+
device_map="auto",
|
35 |
+
trust_remote_code=True
|
36 |
+
)
|
37 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
38 |
+
"fage13141/zhenhuantimodel",
|
39 |
+
use_fast=True,
|
40 |
+
trust_remote_code=True
|
41 |
+
)
|
42 |
+
|
43 |
+
# 开始对话
|
44 |
+
messages = [{"role": "user", "content": "你好,嬛嬛"}]
|
45 |
+
input_text = tokenizer.apply_chat_template(messages, tokenize=False)
|
46 |
+
inputs = tokenizer(input_text, return_tensors="pt").to(model.device)
|
47 |
+
outputs = model.generate(
|
48 |
+
**inputs,
|
49 |
+
max_new_tokens=512,
|
50 |
+
temperature=0.7,
|
51 |
+
top_p=0.9,
|
52 |
+
repetition_penalty=1.1,
|
53 |
+
do_sample=True
|
54 |
+
)
|
55 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
56 |
+
print(response.split("Assistant:")[-1].strip())
|
57 |
+
```
|
58 |
+
|
59 |
+
## 离线使用
|
60 |
+
|
61 |
+
1. 克隆模型到本地:
|
62 |
+
```bash
|
63 |
+
git lfs install
|
64 |
+
git clone https://huggingface.co/fage13141/zhenhuantimodel
|
65 |
+
```
|
66 |
+
|
67 |
+
2. 加载本地模型:
|
68 |
+
```python
|
69 |
+
model_path = "./zhenhuantimodel"
|
70 |
+
model = AutoModelForCausalLM.from_pretrained(
|
71 |
+
model_path,
|
72 |
+
torch_dtype=torch.float16,
|
73 |
+
device_map="auto",
|
74 |
+
trust_remote_code=True,
|
75 |
+
local_files_only=True
|
76 |
+
)
|
77 |
+
```
|
78 |
+
|
79 |
+
## 模型信息
|
80 |
+
|
81 |
+
- 基础模型:DeepSeek-7B-Chat
|
82 |
+
- 训练方法:LoRA
|
83 |
+
- 训练数据:甄嬛传剧本及相关对话
|
84 |
+
- 模型大小:7B参数
|
85 |
+
- 适用场景:聊天、角色扮演
|
86 |
+
|
87 |
+
## 使用限制
|
88 |
+
|
89 |
+
1. 模型输出内容仅供娱乐
|
90 |
+
2. 不得用于生成有害或不当内容
|
91 |
+
3. 不对模型输出的准确性做保证
|
92 |
+
|
93 |
+
## 许可证
|
94 |
+
|
95 |
+
Apache 2.0
|
96 |
+
|