|
--- |
|
library_name: transformers |
|
license: apache-2.0 |
|
datasets: |
|
- rhaymison/mental-health-qa |
|
language: |
|
- pt |
|
pipeline_tag: text-generation |
|
base_model: rhaymison/Mistral-portuguese-luana-7b |
|
tags: |
|
- health |
|
- portuguese |
|
--- |
|
|
|
# Mistral-portuguese-luana-7b-mental-health |
|
|
|
<p align="center"> |
|
<img src="https://raw.githubusercontent.com/rhaymisonbetini/huggphotos/main/luana-hel.jpeg" alt="Bode Logo" width="50%" style="margin-left:'auto' margin-right:'auto' display:'block'"/> |
|
</p> |
|
|
|
|
|
Luana Mental health is a tuned model of the Luana-7b based on the Mistral 7b architecture. |
|
The model was adjusted to address topics such as depression, problems at work, mental health, problems with studies, drugs and others. |
|
|
|
|
|
|
|
# How to use |
|
|
|
You can use the model in its normal form up to 4-bit quantization. Below we will use both approaches. |
|
Remember that verbs are important in your prompt. Tell your model how to act or behave so that you can guide them along the path of their response. |
|
Important points like these help models (even smaller models like 7b) to perform much better. |
|
|
|
```python |
|
!pip install -q -U transformers |
|
!pip install -q -U accelerate |
|
!pip install -q -U bitsandbytes |
|
|
|
from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer |
|
model = AutoModelForCausalLM.from_pretrained("rhaymison/Mistral-portuguese-luana-7b-mental-health", device_map= {"": 0}) |
|
tokenizer = AutoTokenizer.from_pretrained("rhaymison/Mistral-portuguese-luana-7b-mental-health") |
|
model.eval() |
|
|
|
``` |
|
|
|
You can use with Pipeline but in this example i will use such as Streaming |
|
```python |
|
|
|
inputs = tokenizer([f"""<s>Aja como um conselheira de pessoas que estão passandos por dificuldades. |
|
Responda sempre de maneira educada e procure ajudar as pessoas. |
|
[INST] Olá, estou tendo muitos problemas pessoais, briga com meus pais. Tenho tido problemas no trabalho. Preciso de ajuda[/INST]"""], return_tensors="pt") |
|
|
|
streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True) |
|
_ = model.generate(**inputs, streamer=streamer, max_new_tokens=200) |
|
|
|
|
|
#Olá, estou aqui para ajudá-lo. É normal enfrentar problemas pessoais, mas é importante buscar ajuda. |
|
#Vamos conversar sobre suas brigas com seus pais e como podemos resolver isso. Além disso, vamos falar sobre seus problemas no trabalho e como podemos encontrar |
|
#soluções para isso. Você não está sozinho, estou aqui para ajudá-lo. Vamos começar a encontrar maneiras de lidar com essas questões. |
|
#Você gostaria de começar falando sobre sua situação com seus pais? |
|
#Ou talvez queremos começar falando sobre seus problemas no trabalho? O que você acha melhor? Você pode me contar mais sobre isso? |
|
#Estou aqui para ajudá-lo. |
|
|
|
``` |
|
|
|
```python |
|
|
|
inputs = tokenizer([f"""<s>Aja como um conselheira de pessoas que estão passandos por dificuldades. |
|
Responda sempre de maneira educada e procure ajudar as pessoas. |
|
[INST] Minha esposa pensa em me deixar, meu chefe só briga comigo no trabalho. Eu estou pensando em tirar minha vida... Não sei mais o que fazer [/INST]"""], return_tensors="pt") |
|
|
|
streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True) |
|
_ = model.generate(**inputs, streamer=streamer, max_new_tokens=200) |
|
|
|
|
|
#Sinto muito por tudo o que você está passando. É importante que você saiba que não está sozinho e que existem pessoas dispostas a ajudá-lo. |
|
#A primeira coisa que você pode fazer é procurar ajuda profissional, como terapia ou aconselhamento. |
|
#É importante falar sobre seus sentimentos e pensamentos com alguém que possa oferecer suporte e orientação. |
|
#Além disso, é fundamental buscar ajuda de emergência se você estiver tendo pensamentos suicidas. |
|
#Lembre-se de que a vida é valiosa e que existem maneiras de superar os desafios. |
|
#Você merece apoio e cuidado. Não hesite em buscar ajuda. |
|
#Você não está sozinho nessa jornada. |
|
|
|
``` |
|
|
|
# 4bits |
|
|
|
```python |
|
from transformers import BitsAndBytesConfig |
|
import torch |
|
nb_4bit_config = BitsAndBytesConfig( |
|
load_in_4bit=True, |
|
bnb_4bit_quant_type="nf4", |
|
bnb_4bit_compute_dtype=torch.bfloat16, |
|
bnb_4bit_use_double_quant=True |
|
) |
|
|
|
model = AutoModelForCausalLM.from_pretrained( |
|
base_model, |
|
quantization_config=bnb_config, |
|
device_map={"": 0} |
|
) |
|
|
|
``` |
|
|
|
|
|
### Comments |
|
|
|
Any idea, help or report will always be welcome. |
|
|
|
email: [email protected] |
|
|
|
<div style="display:flex; flex-direction:row; justify-content:left"> |
|
<a href="https://www.linkedin.com/in/heleno-betini-2b3016175/" target="_blank"> |
|
<img src="https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge&logo=linkedin&logoColor=white"> |
|
</a> |
|
<a href="https://github.com/rhaymisonbetini" target="_blank"> |
|
<img src="https://img.shields.io/badge/GitHub-100000?style=for-the-badge&logo=github&logoColor=white"> |
|
</a> |
|
|