StaticKD: Multilingual IPTC News-Topic Classifier

StaticKD assigns a news article in any of many languages to one of the 17 top-level topics of the IPTC Media Topic taxonomy. The model is a table that holds 17 topic scores (logits) for each token of a multilingual vocabulary. A text is classified by tokenizing it, averaging the table rows of its tokens, and adding a bias vector. Inference needs only numpy, tokenizers, and safetensors and runs on a single CPU core at several hundred articles per second.

A smaller variant with a pruned vocabulary is published separately as StaticKD-compact. That variant fails on several languages (see its model card).

Resources

Model description

StaticKD is a distilled copy of the multilingual IPTC classifier classla/multilingual-IPTC-news-topic-classifier, an XLM-RoBERTa-large model with 559.9 million parameters (the teacher). It was built in three steps.

  1. Distillation. The teacher labeled 285,999 news articles in 69 languages once and stored its 17 logits for every article. A student was then trained to imitate the teacher distribution with a Kullbackโ€“Leibler loss at temperature 1. The student averages the static token embeddings of an article and applies one linear layer. Its embeddings start from minishlab/potion-multilingual-128M, a Model2Vec model that places the tokens of 101 languages in one shared 256-dimensional space. The embeddings and the linear layer were trained together.
  2. Folding. The classification layer is linear, so it can be multiplied into the embeddings after training. The product is a table T = E Wแต€ with one row of 17 logits per token. The 256-dimensional embeddings are not needed at inference time.
  3. Ensembling. Three students were trained with seeds 0, 1, and 2. Averaging their logits is equivalent to averaging their tables and biases, so the released model is one averaged table at the cost of a single model.
Component Value
Token table 500,353 tokens ร— 17 labels, float16
Bias 17 values, float32
Tokenizer Unigram tokenizer of potion-multilingual-128M (case-sensitive, no lowercasing)
Parameters 8.5 million
Maximum input first 1,024 tokens of a text
Files model.safetensors (table and bias), tokenizer.json, config.json

Computation. The tokenizer encodes the text without special tokens. The first 1,024 token ids are kept and unknown tokens ([UNK]) are removed. A text without any known token is represented by token id 0. The table rows of the remaining ids are averaged in float32, the bias is added, and softmax gives the label probabilities. statickd_inference.py implements exactly this computation.

Intended use

  • Topic classification of news articles (title and body) into the 17 top-level IPTC Media Topics.
  • High-volume or low-cost multilingual pipelines on CPU, for example filtering or routing a news stream, where a transformer classifier is too slow or too large.
  • A first stage in front of the teacher. Articles on which StaticKD has low confidence can be passed to the teacher. In the paper, passing all articles with a top probability below 0.8 to the quantized teacher matched the teacher's test macro-F1 (0.602 against 0.600) at 2.5 times the teacher throughput.

The paper used the title and body truncated to the first 512 words as input. Training articles had at least 75 words (200 characters for Chinese, Japanese, Thai, and Burmese).

Out-of-scope use

  • Multi-label classification or IPTC levels below the top level. The model gives one distribution over the 17 top-level topics.
  • Short texts such as headlines or social media posts, and text that is not news.
  • Languages that occur neither in the training data nor in the pre-training data of XLM-R without per-language monitoring of accuracy (see Limitations).
  • Decisions about individuals or other high-stakes uses without human review.

Labels

The 17 top-level IPTC Media Topics, in the order of the output vector:

id label id label
0 arts, culture, entertainment and media 9 labour
1 conflict, war and peace 10 lifestyle and leisure
2 crime, law and justice 11 politics
3 disaster, accident and emergency incident 12 religion
4 economy, business and finance 13 science and technology
5 education 14 society
6 environment 15 sport
7 health 16 weather
8 human interest

How to use

Install the three dependencies and download all files of this repository into one folder.

pip install numpy tokenizers safetensors
from statickd_inference import StaticKDClassifier

model = StaticKDClassifier(".")  # folder with config.json, model.safetensors, tokenizer.json

texts = [
    "The central bank raised its key interest rate by half a percentage point on Thursday "
    "to curb inflation, and markets fell sharply after the announcement.",
    "El delantero marcรณ dos goles en la segunda parte y el equipo se clasificรณ para la final "
    "de la Copa del Rey.",
]
print(model.predict(texts, top_k=2))
# [[('economy, business and finance', 1.0), ('arts, culture, entertainment and media', 0.0)],
#  [('sport', 1.0), ('arts, culture, entertainment and media', 0.0)]]

probs = model.predict_proba(texts)  # numpy array of shape (2, 17), label order as above

From the command line:

python statickd_inference.py "Heavy rain and strong winds are expected across the region this weekend."

On the 12,744 test articles and the 1,000 development articles of the paper, statickd_inference.py reproduces the logits of the reference implementation bit for bit.

Evaluation

Test set. The test set has 12,744 news articles in 47 languages. Its labels do not come from the teacher. They come from human annotation (32.1% of the articles), publisher categories (20.4%), and news-site sections (47.5%), each mapped to the top-level IPTC topics. The articles come from CC-NEWS 2024โ€“2026 and from five public datasets (MasakhaNEWS, L3Cube-IndicNews, MN-DS, a Bangla news dataset, and IndoNews). The CC-NEWS articles come from news sites that are absent from the training data, and a contamination filter removed articles that share a large part of their text with training documents.

Model Test macro-F1 [95% CI] Test accuracy Share of teacher macro-F1 Development macro-F1
Teacher (XLM-R-large) 0.598 [0.546โ€“0.643] 0.700 100.0% 0.822
StaticKD 0.545 [0.490โ€“0.605] 0.641 91.1% 0.761
StaticKD-compact 0.484 [0.421โ€“0.597] 0.544 81.0% 0.754

The confidence intervals come from a bootstrap that resamples whole news sites. The development set is the development split of EMMediaTopic (1,000 articles in Catalan, Greek, Croatian, and Slovenian with GPT-4o labels). The teacher's hyperparameters were tuned on this split, so the development scores are not comparable with the test scores.

The scores depend on how much training data the language of an article has:

Training articles in the language Test articles Teacher macro-F1 StaticKD macro-F1
at least 500 7,644 0.633 0.618
fewer than 500 2,243 0.537 0.478
none 2,857 0.557 0.402

Label noise. About two thirds of the test labels are editorial labels, which record newsroom decisions and not annotation under a guideline. Checks on samples of these articles found that the editorial label names the main topic for 76.5% to 79.3% of the articles (80.4% after a post-hoc recheck). Absolute scores therefore understate agreement with the main topic of an article. On 300 audited articles, replacing the editorial labels with corrected labels raised the accuracy of StaticKD from 72.3% to 81.7% and that of the teacher from 78.0% to 90.7%.

Efficiency

Model Latency p50 / p95, 1 core (ms) Throughput, 1 core (articles/s) Throughput, 4 cores (articles/s) Model RAM (MiB) File size (MiB)
Teacher, PyTorch fp32 2,816 / 2,894 0.343 0.969 2,950 2,136
Teacher, ONNX int8 1,190 / 1,229 0.790 2.53 1,375 537
StaticKD 2.01 / 3.31 539 1,827 501 34
StaticKD-compact 1.78 / 3.17 601 2,005 277 23

All models ran on an Intel Core Ultra 7 155H laptop with each process pinned to one or four physical performance cores, and each value is the median of three sessions. Throughput used batches of 64 on 3,000 test articles for StaticKD and batches of 8 on 96 articles for the teacher. Latency was measured with one article per call. Model RAM is the increase in resident memory after loading. On identical articles, StaticKD reached about 600 times the throughput of the ONNX int8 teacher. Most of the model RAM is taken by the Unigram tokenizer, and tokenization takes 98% of the prediction time.

Training data

  • EMMediaTopic 1.0: the 20,000-article training split in Catalan, Greek, Croatian, and Slovenian. The teacher was trained on the same split.
  • CC-News 2019โ€“2021: 265,999 news articles in 69 languages. The language of every article was checked with fastText language identification. Articles were kept with at least 75 words and truncated to 512 words, and the number of articles per site and language was capped.

The combined set has 285,999 articles in 69 languages from 2,960 news sites. The training targets are the teacher's logits for these articles, not human labels. A split of 3% of these articles (8,579) was used to choose the training epoch.

Training settings: 6 epochs, batch size 64, AdamW (learning rate 0.003) for the linear layer, SparseAdam (learning rate 0.001) for the embeddings, dropout 0.1 on the averaged embedding, and token dropout 0.2.

Limitations

  • Weak labels. Test F1 is lowest for society (0.16), disaster (0.29), human interest (0.32), and conflict (0.37). These labels also rank among the hardest for the teacher. F1 is highest for sport (0.88), weather (0.84), and education (0.75).
  • Weak languages. StaticKD is weakest on African languages that are absent from its training data and from the pre-training data of XLM-R (Igbo, Luganda, Lingala, Nigerian Pidgin, Kirundi, Shona, Tigrinya, and Yoruba). Its mean accuracy on these languages is 0.407 against 0.643 for the teacher. Accuracy should be monitored per language in deployment.
  • Test scores are not deployment estimates. The test set has at most 50 articles per languageโ€“label pair, so its label distribution is artificial. In 27 of its 47 languages the articles come from fewer than 3 effective news sites, and the whole test set has an effective number of only 13.8 site clusters. Two clusters hold 37.3% of the articles.
  • Single-label, top level only. Multi-topic articles and deeper IPTC levels were not evaluated.
  • Inherited errors. The model learned only from the teacher's outputs and passes on the teacher's errors and biases.
  • Hardware. Efficiency was measured on one laptop. Absolute speeds will differ on other hardware.

Citation

Citation will be added when the paper is published.

Downloads last month
-
Safetensors
Model size
8.51M params
Tensor type
F32
ยท
F16
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for obikastanya/statickd-iptc

Finetuned
(41)
this model