Detection of Self-Harm in Electronic Mental Health Records Using Privacy-Preserving Local Language Models: Methodological Study.

IF 7.4 2区 医学 Q1 PSYCHIATRY
Jmir Mental Health Pub Date : 2026-06-02 DOI:10.2196/87586
Andrey Kormilitzin, Dan W Joyce, Apostolos Tsiachristas, Rohan Borschmann, Navneet Kapur, Galit Geulayov
{"title":"Detection of Self-Harm in Electronic Mental Health Records Using Privacy-Preserving Local Language Models: Methodological Study.","authors":"Andrey Kormilitzin, Dan W Joyce, Apostolos Tsiachristas, Rohan Borschmann, Navneet Kapur, Galit Geulayov","doi":"10.2196/87586","DOIUrl":null,"url":null,"abstract":"<p><strong>Background: </strong>Self-harm is the strongest risk factor for suicide and an important outcome for mental health care. Although prevalent in clinical populations, it is often imprecisely captured in routinely collected clinical data, where it is often recorded and stored as unstructured free text. Contemporary language models, such as GPT (OpenAI) and Gemini (Google), can analyze free-text clinical notes, but such models may violate data governance of processing sensitive patient data.</p><p><strong>Objective: </strong>This study aimed to evaluate whether a privacy-preserving language model running entirely within an institution's secure computing infrastructure (here, the UK National Health Service [NHS]) could accurately identify the presence and timing of self-harm using electronic health records from secondary mental health care.</p><p><strong>Methods: </strong>Clinical notes were drawn from Oxford Health NHS Foundation Trust using a multistage workflow: (1) a random sample of 1000 patients with a psychiatric diagnosis, defined according to the ICD-10 (International Statistical Classification of Diseases, Tenth Revision; codes F00-F99); (2) candidate-note identification using a Gemma3-4b language model to flag notes containing self-harm content; and (3) from those candidates, 1352 randomly sampled notes were selected for expert annotation, resulting in gold-standard corpus enriched for self-harm content. Clinical notes were annotated for the presence of self-harm and its timing (≤90 days, >90 days, or unknown). A privacy-preserving locally served 27-billion-parameter Gemma 3 language model (\"Gemma3-27b\") was used as the core model. Prompts were systematically developed and refined using a labeled development set to identify self-harm and generate a structured output per clinical record. Gemma3-27b performance was compared against a strong baseline multilabel text classification model based on robustly optimized BERT pretraining approach (RoBERTa), a transformer-based language model architecture. Model performance was evaluated using precision, recall, and the F1-score (harmonic mean of precision and recall), with 95% CIs estimated from 1000 bootstrap samples with replacement.</p><p><strong>Results: </strong>Gemma3-27b outperformed the RoBERTa classifier across all categories, achieving Precision=0.92, Recall=0.92 (sensitivity), and F1-score=0.92 for notes containing self-harm, and Precision=0.97, Recall=0.97 (specificity), and F1-score=0.97 for notes without self-harm. For the 51 notes labeled as recent self-harm in the held-out test set, Gemma3-27b achieved Precision=0.84, Recall=0.75, and F1-score=0.79. The global weighted F1-score of Gemma3-27b across all categories was 0.88, compared to 0.85 for RoBERTa.</p><p><strong>Conclusions: </strong>With systematic prompt development on a labeled development set, but no gradient-based fine-tuning, the current Gemma3-27b language model matched or exceeded a fine-tuned RoBERTa classifier for ascertaining self-harm events and their timing. Aggregate gains were modest, while improvements were largest in the most challenging, lower-frequency timing categories. On a simplified binary recent-versus-other task, RoBERTa performed marginally better, indicating that supervised classifiers remain highly effective when the task is simplified and sufficient labeled data exist. This work demonstrates the technical feasibility of privacy-preserving self-harm detection within a secure NHS research environment.</p>","PeriodicalId":48616,"journal":{"name":"Jmir Mental Health","volume":"13 ","pages":"e87586"},"PeriodicalIF":7.4000,"publicationDate":"2026-06-02","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"https://www.ncbi.nlm.nih.gov/pmc/articles/PMC13229841/pdf/","citationCount":"0","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"Jmir Mental Health","FirstCategoryId":"3","ListUrlMain":"https://doi.org/10.2196/87586","RegionNum":2,"RegionCategory":"医学","ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"Q1","JCRName":"PSYCHIATRY","Score":null,"Total":0}
引用次数: 0

Abstract

Background: Self-harm is the strongest risk factor for suicide and an important outcome for mental health care. Although prevalent in clinical populations, it is often imprecisely captured in routinely collected clinical data, where it is often recorded and stored as unstructured free text. Contemporary language models, such as GPT (OpenAI) and Gemini (Google), can analyze free-text clinical notes, but such models may violate data governance of processing sensitive patient data.

Objective: This study aimed to evaluate whether a privacy-preserving language model running entirely within an institution's secure computing infrastructure (here, the UK National Health Service [NHS]) could accurately identify the presence and timing of self-harm using electronic health records from secondary mental health care.

Methods: Clinical notes were drawn from Oxford Health NHS Foundation Trust using a multistage workflow: (1) a random sample of 1000 patients with a psychiatric diagnosis, defined according to the ICD-10 (International Statistical Classification of Diseases, Tenth Revision; codes F00-F99); (2) candidate-note identification using a Gemma3-4b language model to flag notes containing self-harm content; and (3) from those candidates, 1352 randomly sampled notes were selected for expert annotation, resulting in gold-standard corpus enriched for self-harm content. Clinical notes were annotated for the presence of self-harm and its timing (≤90 days, >90 days, or unknown). A privacy-preserving locally served 27-billion-parameter Gemma 3 language model ("Gemma3-27b") was used as the core model. Prompts were systematically developed and refined using a labeled development set to identify self-harm and generate a structured output per clinical record. Gemma3-27b performance was compared against a strong baseline multilabel text classification model based on robustly optimized BERT pretraining approach (RoBERTa), a transformer-based language model architecture. Model performance was evaluated using precision, recall, and the F1-score (harmonic mean of precision and recall), with 95% CIs estimated from 1000 bootstrap samples with replacement.

Results: Gemma3-27b outperformed the RoBERTa classifier across all categories, achieving Precision=0.92, Recall=0.92 (sensitivity), and F1-score=0.92 for notes containing self-harm, and Precision=0.97, Recall=0.97 (specificity), and F1-score=0.97 for notes without self-harm. For the 51 notes labeled as recent self-harm in the held-out test set, Gemma3-27b achieved Precision=0.84, Recall=0.75, and F1-score=0.79. The global weighted F1-score of Gemma3-27b across all categories was 0.88, compared to 0.85 for RoBERTa.

Conclusions: With systematic prompt development on a labeled development set, but no gradient-based fine-tuning, the current Gemma3-27b language model matched or exceeded a fine-tuned RoBERTa classifier for ascertaining self-harm events and their timing. Aggregate gains were modest, while improvements were largest in the most challenging, lower-frequency timing categories. On a simplified binary recent-versus-other task, RoBERTa performed marginally better, indicating that supervised classifiers remain highly effective when the task is simplified and sufficient labeled data exist. This work demonstrates the technical feasibility of privacy-preserving self-harm detection within a secure NHS research environment.

使用保护隐私的本地语言模型检测电子心理健康记录中的自我伤害:方法学研究。
背景:自残是自杀的最大危险因素,也是心理健康护理的重要结果。虽然在临床人群中普遍存在,但在常规收集的临床数据中经常不精确地捕获,通常以非结构化自由文本的形式记录和存储。当代语言模型,如GPT (OpenAI)和Gemini(谷歌),可以分析自由文本的临床记录,但这些模型可能违反处理敏感患者数据的数据治理。目的:本研究旨在评估一个完全在一个机构的安全计算基础设施(这里是英国国民健康服务体系[NHS])内运行的隐私保护语言模型,是否可以使用二级精神卫生保健的电子健康记录准确识别自我伤害的存在和时间。方法:采用多阶段工作流程从牛津健康NHS基金会信托基金提取临床记录:(1)随机抽取1000名精神病诊断患者,根据ICD-10(国际疾病统计分类,第十版,代码F00-F99)进行定义;(2)利用Gemma3-4b语言模型识别含有自残内容的候选笔记;(3)从候选笔记中随机抽取1352个笔记进行专家注释,形成了丰富了自残内容的金标准语料库。在临床记录中标注自我伤害的存在及其时间(≤90天,bb0 90天,或未知)。采用具有270亿个参数的隐私保护本地服务Gemma3语言模型(“Gemma3-27b”)作为核心模型。使用标记开发集系统地开发和改进提示,以识别自我伤害并生成每个临床记录的结构化输出。Gemma3-27b的性能与基于稳健优化的BERT预训练方法(RoBERTa)的强基线多标签文本分类模型进行了比较,RoBERTa是一种基于转换器的语言模型架构。使用精度、召回率和f1分数(精度和召回率的调和平均值)评估模型性能,从1000个带替换的bootstrap样本中估计95%的ci。结果:Gemma3-27b分类器在所有类别中均优于RoBERTa分类器,对于包含自残的笔记,其Precision=0.92, Recall=0.92(灵敏度),F1-score=0.92;对于没有自残的笔记,其Precision=0.97, Recall=0.97(特异性),F1-score=0.97。对于在hold -out测试集中标记为最近自残的51个音符,Gemma3-27b的Precision=0.84, Recall=0.75, F1-score=0.79。Gemma3-27b在所有类别中的全球加权f1得分为0.88,而RoBERTa为0.85。结论:目前的Gemma3-27b语言模型在一个标记的开发集上进行了系统的快速开发,但没有基于梯度的微调,在确定自残事件及其时间方面,它与微调的RoBERTa分类器相匹配或超过了RoBERTa分类器。总体收益不大,而在最具挑战性、频率较低的时机类别中,改善最大。在简化的二元最近与其他任务上,RoBERTa的表现稍好一些,这表明当任务被简化并且有足够的标记数据存在时,监督分类器仍然非常有效。这项工作证明了在安全的NHS研究环境中保护隐私的自我伤害检测的技术可行性。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
求助全文
约1分钟内获得全文 求助全文
来源期刊
Jmir Mental Health
Jmir Mental Health Medicine-Psychiatry and Mental Health
CiteScore
10.80
自引率
3.80%
发文量
104
审稿时长
16 weeks
期刊介绍: JMIR Mental Health (JMH, ISSN 2368-7959) is a PubMed-indexed, peer-reviewed sister journal of JMIR, the leading eHealth journal (Impact Factor 2016: 5.175). JMIR Mental Health focusses on digital health and Internet interventions, technologies and electronic innovations (software and hardware) for mental health, addictions, online counselling and behaviour change. This includes formative evaluation and system descriptions, theoretical papers, review papers, viewpoint/vision papers, and rigorous evaluations.
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
确定
请完成安全验证×
copy
已复制链接
快去分享给好友吧!
我知道了
右上角分享
点击右上角分享
0
联系我们:info@booksci.cn Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。 Copyright © 2023 布克学术 All rights reserved.
京ICP备2023020795号-1
ghs 京公网安备 11010802042870号
Book学术文献互助
Book学术文献互助群
群 号:604180095
Book学术官方微信
小红书