LETZClassify: zero-shot text classification for Luxembourgish

A model for zero-shot topic classification of Luxembourgish text. Give it a text and any list of candidate labels written in Luxembourgish, and it gives each label its own probability. You can take the most likely label, or every label above a certain threshold, which can be one label, several or none. No task-specific training data is needed.

It is Qwen/Qwen3-Embedding-0.6B fine-tuned on LETZ v2.0, a dataset of label/text pairs built from the Lรซtzebuerger Online Dictionnaire (LOD).

Usage

Requires sentence-transformers>=6.0.

import torch
from sentence_transformers import SentenceTransformer

model = SentenceTransformer("fredxlpy/LETZClassify")
SCALE, BIAS = 35.9613, -12.5985  # from classifier_head.json

texts = [
    "D'Equipe huet hire leschte Match 3:1 gewonnen a spillt elo an der รฉischter Divisioun.",
    "D'Regierung huet en neit Gesetz iwwer d'Logementspolitik deposรฉiert.",
    "De Minister huet d'Nationalekipp nom Fussballsmatch am Stadion besicht.",
    "Mir hunn eng Bouneschlupp mat Mettwurscht giess.",
]
labels = ["Sport", "Politik", "Wirtschaft", "Kultur", "Technologie"]

text_emb = model.encode_query(texts)
label_emb = model.encode_document([f"An dรซsem Beispill geet et em {l}." for l in labels])
probs = torch.sigmoid(SCALE * model.similarity(text_emb, label_emb) + BIAS)  # (n_texts, n_labels)

for text, p in zip(texts, probs):
    print(text)
    for i in p.argsort(descending=True):
        print(f"  {labels[i]:<12} {p[i]:.2f}")

Output:

D'Equipe huet hire leschte Match 3:1 gewonnen a spillt elo an der รฉischter Divisioun.
  Sport        0.97
  Kultur       0.01
  Wirtschaft   0.01
  Technologie  0.00
  Politik      0.00
D'Regierung huet en neit Gesetz iwwer d'Logementspolitik deposรฉiert.
  Politik      1.00
  Wirtschaft   0.23
  Technologie  0.12
  Kultur       0.12
  Sport        0.02
De Minister huet d'Nationalekipp nom Fussballsmatch am Stadion besicht.
  Sport        1.00
  Politik      0.54
  Kultur       0.23
  Wirtschaft   0.02
  Technologie  0.01
Mir hunn eng Bouneschlupp mat Mettwurscht giess.
  Sport        0.14
  Kultur       0.13
  Wirtschaft   0.04
  Politik      0.03
  Technologie  0.00

The third text is about both sport and politics, and both labels get a high probability. The last text is about food, which is not among the labels, so every label gets a low probability.

How it works: the text is encoded with encode_query, which adds the classification instruction. Each label is put into the sentence "An dรซsem Beispill geet et em {label}." and encoded with encode_document. The cosine similarity is turned into a probability with the two numbers in classifier_head.json.

Tips:

  • Keep the label template above: the model was trained with it. Labels work best as short Luxembourgish nouns or noun phrases ("Sport", "Iessen an Drรฉnken").
  • The probabilities of the labels are independent of each other, so they do not add up to 1. Adding or removing a candidate label does not change the probabilities of the others.
  • Label embeddings depend only on the labels: for many texts, compute them once and reuse them.
  • This is not an NLI model, so it does not work with the transformers zero-shot-classification pipeline.
  • Texts are truncated to 512 tokens.

Limitations

  • The model learned from dictionary example sentences, which are short. It may be less accurate on long or very specialised texts.
  • When a text covers several topics, it does not always find all of them.
  • It is meant for topics; it is weak at sentiment.

Training

Trained on all three LETZ v2.0 subsets (LETZ-SYN, LETZ-WoT, LETZ-TOP), with a sigmoid (binary cross-entropy) loss that scores every text/label pair on its own. All settings are in letz_training_args.json, and the training code is train.py in github.com/fredxlpy/LETZ.

License

Apache 2.0, the license of the base model. LETZ is built from the LOD, which is published under CC0.

Citation

LETZ was introduced in:

@inproceedings{philippy-etal-2024-forget,
    title = "Forget {NLI}, Use a Dictionary: Zero-Shot Topic Classification for Low-Resource Languages with Application to {L}uxembourgish",
    author = "Philippy, Fred  and Haddadan, Shohreh  and Guo, Siwen",
    editor = "Melero, Maite  and Sakti, Sakriani  and Soria, Claudia",
    booktitle = "Proceedings of the 3rd Annual Meeting of the Special Interest Group on Under-resourced Languages @ {LREC}-{COLING} 2024",
    month = may,
    year = "2024",
    address = "Torino, Italia",
    publisher = "ELRA and ICCL",
    url = "https://aclanthology.org/2024.sigul-1.13/",
    pages = "97--104",
}
Downloads last month
15
Safetensors
Model size
0.6B params
Tensor type
BF16
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for fredxlpy/LETZClassify

Finetuned
(375)
this model

Dataset used to train fredxlpy/LETZClassify