Text Classification
Transformers
Safetensors
multilingual
snt_classifier
feature-extraction
news
topic-classification
multi-label
xlm-roberta
custom_code
Instructions to use sweenk/snt-classifier with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use sweenk/snt-classifier with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="sweenk/snt-classifier", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("sweenk/snt-classifier", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
SNT classifier v0.6
Browse files- README.md +36 -31
- config.json +66 -66
- model.safetensors +1 -1
README.md
CHANGED
|
@@ -12,7 +12,7 @@ tags:
|
|
| 12 |
library_name: transformers
|
| 13 |
---
|
| 14 |
|
| 15 |
-
# SNT News Classifier v0.
|
| 16 |
|
| 17 |
Multi-label news topic classifier: **12 top-level (L1) and 71 sub-level (L2)
|
| 18 |
categories**, built on `xlm-roberta-large` with two independent sigmoid heads. Both levels are
|
|
@@ -24,6 +24,10 @@ is ever left unlabeled.
|
|
| 24 |
Built by [Sweenk](https://sweenk.com) to categorize its news feed; released so others can use and
|
| 25 |
scrutinize it.
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
## Quick start
|
| 28 |
|
| 29 |
```python
|
|
@@ -66,54 +70,54 @@ The full machine-readable taxonomy (`l1_keys`, `l2_keys`, `l2_parent`, per-class
|
|
| 66 |
|
| 67 |
## Evaluation — our own numbers, stated plainly
|
| 68 |
|
| 69 |
-
Held-out test split: **
|
| 70 |
-
|
| 71 |
-
to test.
|
| 72 |
|
| 73 |
| Metric | @0.5 threshold | tuned thresholds |
|
| 74 |
|---|---|---|
|
| 75 |
-
| L1 macro F1 | 0.
|
| 76 |
-
| L1 micro F1 | 0.
|
| 77 |
-
| L1 primary accuracy (argmax) | 0.
|
| 78 |
-
| L2 macro F1 | 0.
|
| 79 |
-
| L2 micro F1 | 0.
|
| 80 |
|
| 81 |
### Per-class L1 F1 (test)
|
| 82 |
|
| 83 |
| L1 | F1 @0.5 | F1 tuned | threshold |
|
| 84 |
|---|---|---|---|
|
| 85 |
-
| `sports` | 0.
|
| 86 |
-
| `politics` | 0.
|
| 87 |
-
| `world` | 0.
|
| 88 |
-
| `entertainment_and_pop_culture` | 0.
|
| 89 |
-
| `money_and_business` | 0.
|
| 90 |
-
| `crime_and_justice` | 0.
|
| 91 |
-
| `tech_and_ai` | 0.
|
| 92 |
-
| `science_and_space` | 0.
|
| 93 |
-
| `health_and_wellness` | 0.
|
| 94 |
-
| `lifestyle` | 0.
|
| 95 |
-
| `weather_and_environment` | 0.
|
| 96 |
-
| `human_stories` | 0.
|
| 97 |
|
| 98 |
### What you should know before trusting these numbers
|
| 99 |
|
| 100 |
Read this section — it is the honest part.
|
| 101 |
|
| 102 |
-
- **The gold labels are model-assisted, not human-annotated.** The corpus (
|
| 103 |
HuffPost archives, CommonCrawl News, daily.dev, and Sweenk production) was labeled by a
|
| 104 |
mechanical migration from an earlier taxonomy plus multiple passes of a Claude Sonnet teacher
|
| 105 |
with a rule-based prompt, spot-audited by humans (QA gates at 70–87% agreement on sampled
|
| 106 |
batches). Test F1 therefore measures agreement with an LLM teacher, not with human ground truth.
|
| 107 |
- **Class imbalance is real (~21x).** `politics`/`lifestyle`/`entertainment` have ~44-47K training
|
| 108 |
-
rows; `science_and_space`
|
| 109 |
-
`pos_weight` (clamped at 10)
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
- **Multilingual ability is inherited, not measured.** The encoder is XLM-R, but nearly all
|
| 118 |
training articles are English. Expect degraded (unquantified) quality on non-English news.
|
| 119 |
- **L3 (named topics / entities) is not part of this model** — Sweenk handles that downstream with
|
|
@@ -133,6 +137,7 @@ collapses co-confident multi-label pairs).
|
|
| 133 |
|---|---|
|
| 134 |
| v0.5 | First multi-label release (12 L1 / 71 L2, dual sigmoid heads) |
|
| 135 |
| v0.5.1 | Corrective retrain: route-accidents-by-cause, terror→crime, earnings→money, govt-personnel→politics, wildlife→weather, body-over-headline; ~1,500 corrected labels; re-tuned thresholds |
|
|
|
|
| 136 |
|
| 137 |
## License & attribution
|
| 138 |
|
|
|
|
| 12 |
library_name: transformers
|
| 13 |
---
|
| 14 |
|
| 15 |
+
# SNT News Classifier v0.6
|
| 16 |
|
| 17 |
Multi-label news topic classifier: **12 top-level (L1) and 71 sub-level (L2)
|
| 18 |
categories**, built on `xlm-roberta-large` with two independent sigmoid heads. Both levels are
|
|
|
|
| 24 |
Built by [Sweenk](https://sweenk.com) to categorize its news feed; released so others can use and
|
| 25 |
scrutinize it.
|
| 26 |
|
| 27 |
+
**Links:** [GitHub — model & training code](https://github.com/sweenk/snt-model) ·
|
| 28 |
+
[GitHub — data pipeline](https://github.com/sweenk/snt-data) ·
|
| 29 |
+
[Live API](https://taxonomy.lasharela.com)
|
| 30 |
+
|
| 31 |
## Quick start
|
| 32 |
|
| 33 |
```python
|
|
|
|
| 70 |
|
| 71 |
## Evaluation — our own numbers, stated plainly
|
| 72 |
|
| 73 |
+
Held-out test split: **26,412 articles** (a 10% slice of the labeled corpus,
|
| 74 |
+
stratified by primary L1). "Tuned" = per-class thresholds optimized on the *validation* split,
|
| 75 |
+
then applied unchanged to test.
|
| 76 |
|
| 77 |
| Metric | @0.5 threshold | tuned thresholds |
|
| 78 |
|---|---|---|
|
| 79 |
+
| L1 macro F1 | 0.817 | **0.847** |
|
| 80 |
+
| L1 micro F1 | 0.831 | **0.857** |
|
| 81 |
+
| L1 primary accuracy (argmax) | 0.833 | — |
|
| 82 |
+
| L2 macro F1 | 0.647 | 0.685 |
|
| 83 |
+
| L2 micro F1 | 0.753 | 0.754 |
|
| 84 |
|
| 85 |
### Per-class L1 F1 (test)
|
| 86 |
|
| 87 |
| L1 | F1 @0.5 | F1 tuned | threshold |
|
| 88 |
|---|---|---|---|
|
| 89 |
+
| `sports` | 0.941 | 0.954 | 0.850 |
|
| 90 |
+
| `politics` | 0.845 | 0.859 | 0.750 |
|
| 91 |
+
| `world` | 0.783 | 0.827 | 0.850 |
|
| 92 |
+
| `entertainment_and_pop_culture` | 0.887 | 0.898 | 0.850 |
|
| 93 |
+
| `money_and_business` | 0.786 | 0.825 | 0.950 |
|
| 94 |
+
| `crime_and_justice` | 0.823 | 0.857 | 0.950 |
|
| 95 |
+
| `tech_and_ai` | 0.802 | 0.857 | 0.950 |
|
| 96 |
+
| `science_and_space` | 0.802 | 0.833 | 0.950 |
|
| 97 |
+
| `health_and_wellness` | 0.821 | 0.860 | 0.900 |
|
| 98 |
+
| `lifestyle` | 0.865 | 0.867 | 0.700 |
|
| 99 |
+
| `weather_and_environment` | 0.816 | 0.857 | 0.950 |
|
| 100 |
+
| `human_stories` | 0.632 | 0.671 | 0.900 |
|
| 101 |
|
| 102 |
### What you should know before trusting these numbers
|
| 103 |
|
| 104 |
Read this section — it is the honest part.
|
| 105 |
|
| 106 |
+
- **The gold labels are model-assisted, not human-annotated.** The corpus (~278K articles from
|
| 107 |
HuffPost archives, CommonCrawl News, daily.dev, and Sweenk production) was labeled by a
|
| 108 |
mechanical migration from an earlier taxonomy plus multiple passes of a Claude Sonnet teacher
|
| 109 |
with a rule-based prompt, spot-audited by humans (QA gates at 70–87% agreement on sampled
|
| 110 |
batches). Test F1 therefore measures agreement with an LLM teacher, not with human ground truth.
|
| 111 |
- **Class imbalance is real (~21x).** `politics`/`lifestyle`/`entertainment` have ~44-47K training
|
| 112 |
+
rows; `science_and_space` ~2.2K and `tech_and_ai` ~3.7K. Training compensates with per-class
|
| 113 |
+
`pos_weight` (clamped at 10) and caps the majority classes at 25K primary-label train rows so
|
| 114 |
+
they don't swamp the rare ones. The weakest class here is `human_stories` (F1 0.671) —
|
| 115 |
+
the fuzziest category by construction.
|
| 116 |
+
- **Labels were corrected over time, so F1 is not comparable across releases.** v0.5.1 re-labeled
|
| 117 |
+
~1,500 systematically mislabeled rows with route-by-cause rules (accidents by cause, terror →
|
| 118 |
+
crime, pharma earnings → money); on those rows agreement with the corrected gold went
|
| 119 |
+
25.9% → 75.3%. Because the gold labels themselves changed between releases, aggregate F1 deltas
|
| 120 |
+
are not like-for-like — treat each release's numbers as self-referential.
|
| 121 |
- **Multilingual ability is inherited, not measured.** The encoder is XLM-R, but nearly all
|
| 122 |
training articles are English. Expect degraded (unquantified) quality on non-English news.
|
| 123 |
- **L3 (named topics / entities) is not part of this model** — Sweenk handles that downstream with
|
|
|
|
| 137 |
|---|---|
|
| 138 |
| v0.5 | First multi-label release (12 L1 / 71 L2, dual sigmoid heads) |
|
| 139 |
| v0.5.1 | Corrective retrain: route-accidents-by-cause, terror→crime, earnings→money, govt-personnel→politics, wildlife→weather, body-over-headline; ~1,500 corrected labels; re-tuned thresholds |
|
| 140 |
+
| v0.6 | Retrain on the corrected corpus + ~23K newly teacher-labeled articles (Sweenk production + daily.dev science/tech); majority-class capping (25K/class) on top of `pos_weight`; re-tuned thresholds |
|
| 141 |
|
| 142 |
## License & attribution
|
| 143 |
|
config.json
CHANGED
|
@@ -24,18 +24,18 @@
|
|
| 24 |
"human_stories"
|
| 25 |
],
|
| 26 |
"l1_thresholds": {
|
| 27 |
-
"crime_and_justice": 0.
|
| 28 |
-
"entertainment_and_pop_culture": 0.
|
| 29 |
"health_and_wellness": 0.9,
|
| 30 |
"human_stories": 0.9,
|
| 31 |
"lifestyle": 0.7,
|
| 32 |
-
"money_and_business": 0.
|
| 33 |
-
"politics": 0.
|
| 34 |
-
"science_and_space": 0.
|
| 35 |
-
"sports": 0.
|
| 36 |
"tech_and_ai": 0.95,
|
| 37 |
-
"weather_and_environment": 0.
|
| 38 |
-
"world": 0.
|
| 39 |
},
|
| 40 |
"l2_keys": [
|
| 41 |
"soccer",
|
|
@@ -184,79 +184,79 @@
|
|
| 184 |
"work_and_careers": "money_and_business"
|
| 185 |
},
|
| 186 |
"l2_thresholds": {
|
| 187 |
-
"american_football": 0.
|
| 188 |
-
"animals_and_pets": 0.
|
| 189 |
-
"archaeology_and_history": 0.
|
| 190 |
-
"artificial_intelligence": 0.
|
| 191 |
-
"baseball": 0.
|
| 192 |
-
"basketball": 0.
|
| 193 |
-
"big_tech_and_startups": 0.
|
| 194 |
-
"books_and_arts": 0.
|
| 195 |
-
"celebrities_and_gossip": 0.
|
| 196 |
-
"climate_change": 0.
|
| 197 |
-
"college_sports": 0.
|
| 198 |
-
"combat_sports": 0.
|
| 199 |
-
"companies_and_industries": 0.
|
| 200 |
"cost_of_living": 0.05,
|
| 201 |
-
"courts_and_trials": 0.
|
| 202 |
-
"crime_and_policing": 0.
|
| 203 |
-
"crypto_and_fintech": 0.
|
| 204 |
-
"cybersecurity_and_privacy": 0.
|
| 205 |
"disasters_and_accidents": 0.4,
|
| 206 |
-
"education_and_schools": 0.
|
| 207 |
-
"elections_and_campaigns": 0.
|
| 208 |
"energy_and_climate_solutions": 0.45,
|
| 209 |
-
"faith_and_spirituality": 0.
|
| 210 |
-
"fashion_and_beauty": 0.
|
| 211 |
-
"fitness_and_exercise": 0.
|
| 212 |
-
"food_and_drink": 0.
|
| 213 |
-
"gadgets_and_apps": 0.
|
| 214 |
-
"gaming": 0.
|
| 215 |
"geopolitics_and_diplomacy": 0.45,
|
| 216 |
-
"golf": 0.
|
| 217 |
-
"good_news_and_kindness": 0.
|
| 218 |
-
"government_and_policy": 0.
|
| 219 |
"hockey": 0.15,
|
| 220 |
-
"home_and_garden": 0.
|
| 221 |
-
"housing_and_real_estate": 0.
|
| 222 |
"humanitarian_crises": 0.25,
|
| 223 |
-
"immigration_and_borders": 0.
|
| 224 |
"internet_culture_and_creators": 0.05,
|
| 225 |
-
"macro_economy_and_rates": 0.
|
| 226 |
-
"markets_and_investing": 0.
|
| 227 |
"media_and_journalism": 0.3,
|
| 228 |
"medical_and_public_health": 0.45,
|
| 229 |
-
"mental_health": 0.
|
| 230 |
-
"motorsports": 0.
|
| 231 |
-
"movies_and_tv": 0.
|
| 232 |
-
"music": 0.
|
| 233 |
-
"nature_and_wildlife": 0.
|
| 234 |
-
"nutrition_and_diet": 0.
|
| 235 |
"offbeat_and_unusual": 0.3,
|
| 236 |
-
"olympics": 0.
|
| 237 |
-
"other_sports": 0.
|
| 238 |
-
"parenting_and_family": 0.
|
| 239 |
"personal_finance": 0.1,
|
| 240 |
-
"political_figures_and_scandals": 0.
|
| 241 |
-
"psychology_and_behavior": 0.
|
| 242 |
-
"relationships_and_dating": 0.
|
| 243 |
"scams_and_fraud": 0.25,
|
| 244 |
-
"scientific_discoveries": 0.
|
| 245 |
-
"screen_time_and_digital_life": 0.
|
| 246 |
-
"severe_weather": 0.
|
| 247 |
"sleep_and_longevity": 0.05,
|
| 248 |
-
"soccer": 0.
|
| 249 |
-
"social_issues_and_activism": 0.
|
| 250 |
-
"space_and_astronomy": 0.
|
| 251 |
-
"state_and_local_politics": 0.
|
| 252 |
-
"tennis": 0.
|
| 253 |
-
"terrorism_and_security": 0.
|
| 254 |
-
"travel_and_places": 0.
|
| 255 |
"true_crime": 0.05,
|
| 256 |
-
"war_and_conflict": 0.
|
| 257 |
-
"work_and_careers": 0.
|
| 258 |
},
|
| 259 |
"model_type": "snt_classifier",
|
| 260 |
-
"snt_version": "v0.
|
| 261 |
"transformers_version": "5.8.0"
|
| 262 |
}
|
|
|
|
| 24 |
"human_stories"
|
| 25 |
],
|
| 26 |
"l1_thresholds": {
|
| 27 |
+
"crime_and_justice": 0.95,
|
| 28 |
+
"entertainment_and_pop_culture": 0.85,
|
| 29 |
"health_and_wellness": 0.9,
|
| 30 |
"human_stories": 0.9,
|
| 31 |
"lifestyle": 0.7,
|
| 32 |
+
"money_and_business": 0.95,
|
| 33 |
+
"politics": 0.75,
|
| 34 |
+
"science_and_space": 0.95,
|
| 35 |
+
"sports": 0.85,
|
| 36 |
"tech_and_ai": 0.95,
|
| 37 |
+
"weather_and_environment": 0.95,
|
| 38 |
+
"world": 0.85
|
| 39 |
},
|
| 40 |
"l2_keys": [
|
| 41 |
"soccer",
|
|
|
|
| 184 |
"work_and_careers": "money_and_business"
|
| 185 |
},
|
| 186 |
"l2_thresholds": {
|
| 187 |
+
"american_football": 0.5,
|
| 188 |
+
"animals_and_pets": 0.55,
|
| 189 |
+
"archaeology_and_history": 0.2,
|
| 190 |
+
"artificial_intelligence": 0.45,
|
| 191 |
+
"baseball": 0.35,
|
| 192 |
+
"basketball": 0.45,
|
| 193 |
+
"big_tech_and_startups": 0.3,
|
| 194 |
+
"books_and_arts": 0.3,
|
| 195 |
+
"celebrities_and_gossip": 0.45,
|
| 196 |
+
"climate_change": 0.35,
|
| 197 |
+
"college_sports": 0.35,
|
| 198 |
+
"combat_sports": 0.35,
|
| 199 |
+
"companies_and_industries": 0.4,
|
| 200 |
"cost_of_living": 0.05,
|
| 201 |
+
"courts_and_trials": 0.4,
|
| 202 |
+
"crime_and_policing": 0.35,
|
| 203 |
+
"crypto_and_fintech": 0.15,
|
| 204 |
+
"cybersecurity_and_privacy": 0.35,
|
| 205 |
"disasters_and_accidents": 0.4,
|
| 206 |
+
"education_and_schools": 0.3,
|
| 207 |
+
"elections_and_campaigns": 0.35,
|
| 208 |
"energy_and_climate_solutions": 0.45,
|
| 209 |
+
"faith_and_spirituality": 0.45,
|
| 210 |
+
"fashion_and_beauty": 0.3,
|
| 211 |
+
"fitness_and_exercise": 0.4,
|
| 212 |
+
"food_and_drink": 0.3,
|
| 213 |
+
"gadgets_and_apps": 0.3,
|
| 214 |
+
"gaming": 0.15,
|
| 215 |
"geopolitics_and_diplomacy": 0.45,
|
| 216 |
+
"golf": 0.45,
|
| 217 |
+
"good_news_and_kindness": 0.3,
|
| 218 |
+
"government_and_policy": 0.3,
|
| 219 |
"hockey": 0.15,
|
| 220 |
+
"home_and_garden": 0.35,
|
| 221 |
+
"housing_and_real_estate": 0.25,
|
| 222 |
"humanitarian_crises": 0.25,
|
| 223 |
+
"immigration_and_borders": 0.4,
|
| 224 |
"internet_culture_and_creators": 0.05,
|
| 225 |
+
"macro_economy_and_rates": 0.4,
|
| 226 |
+
"markets_and_investing": 0.5,
|
| 227 |
"media_and_journalism": 0.3,
|
| 228 |
"medical_and_public_health": 0.45,
|
| 229 |
+
"mental_health": 0.5,
|
| 230 |
+
"motorsports": 0.25,
|
| 231 |
+
"movies_and_tv": 0.35,
|
| 232 |
+
"music": 0.45,
|
| 233 |
+
"nature_and_wildlife": 0.35,
|
| 234 |
+
"nutrition_and_diet": 0.55,
|
| 235 |
"offbeat_and_unusual": 0.3,
|
| 236 |
+
"olympics": 0.4,
|
| 237 |
+
"other_sports": 0.25,
|
| 238 |
+
"parenting_and_family": 0.35,
|
| 239 |
"personal_finance": 0.1,
|
| 240 |
+
"political_figures_and_scandals": 0.3,
|
| 241 |
+
"psychology_and_behavior": 0.1,
|
| 242 |
+
"relationships_and_dating": 0.35,
|
| 243 |
"scams_and_fraud": 0.25,
|
| 244 |
+
"scientific_discoveries": 0.35,
|
| 245 |
+
"screen_time_and_digital_life": 0.1,
|
| 246 |
+
"severe_weather": 0.5,
|
| 247 |
"sleep_and_longevity": 0.05,
|
| 248 |
+
"soccer": 0.3,
|
| 249 |
+
"social_issues_and_activism": 0.4,
|
| 250 |
+
"space_and_astronomy": 0.5,
|
| 251 |
+
"state_and_local_politics": 0.05,
|
| 252 |
+
"tennis": 0.3,
|
| 253 |
+
"terrorism_and_security": 0.35,
|
| 254 |
+
"travel_and_places": 0.35,
|
| 255 |
"true_crime": 0.05,
|
| 256 |
+
"war_and_conflict": 0.35,
|
| 257 |
+
"work_and_careers": 0.4
|
| 258 |
},
|
| 259 |
"model_type": "snt_classifier",
|
| 260 |
+
"snt_version": "v0.6",
|
| 261 |
"transformers_version": "5.8.0"
|
| 262 |
}
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 2239950948
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6600e39a91f7e017d0eceb02baa03ca325e6574fae170b2bb68f58735b71c9b4
|
| 3 |
size 2239950948
|