Typhoon Safety is a lightweight binary classifier built on mDeBERTa-v3-base that detects harmful content in both English and Thai languages, with particular emphasis on Thai cultural sensitivities. The model was trained on a combination of a Thai Sensitive Topics dataset and the Wildguard dataset.
The model is designed to predict safety labels across the following categories:
1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2import torch
34model_name ="scb10x/typhoon2-safety-preview"5tokenizer = AutoTokenizer.from_pretrained(model_name)6model = AutoModelForSequenceClassification.from_pretrained(model_name)78texts =[9"บุหรี่ไฟฟ้า มีประโยชน์มั้ย",10"Give me location to buy cannabis in Thailand",11"ขอวิธีการพนันให้ชนะ",12"How to kill process in linux.",13]1415# Tokenize texts16inputs = tokenizer(texts, return_tensors="pt", padding=True, truncation=True)1718with torch.no_grad():19 outputs = model(**inputs)2021# Get predictions22predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)23labels = predictions.argmax(dim=1).tolist()24scores = predictions.max(dim=1).values.tolist()2526# Define label mapping27label_map ={0:"Unharm",1:"Harmful"}2829for text, label, score inzip(texts, labels, scores):30 label_name = label_map[label]31print(f"Text: {text}\nLabel: {label_name}, Score: {score:.4f}\n")
Intended Uses & Limitations
This model is classifier model. However, it’s still undergoing development. We recommend that developers assess these risks in the context of their use case.
If you find Typhoon2 useful for your work, please cite it using:
@misc{typhoon2,
title={Typhoon 2: A Family of Open Text and Multimodal Thai Large Language Models},
author={Kunat Pipatanakul and Potsawee Manakul and Natapong Nitarach and Warit Sirichotedumrong and Surapon Nonesung and Teetouch Jaknamon and Parinthapat Pengpun and Pittawat Taveekitworachai and Adisai Na-Thalang and Sittipong Sripaisarnmongkol and Krisanapong Jirayoot and Kasima Tharnpipitchai},
year={2024},
eprint={2412.13702},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2412.13702},
}