Views
No views yet
Inference for ZSC (Zero Shot Classification) task
1>>> pipe = pipeline(
2... task='zero-shot-classification',
3... model='./tmp/checkpoint-28832'
4... )
5>>> pipe(
6... sequences='Fakta nomor 7 akan membuat ada terkejut',
7... candidate_labels=['clickbait', 'bukan clickbait'],
8... hypothesis_template='Judul video ini {}.',
9... multi_label=False
10... )
11{
12 'sequence': 'Fakta nomor 7 akan membuat ada terkejut',
13 'labels': ['clickbait', 'bukan clickbait'],
14 'scores': [0.6102734804153442, 0.38972654938697815]
15}
16>>> pipe(
17... sequences='Samsung tuntut balik Apple dengan alasan hak paten teknologi.',
18... candidate_labels=['teknologi', 'olahraga', 'bisnis', 'politik', 'kesehatan', 'kuliner'],
19... hypothesis_template='Kategori berita ini adalah {}.',
20... multi_label=True
21... )
22{
23 'sequence': 'Samsung tuntut balik Apple dengan alasan hak paten teknologi.',
24 'labels': ['politik', 'teknologi', 'kesehatan', 'bisnis', 'olahraga', 'kuliner'],
25 'scores': [0.7390161752700806, 0.6657379269599915, 0.4459509551525116, 0.38407933712005615, 0.3679264783859253, 0.14181996881961823]
26}Inference for NLI (Natural Language Inference) task
1>>> pipe = pipeline(
2... task='text-classification',
3... model='./tmp/checkpoint-28832',
4... return_all_scores=True
5... )
6>>> pipe({
7... 'text': 'Nasi adalah makanan pokok.', # Premise
8... 'text_pair': 'Saya mau makan nasi goreng.' # Hypothesis
9... })
10[
11 {'label': 'entailment', 'score': 0.25495028495788574},
12 {'label': 'neutral', 'score': 0.40920916199684143},
13 {'label': 'contradiction', 'score': 0.33584052324295044}
14]
15>>> pipe({
16... 'text': 'Python sering digunakan untuk web development dan AI research.',
17... 'text_pair': 'AI research biasanya tidak menggunakan bahasa pemrograman Python.'
18... })
19[
20 {'label': 'entailment', 'score': 0.12508109211921692},
21 {'label': 'neutral', 'score': 0.22146646678447723},
22 {'label': 'contradiction', 'score': 0.653452455997467}
23]1>>> from transformers import pipeline
2>>> pipe = pipeline(
3... task='zero-shot-classification',
4... model='./tmp/checkpoint-28832'
5... )
6>>> text = 'Resep sate ayam enak dan mudah.'
7>>> candidate_labels = ['kuliner', 'olahraga']
8>>> pipe(
9... sequences=text,
10... candidate_labels=candidate_labels,
11... hypothesis_template='Kategori judul artikel ini adalah {}.',
12... multi_label=False
13... )
14{
15 'sequence': 'Resep sate ayam enak dan mudah.',
16 'labels': ['kuliner', 'olahraga'],
17 'scores': [0.7711364030838013, 0.22886358201503754]
18}
19>>> pipe(
20... sequences=text,
21... candidate_labels=candidate_labels,
22... hypothesis_template='Kelas kalimat ini {}.',
23... multi_label=False
24... )
25{
26 'sequence': 'Resep sate ayam enak dan mudah.',
27 'labels': ['kuliner', 'olahraga'],
28 'scores': [0.7043636441230774, 0.295636385679245]
29}
30>>> pipe(
31... sequences=text,
32... candidate_labels=candidate_labels,
33... hypothesis_template='{}.',
34... multi_label=False
35... )
36{
37 'sequence': 'Resep sate ayam enak dan mudah.',
38 'labels': ['kuliner', 'olahraga'],
39 'scores': [0.5986711382865906, 0.4013288915157318]
40}
41multilingual-NLI-26lang-2mil7 dataset is machine-translated, this dataset slightly improve result of NLI benchmark and extensively improve result of ZSC benchmark. Both evaluation and testing data is only based on IndoNLI dataset.| Model | bigbird-small-indonesian-nli | xlm-roberta-large-xnli | mDeBERTa-v3-base-xnli-multilingual-nli-2mil7 |
|---|---|---|---|
| Parameter | 30.6M | 559.9M | 278.8M |
| Multilingual | V | V | |
| Finetuned on IndoNLI | V | V | |
| Finetuned on multilingual-NLI-26lang-2mil7 | V | ||
| Test (Lay) | 0.6888 | 0.2226 | 0.8151 |
| Test (Expert) | 0.5734 | 0.3505 | 0.7775 |
Kalimat ini mengekspresikan perasaan {}. and {}.. Take note F1 score measurement only calculate label with highest probability.| Model | Multi-label | Use template | F1 Score |
|---|---|---|---|
| bigbird-small-indonesian-nli | V | V | 0.3574 |
| V | 0.3654 | ||
| V | 0.3985 | ||
| 0.4160 | |||
| xlm-roberta-large-xnli | V | V | 0.6292 |
| V | 0.5596 | ||
| V | 0.5737 | ||
| 0.5433 | |||
| mDeBERTa-v3-base-xnli-multilingual-nli-2mil7 | V | V | 0.5324 |
| V | 0.5499 | ||
| V | 0.5269 | ||
| 0.5228 |