bart large mnli

facebook

Introduction

BART-LARGE-MNLI is a version of the BART model fine-tuned on the MultiNLI dataset, enabling effective zero-shot text classification. The model is particularly useful for tasks where predefined labels are not available, classifying text based on natural language inference (NLI).

Architecture

The model architecture is based on BART, which is a denoising autoencoder for sequence-to-sequence tasks. It consists of a transformer encoder-decoder setup that has been trained on a large corpus and fine-tuned for NLI tasks. The BART model is well-suited for tasks like language generation, translation, and comprehension.

Training

BART-LARGE-MNLI is trained using the MultiNLI dataset. The training involves posing sequences as NLI premises and constructing hypotheses from candidate labels. The model predicts entailment probabilities, which are used to classify sequences. This method leverages large pre-trained models for effective zero-shot classification, as proposed by Yin et al. in their research.

Guide: Running Locally

To use BART-LARGE-MNLI for zero-shot classification locally, you can employ Hugging Face's Transformers library. Below are steps to set it up:

  1. Install the Transformers library:

    pip install transformers
    
  2. Load the zero-shot classification pipeline:

    from transformers import pipeline
    classifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnli")
    
  3. Classify text:

    sequence_to_classify = "one day I will see the world"
    candidate_labels = ['travel', 'cooking', 'dancing']
    result = classifier(sequence_to_classify, candidate_labels)
    print(result)
    

For manual setup using PyTorch, load the model and tokenizer, encode the premise and hypothesis, and compute probabilities manually.

Cloud GPUs

For better performance when dealing with large datasets or running intensive computations, consider using cloud GPU services like AWS EC2, Google Cloud, or Azure.

License

The BART-LARGE-MNLI model is distributed under the MIT License, allowing for flexibility in usage and modification.

More Related APIs in Zero Shot Classification