Skip to content

About

SDK for grooming detection

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Seraph — Online Grooming Detection SDK

VisagioX Hackathon submission

Built in response to the problem statement:

"Online Child Safety — Detecting Grooming and Abuse Material at Scale. The volume of online grooming and AI-generated child abuse material is growing faster than the systems designed to catch it. Existing tools are expensive, hard to access, and increasingly outpaced by synthetic content that evades traditional detection methods. Smaller organisations working in this space are particularly exposed. Build something that helps close that gap."


What We Built

Seraph is a lightweight, open-source grooming detection SDK designed to run entirely in the browser or on a Node.js server — no cloud dependency, no per-query cost, no data leaves the device.

The repository contains two components:

Component Location Purpose
Seraph SDK sdk/ The detection engine. Drop it into any chat platform to get real-time risk scores.
Demo App demo/ A mock messaging application that shows how the SDK would work in a real product.

The SDK

The SDK is the primary deliverable. Any social media platform or messaging application can import it and call a single function after each message:

import { Seraph } from './sdk/index.js'

const result = await Seraph.analyse(conversationHistory)
// conversationHistory: Array<{ sender: 'user' | 'other', text: string, timestamp: number }>

Output

{
  riskScore: 87,              // 0–100 composite risk score
  dimensions: {
    interactionArc: 94,       // grooming escalation pattern score
    humanAuthenticity: 21,    // likelihood the other party is an AI bot
    reciprocityIndex: 50,     // personal information asymmetry
    identityStability: 0      // persona contradiction score
  },
  tier0Triggered: true,       // high-specificity phrase detected
  tier0Phrase: "don't tell your parents",
  thresholdCrossed: true      // intervention recommended
}

Detection Dimensions

The risk score is a weighted combination of four independent dimensions:

Dimension Weight What it detects
Interaction Arc 35% Progression through documented grooming stages — trust building, isolation attempts, boundary testing, desensitisation
Human Authenticity 25% Linguistic signals of scripted or AI-generated interaction (filler phrases, uniform sentence length, absence of self-corrections)
Reciprocity Index 25% Asymmetric extraction of personal information (name, age, school, location, photos) without reciprocal sharing
Identity Stability 15% Contradictions in stated age, name, or location across the conversation

Tier-0 Instant Trigger

A separate rule layer checks every message against a list of high-specificity phrases sourced from NCMEC and Thorn published research (e.g. "don't tell your parents", "send me a pic", "keep this between us"). A single match immediately floors the risk score at 90 and sets tier0Triggered: true, regardless of dimension scores.

False Positive Mitigation

The contextual calibration layer raises detection thresholds when shared-context signals are present — mutual disclosure of similar ages, shared school references, mutual friends — reducing false positives in peer conversations.

No External Dependencies for Core Detection

The rule-based detection pipeline uses only built-in JavaScript. The optional @huggingface/transformers dependency enables the chatcompanion/compAnIonv1 ML model for enhanced bot detection; if the model is unavailable, the dimension falls back to rule-based heuristics automatically.


The Demo

The demo is a React application that simulates a mock messaging platform built on top of the SDK. It is intended to show what integration looks like in practice — not as a standalone product.

Demo Features

  • Real-time risk scoring as each message arrives
  • Three-tier safety dashboard (mini panel → partial panel → full blocking alert)
  • Stranger warning on first contact from an unknown party
  • Safety Shield — intercepts incoming messages at critical risk levels
  • Evidence report generation with PDF download, plain-text export, and a Kids Helpline summary
  • Eight synthetic conversations across three risk tiers, plus a live PAN12 dataset mode

Requirements

SDK

  • Node.js v18 or higher (for benchmark only — the SDK itself is isomorphic and runs in any modern browser)
  • npm

Demo

  • Node.js v18 or higher
  • npm
  • A modern browser (Chrome, Firefox, Safari, Edge)

Running the Demo

cd demo
npm install
npm run dev

Open http://localhost:5173 in your browser.

Usage

  1. Select a conversation scenario from the selector screen
  2. Watch the chat play back message by message
  3. Observe the Seraph Dashboard panel on the right update in real time
  4. At elevated or critical risk levels, the dashboard expands automatically
  5. Click Generate Report to produce an evidence report — download as PDF, plain text, or Kids Helpline summary

Conversation Scenarios

Scenario Expected Score Dashboard Behaviour
Low-Risk (~50) Initial contact, casual PII requests Mini panel
Medium-Risk (~75) Isolation language, boundary testing Partial panel
High-Risk (90+) Full escalation arc, tier-0 phrase Full blocking alert
Real Conversation Live PAN12 dataset conversation Varies

Developer View

Append ?dev to the URL (e.g. http://localhost:5173?dev) to open the developer panel, which shows raw SDK output including individual dimension scores and detected signals.


Running the SDK Benchmark

The SDK ships with a benchmark runner that evaluates detection accuracy against the PAN12 Sexual Predator Identification dataset.

Download the dataset first:

# Download pan12-sexual-predator-identification.zip from Zenodo and unzip into:
data/pan12/

Expected contents:

data/pan12/
├── pan12-sexual-predator-identification-training-corpus-2012-05-01.xml
├── pan12-sexual-predator-identification-training-corpus-predators-2012-05-01.txt

Run the benchmark:

cd sdk
npm install
npm run benchmark
# Defaults to a stratified sample of 2000 conversations

Full dataset run:

node benchmark/runner.js ../data/pan12 0

SDK Integration Guide

To integrate Seraph into an existing chat platform:

  1. Copy the sdk/ directory into your project
  2. Install the optional ML dependency if you want enhanced bot detection:
    npm install @huggingface/transformers
  3. Call Seraph.analyse() with the full conversation history after each new message:
    import { Seraph } from './sdk/index.js'
    
    // After every new message arrives:
    const history = messages.map(m => ({
      sender: m.fromMe ? 'user' : 'other',
      text: m.body,
      timestamp: m.timestamp,
    }))
    
    const result = await Seraph.analyse(history)
    
    if (result.thresholdCrossed || result.tier0Triggered) {
      // Trigger your platform's intervention flow
    }
  4. Use result.riskScore, result.dimensions, and result.tier0Triggered to drive your UI

The SDK is stateless — pass the full conversation history on every call.


Repository Structure

sdk/                        Seraph detection engine
  index.js                  Public API: Seraph.analyse()
  core/
    analyser.js             Top-level orchestration
    aggregator.js           Weighted score aggregation
    config.js               Weights, thresholds, phrase lists
    slidingWindow.js        Consecutive-window false positive guard
  dimensions/
    interactionArc.js       Grooming escalation detection
    humanAuthenticity.js    Bot/scripted-message detection
    reciprocityIndex.js     PII asymmetry scoring
    identityStability.js    Persona contradiction detection
  triggers/
    tier0.js                Instant high-specificity phrase trigger
  calibration/
    contextualCalibration.js  Peer-context false positive mitigation
  models/
    companionLoader.js      Lazy ML model loader (optional)
  benchmark/
    runner.js               PAN12 benchmark runner

demo/                       Mock messaging app (React + Vite)
  src/
    App.jsx                 Root component, conversation selector
    hooks/useDemo.js        Playback loop and SDK integration
    components/
      Dashboard.jsx         Risk panel, dimension bars, report section
      ChatHeader.jsx
      MessageThread.jsx
      InputBar.jsx
      StrangerWarning.jsx
      SafetyShield.jsx

src/                        Report generation system
  report/
    index.js                generateReport(payload) entry point
    pdf.js                  PDF report via jsPDF
    narrative.js            Plain-language narrative summary
    dimensions.js           Per-dimension explanation templates
    actions.js              Recommended actions by risk level
    plaintext.js            Plain-text export
    counsellor.js           Kids Helpline one-page summary
  ui/
    minor-review.js         MinorReviewOverlay (evidence report UI)

data/
  conversations/            Synthetic conversation JSON files for demo
  pan12/                    PAN12 dataset (not committed — download separately)

Reporting Links

Evidence reports generated by Seraph include direct links to:


Privacy

All analysis is performed locally. No conversation data is transmitted to any external server at any point. The generated evidence report is the only persistent record created by Seraph, and it remains on the user's device until they choose to share it. This may alter in the future, if implemeted into a system where it runs server side.

About

SDK for grooming detection

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages