🚀 Llama-3.1-8B-Instruct-心理健康分類
本模型是 meta-llama/Meta-Llama-3.1-8B-Instruct 在 suchintikasarkar/sentiment-analysis-for-mental-health 數據集上的微調版本,可用於從文本中預測各種心理健康障礙。
🚀 快速開始
按照 Fine-Tuning Llama 3.1 for Text Classification 教程,開啟全新 Llama 模型的使用之旅,並定製 Llama-3.1-8B-It 以從文本中預測各種心理健康障礙。
💻 使用示例
基礎用法
from transformers import AutoTokenizer,AutoModelForCausalLM,pipeline
import torch
model_id = "kingabzpro/Llama-3.1-8B-Instruct-Mental-Health-Classification"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
return_dict=True,
low_cpu_mem_usage=True,
torch_dtype=torch.float16,
device_map="auto",
trust_remote_code=True,
)
text = "I'm trapped in a storm of emotions that I can't control, and it feels like no one understands the chaos inside me"
prompt = f"""Classify the text into Normal, Depression, Anxiety, Bipolar, and return the answer as the corresponding mental health disorder label.
text: {text}
label: """.strip()
pipe = pipeline(
"text-generation",
model=model,
tokenizer=tokenizer,
torch_dtype=torch.float16,
device_map="auto",
)
outputs = pipe(prompt, max_new_tokens=2, do_sample=True, temperature=0.1)
print(outputs[0]["generated_text"].split("label: ")[-1].strip())
📚 詳細文檔
評估指標
屬性 |
詳情 |
數據集 |
suchintikasarkar/sentiment-analysis-for-mental-health |
模型類型 |
Llama-3.1-8B-Instruct 微調版本 |
評估指標 |
準確率、F1值 |
任務類型 |
文本生成 |
標籤 |
心理健康、Meta-Llama-3.1-8B-Instruct |
許可證 |
apache-2.0 |
評估結果
100%|██████████| 300/300 [03:24<00:00, 1.47it/s]
Accuracy: 0.913
Accuracy for label Normal: 0.972
Accuracy for label Depression: 0.913
Accuracy for label Anxiety: 0.667
Accuracy for label Bipolar: 0.800
分類報告:
precision recall f1-score support
Normal 0.92 0.97 0.95 143
Depression 0.93 0.91 0.92 115
Anxiety 0.75 0.67 0.71 27
Bipolar 1.00 0.80 0.89 15
accuracy 0.91 300
macro avg 0.90 0.84 0.87 300
weighted avg 0.91 0.91 0.91 300
混淆矩陣:
[[139 3 1 0]
[ 5 105 5 0]
[ 6 3 18 0]
[ 1 2 0 12]]
📄 許可證
本模型使用的是 apache-2.0 許可證。