Views
No views yet
bert-base-uncased1 if from the specific newswire, 0 otherwise)1 for articles from the target newswire, 0 for all others.| Model | Accuracy | Precision | Recall | F1 Score |
|---|---|---|---|---|
| AP | 0.9925 | 0.9926 | 0.9925 | 0.9925 |
| UPI | 0.9999 | 0.9999 | 0.9999 | 0.9999 |
| NEA | 0.9875 | 0.9880 | 0.9875 | 0.9876 |
pip install transformers torch1from transformers import AutoModelForSequenceClassification, AutoTokenizer
2
3model = AutoModelForSequenceClassification.from_pretrained("mike-mcrae/newswire_classifier/AP")
4tokenizer = AutoTokenizer.from_pretrained("mike-mcrae/newswire_classifier/AP")
5
6text = "(AP) President speaks at conference..."
7inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=128)
8outputs = model(**inputs)
9prediction = outputs.logits.argmax().item()
10print("AP Article" if prediction == 1 else "Not AP Article")@misc{newswire_classifier,
author = {McRae, Michael},
title = {Newswire Classifier (AP, UPI, NEA) - BERT Transformers},
year = {2025},
publisher = {Hugging Face},
url = {https://huggingface.co/username/newswire_classifier}
}