Views
No views yet
Qwen/Qwen2.5-1.5B-Instruct trained on the ShenLab/MentalChat16K dataset for mental health conversations. It introduces low-rank adapters to query and value projections while keeping the base model frozen, allowing task-specific adaptation with minimal compute overhead.1from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
2import torch
3
4# Path to your fine-tuned model
5finetuned_path = "rohi1810/qwen2.5-mentalchat16k"
6
7# Load tokenizer and model
8tokenizer_main = AutoTokenizer.from_pretrained(finetuned_path)
9model_main = AutoModelForCausalLM.from_pretrained(
10 finetuned_path,
11 dtype=torch.float16, # reduce memory usage
12 device_map="auto" # automatically place layers on available GPU(s)
13)
14
15# Create a text generation pipeline
16generator = pipeline("text-generation", model=model_main, tokenizer=tokenizer_main)
17
18# Example prompt
19prompt = "<s>[INST] User: I've been struggling with my identity as a member of the LGBTQ community. It's been really hard for me to come to terms with who I am and how society perceives me. I feel like I'm constantly judged and misunderstood, which has taken a toll on my mental health. I need help navigating through these challenges and finding acceptance within myself. [/INST]"
20
21# Generate response
22output = generator(prompt, max_new_tokens=150)
23
24# Extract generated text
25response = output[0]["generated_text"].split("[/INST]")[-1].strip()
26print(response)