Editing
Ai Mental Health Dx
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== <span style="color: #FFFFFF;">Applying</span> == '''Depression screening NLP from clinical notes:''' <syntaxhighlight lang="python"> from transformers import AutoTokenizer, AutoModelForSequenceClassification import torch import torch.nn.functional as F from openai import OpenAI # MentalBERT β BERT pre-trained on mental health text (Reddit MH forums + clinical notes) tokenizer = AutoTokenizer.from_pretrained("mental/mental-bert-base-uncased") model = AutoModelForSequenceClassification.from_pretrained( "mental/mental-bert-base-uncased" ) def screen_for_depression(text: str) -> dict: """Screen text for depression severity using MentalBERT.""" inputs = tokenizer(text, return_tensors="pt", max_length=512, truncation=True, padding=True) with torch.no_grad(): logits = model(**inputs).logits probs = F.softmax(logits, dim=1)[0] labels = model.config.id2label return {labels[i]: float(p) for i, p in enumerate(probs)} # LLM-based PHQ-9 extraction from clinical notes client = OpenAI() def extract_phq9_from_note(clinical_note: str) -> dict: """Extract PHQ-9 items from unstructured clinical note.""" prompt = f"""Extract PHQ-9 depression screening scores from this clinical note. For each PHQ-9 item (1-9), score 0-3 if mentioned, or 'not mentioned'. Return JSON with: {{phq9_items: {{...}}, total_if_complete: int|null, flags: [...]}} Clinical note: {clinical_note}""" response = client.chat.completions.create( model="gpt-4o-mini", messages=[{"role":"user","content":prompt}], response_format={"type":"json_object"}, temperature=0 ) return response.choices[0].message.content # Suicidality risk keyword escalation (rule + ML hybrid β safety-critical) HIGH_RISK_PHRASES = [ "suicidal ideation", "wants to die", "plan to kill", "suicide attempt", "self-harm", "cutting", "overdose intentional", "no reason to live" ] def detect_crisis_risk(text: str) -> dict: """Rule-based + ML hybrid crisis detection β conservative (high sensitivity).""" text_lower = text.lower() rule_triggered = any(phrase in text_lower for phrase in HIGH_RISK_PHRASES) ml_result = screen_for_depression(text) return { 'rule_triggered': rule_triggered, 'ml_risk_score': ml_result.get('high_risk', 0), 'escalate': rule_triggered, # Rules always take precedence for safety 'action': 'immediate_clinical_review' if rule_triggered else 'standard_care' } </syntaxhighlight> ; Mental health AI tools : '''Chatbots / DTx''' β Woebot, Wysa, Mindstrong (passive sensing), Headspace for Work : '''Clinical NLP''' β MentalBERT, BERT-MH; Columbia CSSRS NLP (academic) : '''Speech analysis''' β Sonde Health (depression from voice), Ellipsis Health, Canary Speech : '''Population screening''' β Crisis Text Line ML (text message triage), Safe Messaging AI : '''Passive sensing research''' β StudentLife dataset (Dartmouth), TILES dataset </div> <div style="background-color: #8B4500; color: #FFFFFF; padding: 20px; border-radius: 8px; margin-bottom: 15px;">
Summary:
Please note that all contributions to BloomWiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
BloomWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information