korean-profanity-refiner-2.1b
Toxicity reduction in Korean chat
2 min readupdated
The model automatically rewrites profanity, insults, and hate speech in chat messages into polite sentences while preserving the original meaning, tone, and conversational style. Built on top of a base model by KakaoCorp (Kanana-1.5-2.1b-instruct-2505, 2.09 billion parameters), it is fine-tuned using LoRA (a small add-on to the base model) with adapter weight merging. Unlike hard censorship or message deletion, it carefully removes swear words and insults while keeping the context of the conversation intact. The project is useful for chat developers, community moderators, and Discord bot creators to maintain a friendly atmosphere.
Key features
- Rewriting without deletion: Replaces profanity and slang with neutral or polite words while preserving the message structure.
- Style preservation: Keeps conversational endings, abbreviations, and emojis (such as ㅋㅋ) intact.
- Ready-made moderation pipeline: The repository includes a wrapper with checks, family insult blocking, and leak protection.
- Discord integration: A ready-to-use bot is available that deletes toxic messages and republishes them in an edited form on behalf of the author.
What you can do
- Set up a Discord bot: Deploy the ready-to-use bot from the repository for automated text channel moderation.
- Integrate into a chat application: Embed the model into a service backend for soft censorship of user messages on the fly.
- Improve the filtering system: Use the built-in validation pipeline with lexicons to reliably catch obfuscated profanity.
Example
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
repo = "seoha1234/korean-profanity-refiner-2.1b"
device = "cuda" if torch.cuda.is_available() else "cpu"
tok = AutoTokenizer.from_pretrained(repo)
model = AutoModelForCausalLM.from_pretrained(repo, dtype=torch.bfloat16).to(device).eval()
PROMPT = "다음 문장에서 욕설·비속어·혐오 표현을 순화해서 다시 써줘. 이미 깨끗한 문장은 그대로 써줘.\n문장: {text}"
def refine(text):
prompt = tok.apply_chat_template([{"role": "user", "content": PROMPT.replace("{text}", text)}], add_generation_prompt=True, tokenize=False)
ids = tok(prompt, return_tensors="pt", add_special_tokens=False).to(device)
out = model.generate(**ids, max_new_tokens=96, do_sample=False)
return tok.decode(out[0, ids["input_ids"].shape[1]:], skip_special_tokens=True).strip()
print(refine("아 씨발 오늘 존나 덥네"))Read more
DetailsMetrics: Accuracy on clean texts (identity) reaches 98.97% chrF, and on toxic datasets—49.43% chrF.
Requirements and hardware: Based on a model with 2.09 billion parameters, using the bfloat16 format.
Limitations: Struggles with obfuscated profanity (separated letters, numbers) without an external pipeline, and alters about 3% of clean messages (fixing typos).
License: CC-BY-NC-4.0 (commercial use is prohibited due to K/DA data).










Comments