Run this model with HF Jobs
Run KDAI-NLP/wangchanberta-traffy-multi on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/KDAI-NLP/wangchanberta-traffy-multi. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/KDAI-NLP/wangchanberta-traffy-multi on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use KDAI-NLP/wangchanberta-traffy-multi with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use KDAI-NLP/wangchanberta-traffy-multi with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="KDAI-NLP/wangchanberta-traffy-multi")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("KDAI-NLP/wangchanberta-traffy-multi") model = AutoModelForSequenceClassification.from_pretrained("KDAI-NLP/wangchanberta-traffy-multi", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Traffy Complaint Classification
This multi-label model is trained to automatically classify various types of traffic complaints expressed in Thai text, with the goal of minimizing the need for manual classification. Please note that the example inference provided by Hugging Face (Right-side UI) does not yet support multi-label classification. If you require multi-label classification, please use the code provided below.
Model Details
Model Name: KDAI-NLP/wangchanberta-traffy-multi
Tokenizer: airesearch/wangchanberta-base-att-spm-uncased
License: Apache License 2.0
How to Use
!pip install sentencepiece
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
from torch.nn.functional import sigmoid
import json
# Target lists
target_list = [
'ความสะอาด', 'สายไฟ', 'สะพาน', 'ถนน', 'น้ำท่วม',
'ร้องเรียน', 'ท่อระบายน้ำ', 'ความปลอดภัย', 'คลอง', 'แสงสว่าง',
'ทางเท้า', 'จราจร', 'กีดขวาง', 'การเดินทาง', 'เสียงรบกวน',
'ต้นไม้', 'สัตว์จรจัด', 'เสนอแนะ', 'คนจรจัด', 'ห้องน้ำ',
'ป้ายจราจร', 'สอบถาม', 'ป้าย', 'PM2.5'
]
# Load tokenizer and model
tokenizer = AutoTokenizer.from_pretrained("airesearch/wangchanberta-base-att-spm-uncased")
model = AutoModelForSequenceClassification.from_pretrained("KDAI-NLP/wangchanberta-traffy-multi")
# Example text to classify
text = "ช่วยด้วยครับถนนน้ำท่วมอีกแล้ว ต้นไม้ก็ล้มขวางทาง กลับบ้านไม่ได้"
# Encode the text using the tokenizer
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=256)
# Get model predictions (logits)
with torch.no_grad():
logits = model(**inputs).logits
# Apply sigmoid function to convert logits to probabilities
probabilities = sigmoid(logits)
# Map probabilities to corresponding labels
probabilities = probabilities.squeeze().tolist()
label_probabilities = zip(target_list, probabilities)
# Print labels with probabilities
for label, probability in label_probabilities:
print(f"{label}: {probability:.4f}")
# Or JSON
# Create a dictionary for labels and probabilities
results_dict = {label: probability for label, probability in label_probabilities}
# Convert dictionary to JSON string
results_json = json.dumps(results_dict, ensure_ascii=False, indent=4)
# Print the JSON string
print(results_json)
Training Details
The model was trained on traffic complaint data API (included stopwords) using the airesearch/wangchanberta-base-att-spm-uncased base model. This is a multi-label classification task with a total of 24 classes.
Training Scores
| Model | Stopword | Epoch | Training Loss | Validation Loss | F1 | Accuracy |
|---|---|---|---|---|---|---|
| wangchanberta-base-att-spm-uncased | Included | 0 | 0.0322 | 0.034822 | 0.7015 | 0.7569 |
| wangchanberta-base-att-spm-uncased | Included | 2 | 0.0207 | 0.026364 | 0.8405 | 0.7821 |
| wangchanberta-base-att-spm-uncased | Included | 4 | 0.0165 | 0.025142 | 0.8458 | 0.7934 |
Feel free to customize the README further if needed.
- Downloads last month
- 16