Update README.md
Browse files
README.md
CHANGED
@@ -76,6 +76,59 @@ ManoVyadh is a LLM for mental health counselling.
|
|
76 |
- cannot be used to generate text for research or academic purposes
|
77 |
|
78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
# Bias, Risks, and Limitations
|
80 |
|
81 |
Significant research has explored bias and fairness issues with language models (see, e.g., [Sheng et al. (2021)](https://aclanthology.org/2021.acl-long.330.pdf) and [Bender et al. (2021)](https://dl.acm.org/doi/pdf/10.1145/3442188.3445922)). Predictions generated by the model may include disturbing and harmful stereotypes across protected classes; identity characteristics; and sensitive, social, and occupational groups.
|
|
|
76 |
- cannot be used to generate text for research or academic purposes
|
77 |
|
78 |
|
79 |
+
# Usage
|
80 |
+
|
81 |
+
```
|
82 |
+
# Load model directly
|
83 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, AutoConfig
|
84 |
+
|
85 |
+
tokenizer = AutoTokenizer.from_pretrained("ShieldX/manovyadh-1.1B-v1-chat")
|
86 |
+
model = AutoModelForCausalLM.from_pretrained("ShieldX/manovyadh-1.1B-v1-chat").to("cuda")
|
87 |
+
config = AutoConfig.from_pretrained("ShieldX/manovyadh-1.1B-v1-chat")
|
88 |
+
|
89 |
+
def format_prompt(q):
|
90 |
+
return f"""###SYSTEM: You are an AI assistant that helps people cope with stress and improve their mental health. User will tell you about their feelings and challenges. Your task is to listen empathetically and offer helpful suggestions. While responding, think about the user’s needs and goals and show compassion and support
|
91 |
+
###USER: {q}
|
92 |
+
###ASSISTANT:"""
|
93 |
+
|
94 |
+
prompt = format_prompt("I've never been able to talk with my parents. My parents are in their sixties while I am a teenager. I love both of them but not their personalities. I feel that they do not take me seriously whenever I talk about a serious event in my life. If my dad doesn’t believe me, then my mom goes along with my dad and acts like she doesn’t believe me either. I’m a pansexual, but I can’t trust my own parents. I've fought depression and won; however, stress and anxiety are killing me. I feel that my friends don't listen to me. I know they have their own problems, which I do my best to help with. But they don't always try to help me with mine, when I really need them. I feel as if my childhood has been taken from me. I feel as if I have no one whom I can trust.")
|
95 |
+
|
96 |
+
import torch
|
97 |
+
from transformers import GenerationConfig, TextStreamer
|
98 |
+
from time import perf_counter
|
99 |
+
|
100 |
+
# Check for GPU availability
|
101 |
+
if torch.cuda.is_available():
|
102 |
+
device = "cuda"
|
103 |
+
else:
|
104 |
+
device = "cpu"
|
105 |
+
|
106 |
+
# Move model and inputs to the GPU (if available)
|
107 |
+
model.to(device)
|
108 |
+
|
109 |
+
inputs = tokenizer(prompt, return_tensors="pt").to(device)
|
110 |
+
|
111 |
+
streamer = TextStreamer(tokenizer)
|
112 |
+
|
113 |
+
generation_config = GenerationConfig(
|
114 |
+
penalty_alpha=0.6,
|
115 |
+
do_sample=True,
|
116 |
+
top_k=5,
|
117 |
+
temperature=0.5,
|
118 |
+
repetition_penalty=1.2,
|
119 |
+
max_new_tokens=256,
|
120 |
+
streamer=streamer,
|
121 |
+
pad_token_id=tokenizer.eos_token_id
|
122 |
+
)
|
123 |
+
|
124 |
+
start_time = perf_counter()
|
125 |
+
outputs = model.generate(**inputs, generation_config=generation_config)
|
126 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
127 |
+
output_time = perf_counter() - start_time
|
128 |
+
print(f"Time taken for inference: {round(output_time, 2)} seconds")
|
129 |
+
```
|
130 |
+
|
131 |
+
|
132 |
# Bias, Risks, and Limitations
|
133 |
|
134 |
Significant research has explored bias and fairness issues with language models (see, e.g., [Sheng et al. (2021)](https://aclanthology.org/2021.acl-long.330.pdf) and [Bender et al. (2021)](https://dl.acm.org/doi/pdf/10.1145/3442188.3445922)). Predictions generated by the model may include disturbing and harmful stereotypes across protected classes; identity characteristics; and sensitive, social, and occupational groups.
|