xablex's picture
Upload folder using huggingface_hub
c81f977 verified
|
Raw
History Blame Contribute Delete
917 Bytes

Prosody DistilBERT Text Classifier

Fine-tuned distilbert-base-uncased for binary page classification in the Princeton Prosody Archive corpus, using page text (OCR transcription) only.

  • Classes: TU (0), non-TU (1)
  • Architecture: DistilBertForSequenceClassification (HF-native)
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch

model = AutoModelForSequenceClassification.from_pretrained("./distilbert-text")
tok   = AutoTokenizer.from_pretrained("./distilbert-text")

enc = tok("a line of verse ...", truncation=True, max_length=512, return_tensors="pt")
with torch.no_grad():
    probs = model(**enc).logits.softmax(-1)[0]
print({model.config.id2label[i]: float(p) for i, p in enumerate(probs)})

label_encoder.pkl is the original sklearn LabelEncoder (class1->0, class2->1) kept for provenance.