This model fine-tunes lonformer-base for multilabel classification of policies, targets, and themes.
Classify policy documents descriptions into thematic categories.
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import numpy as np
import joblib
import requests
model_path = "vtt-qsts-ai/multilabel-indicator-classification-longformer-base"
model = AutoModelForSequenceClassification.from_pretrained(model_path)
tokenizer = AutoTokenizer.from_pretrained(model_path)
mlb_url = "https://huggingface.co/vtt-qsts-ai/multilabel-indicator-classification-longformer-base/resolve/main/mlb.pkl"
mlb_path = "mlb.pkl"
with open(mlb_path, "wb") as f:
f.write(requests.get(mlb_url).content)
mlb = joblib.load(mlb_path)
text = "This program supports clean technology and sustainable development in industries."
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True, max_length=1024)
model.eval()
with torch.no_grad():
logits = model(**inputs).logits
probs = torch.sigmoid(logits).squeeze().numpy()
# Threshold
binary_preds = (probs > 0.25).astype(int)
predicted_labels = [label for i, label in enumerate(mlb.classes_) if binary_preds[i] == 1]
print("Predicted Labels:", predicted_labels)
# Predicted Labels: ['TG20', 'TG21', 'TG22', 'TG25', 'TG29', 'TG9']
model.safetensors 595 MBtraining_args.bin 5.2 kB