ms marco Mini L M L 12 v2

cross-encoder

Introduction

The Cross-Encoder MS MARCO MiniLM-L-12-v2 model is designed for tasks involving information retrieval, specifically for passage ranking in the MS MARCO dataset. It encodes queries alongside passages to rank them effectively.

Architecture

This model uses a cross-encoder architecture, which processes both the query and passage together, allowing the model to consider interactions between the two. It is implemented using popular libraries such as Transformers and SentenceTransformers, and is compatible with PyTorch.

Training

The model was trained on the MS MARCO Passage Ranking task, which involves sorting passages retrieved (e.g., via Elasticsearch) by relevance to a given query. The training code is available on the SBERT GitHub repository.

Guide: Running Locally

To use the Cross-Encoder model locally, follow these steps:

  1. Installation: Ensure you have transformers and torch installed:

    pip install transformers torch
    
  2. Load the Model: Use the following code to load the model and tokenizer:

    from transformers import AutoTokenizer, AutoModelForSequenceClassification
    import torch
    
    model = AutoModelForSequenceClassification.from_pretrained('cross-encoder/ms-marco-MiniLM-L-12-v2')
    tokenizer = AutoTokenizer.from_pretrained('cross-encoder/ms-marco-MiniLM-L-12-v2')
    
  3. Tokenize and Evaluate: Prepare your input data and evaluate:

    features = tokenizer(
        ['How many people live in Berlin?', 'How many people live in Berlin?'],
        ['Berlin has a population of 3,520,031 registered inhabitants in an area of 891.82 square kilometers.', 'New York City is famous for the Metropolitan Museum of Art.'],
        padding=True, truncation=True, return_tensors="pt"
    )
    
    model.eval()
    with torch.no_grad():
        scores = model(**features).logits
        print(scores)
    

For enhanced performance, consider using cloud-based GPU services such as AWS EC2, Google Cloud Platform, or Azure, which offer access to powerful GPUs like the NVIDIA V100.

License

The model is released under the Apache 2.0 license. This allows for both commercial and non-commercial use, modification, and distribution of the software.

More Related APIs in Text Classification