YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

Model Card: SDGs Classification

Model Overview

Model Name: sdd-sdgs
Base Model: indobenchmark/indobert-base-p2
Task: Multi-class SDG classification (18-class)
Language: Indonesian


Model Description

Fine-tuned IndoBERT for classifying Indonesian text against UN Sustainable Development Goals.

Classes: SDG0 (Non-SDG), SDG1-SDG17 (UN Sustainable Development Goals)


Performance Metrics

Metric Test Public Test Internal
Accuracy 0.7919 1.0000
Macro F1 0.7445 1.0000
Latency (mean) 8.71 ms -
Model Size 474.8 MB -

Usage

Load Model

from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch

model_name = "AzrilFahmiardi/sdd-sdgs"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = model.to(device)

SDG_DICT = {
    "SDG0": "Non-SDG", "SDG1": "No Poverty", "SDG2": "Zero Hunger",
    "SDG3": "Good Health", "SDG4": "Quality Education", "SDG5": "Gender Equality",
    "SDG6": "Clean Water", "SDG7": "Clean Energy", "SDG8": "Decent Work",
    "SDG9": "Industry Innovation", "SDG10": "Reduced Inequalities",
    "SDG11": "Sustainable Cities", "SDG12": "Responsible Consumption",
    "SDG13": "Climate Action", "SDG14": "Life Below Water", "SDG15": "Life on Land",
    "SDG16": "Peace Justice", "SDG17": "Partnerships"
}

Inference

def classify_sdg(text: str) -> dict:
    inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=256).to(device)
    
    with torch.no_grad():
        outputs = model(**inputs)
        logits = outputs.logits
    
    probabilities = torch.softmax(logits, dim=-1)[0].cpu()
    predicted_class = logits.argmax(-1).item()
    predicted_label = model.config.id2label[predicted_class]
    confidence = probabilities[predicted_class].item()
    
    return {
        "sdg_code": predicted_label,
        "sdg_name": SDG_DICT[predicted_label],
        "confidence": confidence
    }

# Example
text = "Pemerintah meluncurkan program pengentasan kemiskinan di daerah terpencil."
result = classify_sdg(text)
print(f"SDG: {result['sdg_code']} - {result['sdg_name']} ({result['confidence']:.2%})")

Output Format

{
  "sdg_code": "SDG1",
  "sdg_name": "No Poverty",
  "confidence": 0.8756
}

Input/Output

Parameter Type Example
Input str Indonesian text (policy, news), max 256 tokens
Output dict {"sdg_code": "SDG1", "sdg_name": "No Poverty", "confidence": 0.88}
Downloads last month
2
Safetensors
Model size
0.1B params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Collection including AzrilFahmiardi/sdd-sdgs