StaticKD-compact: Multilingual IPTC News-Topic Classifier With a Pruned Vocabulary

StaticKD-compact is a smaller copy of the StaticKD classifier. It assigns a news article 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 its 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.

Use the full StaticKD model unless RAM is the main constraint and all target languages are well covered by the training data. The compact variant needs about half the RAM of StaticKD, but its accuracy falls almost to zero on languages whose rare tokens were removed from the vocabulary (see How it differs from StaticKD).

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). StaticKD 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.
  3. Ensembling. Three students were trained with seeds 0, 1, and 2, and their tables and biases were averaged into one model.

StaticKD-compact then prunes the vocabulary of StaticKD without further training. Every token piece that occurs fewer than 10 times in the training data is removed from the tokenizer and from the table. Single characters are always kept, so every text can still be tokenized. The remaining table rows and the bias are identical to those of StaticKD.

Component StaticKD-compact StaticKD
Token table 335,441 tokens ร— 17 labels, float16 500,353 tokens ร— 17 labels, float16
Bias 17 values, float32 (identical) 17 values, float32
Tokenizer pruned Unigram tokenizer of potion-multilingual-128M (case-sensitive, no lowercasing) full Unigram tokenizer
Maximum input first 1,024 tokens of a text first 1,024 tokens of a text
File size 23 MiB 34 MiB

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.

How it differs from StaticKD

The pruned tokenizer splits words that contained a removed token into shorter pieces, so the model reads different tokens than StaticKD on the same text. This costs little in well-covered languages and fails in languages whose text consists mostly of rare tokens.

  • Smaller and faster. Model RAM falls from 501 to 277 MiB, the file from 34 to 23 MiB, and single-core throughput rises from 539 to 601 articles per second.
  • Lower test accuracy. Test macro-F1 falls from 0.545 to 0.484 and test accuracy from 0.641 to 0.544. The paired difference of 0.060 [0.003โ€“0.100] is not significant after Holm correction in the main bootstrap of the paper (p = 0.090), but it is significant in the bootstrap stratified by test-set source (p = 0.018).
  • Failure on languages with rare tokens. In Bangla, Malayalam, Odia, and Punjabi, at least 67% of the token occurrences come from tokens seen fewer than 10 times in the training data. StaticKD-compact reaches an accuracy of 0.013 on these four languages against 0.578 on the other languages. The full StaticKD reaches 0.624 on the same four languages and the teacher 0.738.
  • Development set. On the four languages of the development set, which are well covered by the training data, the two models score almost the same (macro-F1 0.754 against 0.761).

Intended use

  • Topic classification of news articles (title and body) into the 17 top-level IPTC Media Topics when RAM is tight and every target language has substantial training data.
  • High-volume multilingual pipelines on CPU, for example filtering or routing a news stream.

Before deployment, check accuracy on labeled articles in every target language. 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

  • Languages with little or no training data, and any language in which most tokens are rare in the training data (for example Bangla, Malayalam, Odia, and Punjabi). Use the full StaticKD model instead.
  • 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.
  • 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.

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.

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 the StaticKD models 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. Most of the model RAM is taken by the Unigram tokenizer, so pruning the vocabulary lowers RAM much more than file size.

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. The token counts that decided which tokens StaticKD-compact keeps were taken from the same 285,999 articles.

Training settings of StaticKD: 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. StaticKD-compact received no further training.

Limitations

  • Pruned languages. Accuracy collapses on languages whose text consists mostly of tokens that are rare in the training data (see above). Accuracy must be checked per language before deployment.
  • Weak labels. For the full StaticKD, 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.
  • Weak languages. The full 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), with a mean accuracy of 0.407 against 0.643 for the teacher. Per-language results for the compact variant on these languages are not reported in the paper.
  • 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.
  • 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
5.7M 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-compact

Finetuned
(41)
this model