Congliu/Chinese-DeepSeek-R1-Distill-data-110k
Viewer • Updated • 110k • 881 • 764
How to use cvGod/DeepSeek-R1-Psychology-COT with Unsloth Studio:
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for cvGod/DeepSeek-R1-Psychology-COT to start chatting
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for cvGod/DeepSeek-R1-Psychology-COT to start chatting
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for cvGod/DeepSeek-R1-Psychology-COT to start chatting
pip install unsloth
from unsloth import FastModel
model, tokenizer = FastModel.from_pretrained(
model_name="cvGod/DeepSeek-R1-Psychology-COT",
max_seq_length=2048,
)Xinjing-LM 是一个专注于心理健康领域的智能助手,基于 Qwen 模型进行微调和优化,旨在理解复杂的心理学知识、生成高质量文本并支持多轮对话。通过数据蒸馏、指令微调和多轮对话构建等技术,Xinjing-LM 在心理健康场景中表现出色,能够为用户提供准确、流畅且逻辑严谨的心理学相关建议。
我们使用了以下数据集进行模型训练和优化:
Below is the code to fine-tune the model using the unsloth and trl libraries:
# Modules for inference
import unsloth
from unsloth import FastLanguageModel
import torch # Import PyTorch
from trl import SFTTrainer # Trainer for supervised fine-tuning (SFT)
from unsloth import is_bfloat16_supported # Checks if the hardware supports bfloat16 precision
# Hugging Face modules
from transformers import TrainingArguments # Defines training hyperparameters
from datasets import load_dataset # Lets you load fine-tuning datasets
model_id = "cvGod/DeepSeek-R1-Psychology-COT"
model, tokenizer = FastLanguageModel.from_pretrained(
model_name=model_id,
max_seq_length=4096,
dtype=None,
load_in_4bit=True,
)
prompt_style = """以下是一项任务说明,并附带了更详细的背景信息。
请撰写一个满足完成请求的回复。
在回答之前,请仔细考虑问题,并创建一个逐步的思考链,以确保逻辑和准确的回答。
### Instruction:
你是一个专业的心里专家专家,请你根据以下问题回答。
### Question:
{}
### Response:
{}"""
EOS_TOKEN = tokenizer.eos_token
question = """我晚上难以入睡,我认为这是因为我对工作感到压力"""
# Load the inference model using FastLanguageModel (Unsloth optimizes for speed)
FastLanguageModel.for_inference(model) # Unsloth has 2x faster inference!
# Tokenize the input question with a specific prompt format and move it to the GPU
inputs = tokenizer([prompt_style.format(question, "")], return_tensors="pt").to("cuda")
# Generate a response using LoRA fine-tuned model with specific parameters
outputs = model.generate(
input_ids=inputs.input_ids, # Tokenized input IDs
attention_mask=inputs.attention_mask, # Attention mask for padding handling
max_new_tokens=4096, # Maximum length for generated response
use_cache=True, # Enable cache for efficient generation
)
# Decode the generated response from tokenized format to readable text
response = tokenizer.batch_decode(outputs)
# Extract and print only the model's response part after "### Response:"
print(response[0].split("### Response:")[1])