govtech/lionguard-2
1160
LionGuard 2
LionGuard 2 is a multilingual content moderation classifier tuned for English/Singlish, Chinese, Malay, and Tamil in the Singapore context.
It leverages OpenAI’s text-embedding-3-large with a multi-head classifier to return fine-grained scores for the following categories:
- Overall safety (
binary) - Hate (
hateful_l1,hateful_l2) - Insults (
insults) - Sexual content (
sexual_l1,sexual_l2) - Physical violence (
physical_violence) - Self-harm (
self_harm_l1,self_harm_l2) - Other misconduct (
all_other_misconduct_l1,all_other_misconduct_l2)
Further details on the benchmark results and training methodology are in our report.
Taxonomy
Usage
import os
import numpy as np
from transformers import AutoModel
from openai import OpenAI
# Load model directly from HF
model = AutoModel.from_pretrained(
"govtech/lionguard-2",
trust_remote_code=True
)
# Get OpenAI embeddings (users to input their own OpenAI API key)
client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
response = client.embeddings.create(
input="Hello, world!", # users to input their own text
model="text-embedding-3-large",
dimensions=3072 # dimensions of the embedding
)
embeddings = np.array([data.embedding for data in response.data])
# Run LionGuard 2
results = model.predict(embeddings)