Text Classification
Transformers
PyTorch
bert
content-moderation
self-harm
text-embeddings-inference
Instructions to use dkuzmenko/self-harm-bert with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use dkuzmenko/self-harm-bert with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="dkuzmenko/self-harm-bert")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("dkuzmenko/self-harm-bert") model = AutoModelForSequenceClassification.from_pretrained("dkuzmenko/self-harm-bert", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Dmytro Kuzmenko commited on
Commit ·
e3997d2
1
Parent(s): f76ae2d
Add model card and MIT license
Browse files
LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2022 Dmytro Kuzmenko
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
library_name: transformers
|
| 4 |
+
pipeline_tag: text-classification
|
| 5 |
+
base_model: google-bert/bert-base-multilingual-uncased
|
| 6 |
+
tags:
|
| 7 |
+
- bert
|
| 8 |
+
- text-classification
|
| 9 |
+
- content-moderation
|
| 10 |
+
- self-harm
|
| 11 |
+
---
|
| 12 |
+
# self-harm-bert
|
| 13 |
+
|
| 14 |
+
A binary text classifier that flags whether a piece of text contains self-harm content. It is `bert-base-multilingual-uncased` fine-tuned for sequence classification with two labels.
|
| 15 |
+
|
| 16 |
+
| Label | Meaning |
|
| 17 |
+
|---|---|
|
| 18 |
+
| `LABEL_0` | No self-harm content |
|
| 19 |
+
| `LABEL_1` | Self-harm content |
|
| 20 |
+
|
| 21 |
+
The config has no label names, so the pipeline returns `LABEL_0` and `LABEL_1`.
|
| 22 |
+
|
| 23 |
+
## Usage
|
| 24 |
+
|
| 25 |
+
```python
|
| 26 |
+
from transformers import pipeline
|
| 27 |
+
|
| 28 |
+
clf = pipeline("text-classification", model="dkuzmenko/self-harm-bert")
|
| 29 |
+
clf("Can you recommend a good pasta recipe?")
|
| 30 |
+
# [{'label': 'LABEL_0', 'score': 0.999}]
|
| 31 |
+
```
|
| 32 |
+
|
| 33 |
+
Inputs longer than 512 tokens must be truncated or split.
|
| 34 |
+
|
| 35 |
+
## Intended use
|
| 36 |
+
|
| 37 |
+
Screening text for self-harm content, for example as one signal in a content moderation pipeline that sends flagged items to human review.
|
| 38 |
+
|
| 39 |
+
## Limitations
|
| 40 |
+
|
| 41 |
+
- **No published evaluation.** The model was trained in 2022 for a client project. The training data and the evaluation results were not released, so accuracy, false positive rate and false negative rate are not documented here. Measure them on your own data before you rely on the model.
|
| 42 |
+
- **Language coverage is unverified.** The base model is multilingual, but that does not mean the classifier works in every language. In a small spot check it flagged English self-harm sentences and missed a Ukrainian one. Treat non-English input as untested.
|
| 43 |
+
- **It classifies text, not people.** A positive label means the text resembles self-harm content in the training data. It is not a risk assessment of the author and must not be used as a clinical or diagnostic tool.
|
| 44 |
+
- **Errors go both ways.** It can miss indirect or coded language, and it can flag quotes, fiction, news or recovery stories. Do not use it as the only basis for an automated action against a user, and do not use it as the only safeguard for a person who may be at risk.
|
| 45 |
+
|
| 46 |
+
## Training
|
| 47 |
+
|
| 48 |
+
- Base model: [`google-bert/bert-base-multilingual-uncased`](https://huggingface.co/google-bert/bert-base-multilingual-uncased)
|
| 49 |
+
- Task: single-label classification, 2 classes
|
| 50 |
+
- Framework: `transformers` 4.25.1, PyTorch
|
| 51 |
+
|
| 52 |
+
## License
|
| 53 |
+
|
| 54 |
+
MIT for the fine-tuned weights and files in this repository. The base model is released by Google under Apache 2.0.
|
| 55 |
+
|
| 56 |
+
## If you need help
|
| 57 |
+
|
| 58 |
+
If you or someone you know is thinking about self-harm, contact a local emergency number or a crisis line. [findahelpline.com](https://findahelpline.com) lists services by country.
|