Text Classification
Transformers
ONNX
Safetensors
Transformers.js
modernbert
topic-classification
domain-classification
web-classification
weborganizer
data-curation
pretraining-data
mmbert
text-embeddings-inference
Instructions to use Horizon-Labs/multilingual-web-topic-format-base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Horizon-Labs/multilingual-web-topic-format-base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="Horizon-Labs/multilingual-web-topic-format-base")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("Horizon-Labs/multilingual-web-topic-format-base") model = AutoModelForSequenceClassification.from_pretrained("Horizon-Labs/multilingual-web-topic-format-base", device_map="auto") - Transformers.js
How to use Horizon-Labs/multilingual-web-topic-format-base with Transformers.js:
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('text-classification', 'Horizon-Labs/multilingual-web-topic-format-base'); - Notebooks
- Google Colab
- Kaggle
Download code/webtax/metrics.py from Horizon-Labs/multilingual-web-topic-format-base: direct link, hf CLI and curl.
- Browser
- Download file 688 Bytes
-
https://huggingface.co/Horizon-Labs/multilingual-web-topic-format-base/resolve/main/code/webtax/metrics.py
- Command line
-
hf download hf://Horizon-Labs/multilingual-web-topic-format-base/code/webtax/metrics.py
-
curl -L -o metrics.py https://huggingface.co/Horizon-Labs/multilingual-web-topic-format-base/resolve/main/code/webtax/metrics.py
688 Bytes
| """Topic / format accuracy and macro-F1 of predicted label slugs against a reference; per-language mean accuracy.""" | |
| import numpy as np | |
| def acc_f1(p, r, lang=None): | |
| p, r = np.asarray(p), np.asarray(r); out = dict(n=len(r), acc=float((p == r).mean())) | |
| f1 = [] | |
| for c in np.unique(r): | |
| if (r == c).sum() >= 10: | |
| tp = ((p == c) & (r == c)).sum(); f1.append(2 * tp / max(1, 2 * tp + ((p == c) & (r != c)).sum() + ((p != c) & (r == c)).sum())) | |
| out["macro_f1"] = float(np.mean(f1)) | |
| if lang is not None: | |
| lang = np.asarray(lang); out["lang_mean_acc"] = float(np.mean([(p[lang == l] == r[lang == l]).mean() for l in np.unique(lang)])) | |
| return out | |