Download README.md from orcheflow/flow-moderation: direct link, hf CLI and curl.
- Browser
- Download file 5.52 kB
-
https://huggingface.co/orcheflow/flow-moderation/resolve/main/README.md
- Command line
-
hf download hf://orcheflow/flow-moderation/README.md
-
curl -L -o README.md https://huggingface.co/orcheflow/flow-moderation/resolve/main/README.md
license: mit
language:
- ko
- en
FLOW-Moderation Opensource Software (CharCNN)
This repository contains two complementary AI models designed for Korean profanity and toxic content detection. Each model is optimized for different environments: speed vs. contextual accuracy.
1. Overview
| Feature | Module Profanity (CharCNN) | Module Toxic Detection (KcELECTRA) |
|---|---|---|
| Primary Goal | Detects explicit profanity, slang, and intentional typos (leetspeak). | Detects context-aware toxicity, hate speech, and offensive tones. |
| Architecture | Character-level CNN (CharCNN) | Transformer (Fine-tuned KcELECTRA-base) |
| Model Size | ~12MB (Ultra-lightweight) | ~400MB+ (Large) |
| Inference Speed | Very Fast (Real-time, CPU friendly) | Moderate (GPU recommended) |
| Input Method | Character/Jamo-level (Max len: 150) | WordPiece Tokenizer (Max len: 128) |
| Strengths | Highly robust against variations. | Detects subtle insults and toxicity without explicit swear words. |
2. Module Profanity (Profanity Detection)
Path: module_profanity/
Based on a CharCNN architecture, this model is extremely lightweight and fast. It is ideal for high-traffic real-time environments like game chats or live comment streams where users frequently bypass filters using special characters or intentional typos. Unlike BERT-based models, it operates at the character level, making it highly robust to "Out-of-Vocabulary" (OOV) issues for slang.
Technical Specifications
- Embedding Dim: 300
- Filters: 384 (Kernel sizes: 2, 3, 4, 5, 6)
- Performance: 99.5%+ Validation Accuracy
- Training Data: ~80k samples (NSMC for clean data + refined Korean profanity datasets)
Usage (Inference)
import torch
from module_profanity.src.tokenizer import CharTokenizer
from module_profanity.src.model import CharCNN
# Load model and tokenizer
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
tokenizer = CharTokenizer.load("./module_profanity/models/tokenizer.json")
model = CharCNN(vocab_size=len(tokenizer), num_classes=2).to(device)
model.load_state_dict(torch.load("./module_profanity/models/char_cnn_model.pth", map_location=device))
model.eval()
# Predict
text = "κ²μ μ°Έ μ’κ°μ΄λ νμλ€μ"
encoded = tokenizer.encode(text)
input_tensor = torch.tensor([encoded]).to(device)
with torch.no_grad():
output = model(input_tensor)
prob = torch.nn.functional.softmax(output, dim=1)[0][1].item() # Class 1: Profanity
print(f"Profanity Probability: {prob * 100:.2f}%")
3. Module Toxic Detection (Contextual Toxicity)
Path: module_toxicdetection/
This module uses a fine-tuned beomi/KcELECTRA-base model, which is pre-trained on Korean online comments and colloquialisms. It excels at understanding the semantic meaning and nuance of a sentence. It can identify toxic behavior even when no explicit profanity is present, making it suitable for community moderation and safety filtering.
Technical Specifications
- Base Model:
beomi/KcELECTRA-base - Max Length: 128
- Training: Implemented using the HuggingFace Trainer API with FP16 support.
Usage (Inference)
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
# Load model from checkpoint
model_path = "./module_toxicdetection/models/final_model"
tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModelForSequenceClassification.from_pretrained(model_path)
model.eval()
# Predict
text = "κΈμ μ°Έ κ°κ°μ΄λ μμ°μλ€μ γ
γ
" # Toxic tone without explicit swear words
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=128)
with torch.no_grad():
outputs = model(**inputs)
probs = torch.nn.functional.softmax(outputs.logits, dim=-1)
toxic_score = probs[0][1].item()
print(f"Toxic Score: {toxic_score:.4f}")
4. Directory Structure
.
βββ module_profanity/ # CharCNN-based Profanity Detection
β βββ models/ # Trained weights (.pth) and tokenizer.json
β βββ src/ # Source code (model definition, tokenizer, etc.)
β βββ train.py # Training script
β βββ predict.py # Inference test script
β
βββ module_toxicdetection/ # KcELECTRA-based Toxicity Detection
β βββ models/ # HuggingFace model directory
β βββ src/ # Dataset loaders and utility scripts
β βββ train.py # Training script using Trainer API
β βββ src/predict.py # Inference test script
β
βββ README_NEW.md # Documentation (this file)
Model Description
- Developed by: FLOWLABS & JunsuAI
- Model type: TEXT CLASSIFICATION
- Language(s) (NLP): KOREAN, ENGLISH
- License: MIT LICENSE