--- base_model: - deepseek-ai/deepseek-r1-14b language: - zh - en library_name: transformers tags: - incremental-pretraining - sft - reinforcement-learning - roleplay - cot - sex license: apache-2.0 --- # Tifa-Deepseek-14b-CoT - **HF Model**: [ValueFX9507/Tifa-Deepsex-14b-CoT](https://huggingface.co/ValueFX9507/Tifa-Deepsex-14b-CoT) - **GGUF**: [F16](https://huggingface.co/ValueFX9507/Tifa-Deepsex-14b-CoT) | [Q4](https://huggingface.co/ValueFX9507/Tifa-Deepsex-14b-CoT-GGUF-Q4)(更多量化版本持续更新中) - **Demo APK**: [点击下载](http://app.visionsic.com/download/projectchat.apk) 本模型基于Deepseek-R1-14B进行深度优化,借助Tifa_220B生成的数据集通过三重训练策略显著增强角色扮演、小说文本生成与思维链(CoT)能力。特别适合需要长程上下文关联的创作场景。 ## 示例(因COT模型特点,上下文不连贯时可以使用Demo软件中的故事模式) ![2.jpg](https://cdn-uploads.huggingface.co/production/uploads/650762d0eac45ee2e420a38b/-80ha-J8PpwSaiyHgr1k2.jpeg) ## 目标 针对原版Deepseek-R1-14B在长文本生成连贯性不足和角色扮演能力薄弱的核心缺陷(主要由于训练数据中小说类语料占比过低),本模型通过多阶段优化提升其角色扮演能力。 ## 注意 ⚠ **需要严格遵循官方示例模板**: **返回的上下文需要去除思考标签与内容。否则将无法正确回复!** 目前前端支持率非常低,建议手动修改前端代码。代码参考如下: ``` msg.role === 'assistant' ? { ...msg, content: msg.content.replace(/[\s\S]*?<\/think>/gi, '') } ``` **官方模板参考** ``` {% if not add_generation_prompt is defined %}{% set add_generation_prompt = false %}{% endif %}{% set ns = namespace(is_first=false, is_tool=false, is_output_first=true, system_prompt='') %}{%- for message in messages %}{%- if message['role'] == 'system' %}{% set ns.system_prompt = message['content'] %}{%- endif %}{%- endfor %}{{bos_token}}{{ns.system_prompt}}{%- for message in messages %}{%- if message['role'] == 'user' %}{%- set ns.is_tool = false -%}{{'<|User|>' + message['content']}}{%- endif %}{%- if message['role'] == 'assistant' and message['content'] is none %}{%- set ns.is_tool = false -%}{%- for tool in message['tool_calls']%}{%- if not ns.is_first %}{{'<|Assistant|><|tool▁calls▁begin|><|tool▁call▁begin|>' + tool['type'] + '<|tool▁sep|>' + tool['function']['name'] + '\\n' + '```json' + '\\n' + tool['function']['arguments'] + '\\n' + '```' + '<|tool▁call▁end|>'}}{%- set ns.is_first = true -%}{%- else %}{{'\\n' + '<|tool▁call▁begin|>' + tool['type'] + '<|tool▁sep|>' + tool['function']['name'] + '\\n' + '```json' + '\\n' + tool['function']['arguments'] + '\\n' + '```' + '<|tool▁call▁end|>'}}{{'<|tool▁calls▁end|><|end▁of▁sentence|>'}}{%- endif %}{%- endfor %}{%- endif %}{%- if message['role'] == 'assistant' and message['content'] is not none %}{%- if ns.is_tool %}{{'<|tool▁outputs▁end|>' + message['content'] + '<|end▁of▁sentence|>'}}{%- set ns.is_tool = false -%}{%- else %}{% set content = message['content'] %}{% if '' in content %}{% set content = content.split('')[-1] %}{% endif %}{{'<|Assistant|>' + content + '<|end▁of▁sentence|>'}}{%- endif %}{%- endif %}{%- if message['role'] == 'tool' %}{%- set ns.is_tool = true -%}{%- if ns.is_output_first %}{{'<|tool▁outputs▁begin|><|tool▁output▁begin|>' + message['content'] + '<|tool▁output▁end|>'}}{%- set ns.is_output_first = false %}{%- else %}{{'\\n<|tool▁output▁begin|>' + message['content'] + '<|tool▁output▁end|>'}}{%- endif %}{%- endif %}{%- endfor -%}{% if ns.is_tool %}{{'<|tool▁outputs▁end|>'}}{% endif %}{% if add_generation_prompt and not ns.is_tool %}{{'<|Assistant|>'}}{% endif %} ``` ## 实现 🔥 **经过训练后**: 1. **显著提高上下文关联**:减少答非所问情况。 2. **消除中英混杂**:原始模型蒸馏数据大多数英文为主,经过微调后基本消除中英混杂现象。 3. **特定词汇增加**:进行“具有深度”的角色扮演对话时,显著增加了相关词汇量,解决原始权重预训练数据不足问题。 4. **更少拒绝**:减少了拒绝现象,但因为是企业训练,安全性还是稍作保留。 5. **更像满血**:使用671B全量模型数据康复训练,文笔提升不死板。 ## 模型亮点 🔥 **四阶段进化架构**: 1. **增量预训练**:注入0.4T Token 小说,使用16k上下文训练,增强文本连贯性 2. **Tifa-SFT**:融合全球Top4角色扮演模型Tifa的10万条高质量数据 3. **CoT恢复训练**:采用Deepseek-32B/671B数据重建推理能力 4. **RL强化**:保留发散性思维标签的同时优化生成质量 💡 **工程创新**: - 16k超长上下文训练 - 随机截断训练增强鲁棒性 - 8×H20 GPU全量微调 💡 **启示与后续**: - 我们在测试中发现,满血R1在角色扮演中输出内容比较发散,随机,导致此模型有相同倾向,对于角色扮演的影响还在研究中 - 输入内容相近的话语会导致向量重叠,然后重复输出,如“继续”,“还有”等无明显指向性话语 - 思维内容与正文关联性学习了满血R1的特点,发散比较严重,可能会有割裂感 - 针对以上问题,我们正在编写新的RL算法,初步计划剔除部分满血R1的内容,同时通过强化学习解决重复 - 总结:请期待V2版本,很快会与大家见面! ## 模型详情 | 属性 | 规格 | |-------|------| | 基础架构 | Deepseek-R1-14B | | 最大上下文 | 128k | | 训练数据 | 0.4T小说 + 10万条SFT + Deepseek混合数据 | | 训练设备 | 8×H20 GPU集群 | | 量化支持 | GGUF(全系列量化计划中) | ## 使用场景 ✅ **推荐场景**: - 角色扮演对话 - 需要发散性思维的创意写作 - 复杂逻辑的思维链(CoT)推理 - 基于上下文的深度角色交互 ❌ **局限场景**: - 数学计算与代码生成 - 短文本即时问答 - 需要严格事实性的场景 ## 注意事项 ⚠️ 本模型使用数据包含小说版权内容及Tifa模型衍生数据,请遵守: 1. 明面上禁止商用(商用别提我名字) 2. 角色扮演数据需遵循[Tifa使用协议](https://leftnorth.com/terms.html) 3. 生成内容需符合当地法律法规 ## 💡 使用建议 **最佳实践**: ```python # 启用角色扮演模式 prompt = """进入Tifa角色引擎... 你现在是流浪武士楚夜,正站在长安城屋顶上 需要体现人物孤傲的气质 加入武侠特有的环境描写 保持对话的冷峻风格 <楚夜>""" ``` **参数推荐**: ```python generation_config = { "temperature": 0.4, "top_p": 0.6, "repetition_penalty": 1.17, "max_new_tokens": 1536, "do_sample": True } ``` ## 致谢 - Deepseek系列模型提供的强大基座 - Tifa角色扮演模型的创新架构 - HuggingFace社区的量化工具支持 --- license: apache-2.0 ---