Edit model card

mdeberta-v3-base for Extractive QA

This is the mdeberta-v3-base model, fine-tuned using the SQuAD2.0 dataset. It's been trained on question-answer pairs, including unanswerable questions, for the task of Extractive Question Answering.

Overview

Language model: mdeberta-v3-base
Language: English
Downstream-task: Extractive QA
Training data: SQuAD 2.0
Eval data: SQuAD 2.0
Infrastructure: 1x NVIDIA T4

Model Usage

import torch
from transformers import(
  AutoModelForQuestionAnswering,
  AutoTokenizer,
  pipeline
)
model_name = "sjrhuschlee/mdeberta-v3-base-squad2"

# a) Using pipelines
nlp = pipeline('question-answering', model=model_name, tokenizer=model_name)
qa_input = {
'question': 'Where do I live?',
'context': 'My name is Sarah and I live in London'
}
res = nlp(qa_input)
# {'score': 0.984, 'start': 30, 'end': 37, 'answer': ' London'}

# b) Load model & tokenizer
model = AutoModelForQuestionAnswering.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)

question = 'Where do I live?'
context = 'My name is Sarah and I live in London'
encoding = tokenizer(question, context, return_tensors="pt")
start_scores, end_scores = model(
  encoding["input_ids"],
  attention_mask=encoding["attention_mask"],
  return_dict=False
)

all_tokens = tokenizer.convert_ids_to_tokens(input_ids[0].tolist())
answer_tokens = all_tokens[torch.argmax(start_scores):torch.argmax(end_scores) + 1]
answer = tokenizer.decode(tokenizer.convert_tokens_to_ids(answer_tokens))
# 'London'

Metrics

# Squad v2
{
    "eval_HasAns_exact": 77.7327935222672,
    "eval_HasAns_f1": 84.7172608568916,
    "eval_HasAns_total": 5928,
    "eval_NoAns_exact": 83.02775441547519,
    "eval_NoAns_f1": 83.02775441547519,
    "eval_NoAns_total": 5945,
    "eval_best_exact": 80.38406468457846,
    "eval_best_exact_thresh": 0.0,
    "eval_best_f1": 83.87129810154576,
    "eval_best_f1_thresh": 0.0,
    "eval_exact": 80.38406468457846,
    "eval_f1": 83.87129810154582,
    "eval_runtime": 221.4855,
    "eval_samples": 12054,
    "eval_samples_per_second": 54.423,
    "eval_steps_per_second": 2.271,
    "eval_total": 11873
}

# Squad
{
    "eval_exact_match": 83.78429517502366,
    "eval_f1": 90.96354972948996,
    "eval_runtime": 197.0364,
    "eval_samples": 10715,
    "eval_samples_per_second": 54.381,
    "eval_steps_per_second": 2.269
}
Downloads last month
49
Safetensors
Model size
278M params
Tensor type
I64
·
F32
·
Inference Examples
This model does not have enough activity to be deployed to Inference API (serverless) yet. Increase its social visibility and check back later, or deploy to Inference Endpoints (dedicated) instead.

Datasets used to train sjrhuschlee/mdeberta-v3-base-squad2

Evaluation results