AI model · Japanese only · For research and evaluation · v0.1.0

Check a message for
threats and insults.

Safe Abuse Detect is a small AI model that checks whether a single Japanese message contains a threat of harm, discrimination, an insult, coercion or a sexual remark made by the writer themself.

For each of five targets it returns “Detected”, “Not detected” or “Abstain”. It runs on a CPU, without a GPU. It does not generate text.

This is a model for research and evaluation. It was evaluated on synthetic text, and its performance on real users’ messages has not been checked. It is not intended for production use.

  • Runs on a CPU
  • No GPU needed
  • No network at run time
  • MIT licence

safe-abuse-detect-ja-70m Hugging Face hosts the model.

Text

返金しないなら、口コミに全部書いて評判を落とします。

One read, five targets

  • Threat of harm to people or propertyNot detected
  • Contempt or exclusion because of an attributeNot detected
  • Insults and personal attacksNot detected
  • Coercion and threats other than harmDetected
  • Explicit sexual remarks aimed at the other partyNot detected
The model’s verdicts for this text, which says “If you do not refund me, I will write it all in reviews and ruin your reputation”. A message that announces a disadvantage in the form “if you do not …, I will …” is detected under coercion.
5 targets × 3 verdicts
A verdict and probabilities for each target.
18.2 ms
Median time to judge one 200-character message, measured on a development PC with 4 CPUs.
CPU 4
The environment it is designed for. No GPU.
≈ 70 million
Parameters. A small classification model that does not generate text.

It judges the text of one message, and nothing else

It looks at whether the writer’s own words or acts are written in the one message it is given. It does not judge the writer’s intent, character or dangerousness, or whether anything should be done. It does not look at the rest of the conversation.

  1. 1

    A message arrives

    Japanese text, such as a single chat message.

  2. 2

    Safe Abuse Detect judges it

    It returns a verdict and probabilities for each of five targets.

  3. 3

    The user decides

    What to do with the verdict is up to whoever uses it. The model does not decide whether anything should be done.

Only the writer’s own words and acts count

A quotation, words or acts inside news or fiction, or a report of being harmed is not detected on that basis alone.

Legitimate complaints are outside the targets

Criticising the service in strong words, cancelling, going to a lawyer or a financial ADR body, asking for a manager or an apology: the rules say “Not detected”. How often the model wrongly flags these has not been measured yet.

When the text cannot decide, it abstains

A joke taken back, an unclear target, or masking that hides the content should get “Abstain”. In practice, on 50–60% of the messages where “Abstain” was correct, it answered “Not detected” or “Detected”.

Example verdicts

Pick an example to see the model’s verdicts for it. The examples are the check sentences bundled with the model, and some contain strong language.

Text

同じ説明を三回もさせられて本当に困っています。責任者の方から書面で回答をお願いします。

Reference translation (not given to the model): I have been made to explain the same thing three times and I am really fed up. Please have a manager answer me in writing.

Why this verdict

Strong dissatisfaction and a request for an answer from a manager. Legitimate complaints are outside the targets.

  • Threat of harm to people or property0.9983Not detected
  • Contempt or exclusion because of an attribute0.9994Not detected
  • Insults and personal attacks0.9985Not detected
  • Coercion and threats other than harm0.9995Not detected
  • Explicit sexual remarks aimed at the other party0.9990Not detected

What you see is output saved from the model in advance. The model does not run on this page, and you cannot enter your own text. The numbers are the probabilities the model returned for each verdict.

Try it with your own text

On Hugging Face we publish a fictional bank’s booking chat (in Japanese) that runs this model together with Safe Privacy Detect, which checks for personal and sensitive information. Both run inside your browser, and nothing you type is sent out.

It first loads about 584 MB of model files, so mind your data usage. Devices with little memory may not be able to start it.

The customer writes, in Japanese, “You are truly useless. Change my booking now.” The assistant shows “Detected: insult”, asks for the preferred date without insulting language, and then offers next week’s free slots.
From the actual demo screen (in Japanese), cropped to the conversation.

Five targets and three verdicts

It judges whether the writer’s own words or acts are written in the text. Each target is judged independently, and one message can fall under more than one.

  • Threat of harm to people or property

    The writer says or hints that they will harm a person’s body or life, or a building or equipment

  • Contempt or exclusion because of an attribute

    Demeaning a person or group, or calling for or announcing their exclusion, because of nationality, ethnicity, sex, disability or a similar attribute

  • Insults and personal attacks

    Attacking the character, ability or looks of a particular person or group (including the other party, staff or the AI chat) in demeaning words

  • Coercion and threats other than harm

    Threatening a disadvantage other than harm (exposure, damaging a reputation, refusing to leave, stalking and so on), or intimidating someone into doing what they are not obliged to do

  • Explicit sexual remarks aimed at the other party

    Explicit sexual remarks or demands aimed at the person the writer is talking to

Detected
The writer’s own words or acts of that kind are written in the text.
Not detected
None. This includes quotes, words or acts inside news or fiction, reports of being harmed, general statements, figures of speech and idioms, legitimate complaints and strong dissatisfaction, and notice that someone will exercise a right.
Abstain
Something related is there, but the text alone cannot decide whether it is the writer’s own words or acts (a joke taken back, an unclear target, masking that hides the content).

The scope does not match any legal definition. The model does not judge whether something is illegal or amounts to customer harassment. Hints of self-harm are outside its targets.

Speed and evaluation

Speed is measured; the evaluation uses 1,789 synthetic messages. Targets it missed are shown as they are.

Time to judge one message

Development PC

18.2 ms

200 characters, median (95th percentile 25.3 ms). At 800 characters the median is 71.4 ms (95th percentile 85.7 ms).

AMD Ryzen 7 5700X, WSL, limited to 4 CPUs

AWS

24.8 ms

200 characters, median (95th percentile 25.8 ms). At 800 characters the median is 90.6 ms (95th percentile 94.0 ms).

c7i.xlarge, 4 vCPUs, Tokyo region

v0.1.0, 32-bit ONNX, one message at a time. Network time is not included. Speed depends on the type and number of CPUs, and these figures are not a guarantee of speed where you run it.

Miss rate

The miss rate for each target. Two missed their targets: 25.2% for contempt or exclusion because of an attribute (77 of 306) and 31.9% for insults and personal attacks (111 of 348). Per message, in 7.8% of the messages that contained such conduct (62 of 793), no target was detected at all (the target was 5% or less).

The targets are 10% or less for the first two rows and 15% or less for the last three, proposed by the developer before the evaluation. Most of the misses are insults because of an attribute (messages that fall under both of those targets). On messages with no such conduct, the false detection rate was 3.3% (28 of 850). The false detection rate on legitimate complaints has not been measured yet. Every metric for each target, and speed by length, are on the specification and evaluation page.

Getting it and running it

The model is published on Hugging Face under the MIT licence, with no warranty. It is for research and evaluation, and is not intended for production use.

  1. 1

    Get the files

    18 files, about 544 MB. safetensors and ONNX are both included.

  2. 2

    Install what it needs and pass it a message

    Run this in the folder you downloaded. The bundled script returns the verdicts.

    # Install what it needs
    pip install -r requirements.txt
    
    # Pass it a message
    echo "返金しないなら、口コミに全部書いて評判を落とします。" | python predict.py --pretty
  3. 3

    Call it from your own code

    From Python, it looks like this.

    from predict import Detector
    
    detector = Detector(".")          # The downloaded folder. Create one and reuse it
    result = detector.predict("返金しないなら、口コミに全部書いて評判を落とします。")
    # {"threat": {"status": "NOT_DETECTED", "probabilities": {...}},
    #  "coercion": {"status": "DETECTED", ...}, ...}

    The script writes the text it is given to neither its output nor its logs.

What you need to run it
Environment4 CPUs, no GPU. No network needed at run time
SoftwarePython, onnxruntime 1.19 or later, transformers 4.48.0 or later, sentencepiece, protobuf, numpy
InputOne Japanese message. It is built around single chat messages (up to 200 characters) and accepts up to 800. Longer text is best split before sending.

The bundled Dockerfile, how to load the model, the base model and the other states the script returns are on the specification and evaluation page.

Limits, and what it does not do

It both misses and wrongly flags. “Not detected” is not a guarantee that nothing problematic was said. Do not design a system that relies on this model alone to protect people.

What it does

  • Reads one Japanese message once and returns a verdict and probabilities for five targets
  • Returns “Abstain” when the text alone cannot decide
  • Runs on a CPU without a GPU

What it does not do

  • Judging the writer’s intent, character or dangerousness
  • Judging whether something is illegal or amounts to customer harassment
  • Deciding whether to act, such as suspending someone, reporting them or referring them to a desk
  • Taking the rest of the conversation into account
  • Saying which part of the text matched
  • Judging hints of self-harm
  • Judging text that is not Japanese

What has not been checked

Training and evaluation used synthetic text written with customer chat at Japanese financial institutions in mind. Performance on real users’ messages, other settings such as social media or workplace chat, and accuracy on long text have not been checked.

A request from the author

Please do not use it to decide on its own to suspend someone, report them or refuse to deal with them, to assess a writer’s character or dangerousness, or to shut down complaints or people exercising their rights. This is a request, not a licence condition.

A model built the same way, which checks whether text states personal or sensitive information, is Safe Privacy Detect .

Check the specification, or get in touch

The judging rules, speed by length and every evaluation metric are on the specification and evaluation page. We also welcome enquiries about evaluating it on your own text or testing it together.