Inputs are anonymised and logged to improve LionGuard's moderation models.
Model Selection
Input
Analysis
Enter text to analyze
Category scores will appear here after analysis
Inputs are anonymised and logged to improve LionGuard's moderation models.
Model Selection
No Moderation
OpenAI Moderation
LionGuard
LionGuard is a family of open-source content moderation models specifically designed for Singapore's multilingual environment. Optimized for Singapore’s linguistic mix, including Singlish, Mandarin, Malay, and Tamil, LionGuard delivers accurate moderation grounded in local usage and cultural nuance.
Developed by GovTech Singapore.
Open-Sourced Models
Open-Sourced Datasets
Blog Posts
Option 1: Self-Host the Classifier
Integrate LionGuard directly into your applications. Toggle between models to see the implementation details.
import os
import numpy as np
from transformers import AutoModel
from google import genai
# Load model directly from HF
model = AutoModel.from_pretrained("govtech/lionguard-2.1", trust_remote_code=True)
# Text to classify
texts = ["hello", "world"]
# Get embeddings (users to input their own Gemini API key)
client = genai.Client(api_key=os.getenv("GEMINI_API_KEY"))
response = client.models.embed_content(
model="gemini-embedding-001",
contents=texts
)
embeddings = np.array([emb.values for emb in response.embeddings])
# Run inference
results = model.predict(embeddings)
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)
import numpy as np
from sentence_transformers import SentenceTransformer
from transformers import AutoModel
# Load model directly from Hub
model = AutoModel.from_pretrained("govtech/lionguard-2-lite", trust_remote_code=True)
# Download model from the 🤗 Hub
embedding_model = SentenceTransformer("google/embeddinggemma-300m")
# Text to classify
texts = ["hello", "world"]
# Add prompt instructions to generate embeddings that are optimized to classify texts according to preset labels
formatted_texts = [f"task: classification | query: {c}" for c in texts]
embeddings = embedding_model.encode(formatted_texts) # NOTE: use encode() instead of encode_documents()
# Run inference
results = model.predict(embeddings)
Option 2: via AI Guardians - Sentinel
Managed service for Singapore public sector agencies.