Views
No views yet
1>>> from transformers import pipeline
2>>> classifier = pipeline(
3... "zero-shot-classification",
4... model="KBlab/megatron-bert-large-swedish-cased-165-zero-shot"
5... )
6>>> classifier(
7... "Ruben Östlunds ”Triangle of sadness” nomineras till en Golden Globe i kategorin bästa musikal eller komedi.",
8... candidate_labels=["hälsa", "politik", "sport", "religion", "nöje"],
9... hypothesis_template="Detta exempel handlar om {}.",
10... )
11{'sequence': 'Ruben Östlunds ”Triangle of sadness” nomineras till en Golden Globe i kategorin bästa musikal eller komedi.',
12 'labels': ['nöje', 'sport', 'religion', 'hälsa', 'politik'],
13 'scores': [0.9274595379829407,
14 0.025105971843004227,
15 0.018440095707774162,
16 0.017049923539161682,
17 0.011944468133151531]}@misc{sikora2023swedish,
author = {Sikora, Justyna},
title = {The KBLab Blog: Swedish zero-shot classification model},
url = {https://kb-labb.github.io/posts/2023-02-12-zero-shot-text-classification/},
year = {2023}
}