🚀 ScandiNLI - Natural Language Inference model for Scandinavian Languages
ScandiNLI is a fine - tuned model based on NbAiLab/nb-bert-large, designed for Natural Language Inference in Danish, Norwegian Bokmål, and Swedish. It provides different model sizes to meet various needs.
🚀 Quick Start
You can use this model in your scripts as follows:
Basic Usage
>>> from transformers import pipeline
>>> classifier = pipeline(
... "zero-shot-classification",
... model="alexandrainst/scandi-nli-large",
... )
>>> classifier(
... "Mexicansk bokser advarer Messi - 'Du skal bede til gud, om at jeg ikke finder dig'",
... candidate_labels=['sundhed', 'politik', 'sport', 'religion'],
... hypothesis_template="Dette eksempel handler om {}",
... )
{'sequence': "Mexicansk bokser advarer Messi - 'Du skal bede til gud, om at jeg ikke finder dig'",
'labels': ['sport', 'religion', 'politik', 'sundhed'],
'scores': [0.6134647727012634,
0.30309760570526123,
0.05021871626377106,
0.03321893885731697]}
✨ Features
- Multiple Language Support: Supports Danish, Norwegian Bokmål, and Swedish for Natural Language Inference.
- Model Variety: Offers models of different sizes, including large, base, and small, to balance performance and resource consumption.
📚 Documentation
Performance
We assess the models both on their aggregate Scandinavian performance, as well as their language - specific Danish, Swedish, and Norwegian Bokmål performance. In all cases, we report Matthew's Correlation Coefficient (MCC), macro - average F1 - score, as well as accuracy.
Scandinavian Evaluation
The Scandinavian scores are the average of the Danish, Swedish, and Norwegian scores.
Danish Evaluation
We use a test split of the DanFEVER dataset to evaluate the Danish performance of the models.
Swedish Evaluation
We use the test split of the machine - translated version of the MultiNLI dataset to evaluate the Swedish performance of the models.
Norwegian Evaluation
We use the test split of the machine - translated version of the MultiNLI dataset to evaluate the Norwegian performance of the models.
Training procedure
It has been fine - tuned on a dataset composed of DanFEVER as well as machine - translated versions of MultiNLI and CommitmentBank into all three languages, and machine - translated versions of FEVER and Adversarial NLI into Swedish.
The training split of DanFEVER is generated using this gist.
The three languages are sampled equally during training, and they're validated on validation splits of DanFEVER and machine - translated versions of MultiNLI for Swedish and Norwegian Bokmål, sampled equally.
Check out the Github repository for the code used to train the ScandiNLI models, and the full training logs can be found in this Weights and Biases report.
Training hyperparameters
The following hyperparameters were used during training:
- learning_rate: 2e - 05
- train_batch_size: 2
- eval_batch_size: 2
- seed: 4242
- gradient_accumulation_steps: 16
- total_train_batch_size: 32
- optimizer: Adam with betas=(0.9, 0.999) and epsilon = 1e - 08
- lr_scheduler_type: linear
- lr_scheduler_warmup_steps: 500
- max_steps: 50,000
📄 License
This model is released under the Apache 2.0 license.
📦 Additional Information
Property |
Details |
Supported Languages |
Danish, Norwegian Bokmål, Swedish |
Model Type |
Fine - tuned Natural Language Inference model |
Training Data |
DanFEVER, machine - translated MultiNLI, CommitmentBank, machine - translated FEVER, Adversarial NLI |
Pipeline Tag |
zero - shot - classification |
Demo |
[Hugging Face Space](https://huggingface.co/spaces/alexandrainst/zero - shot - classification) |