SAVRN
Search Contact SAVRN

Open-weight model · Question answering

bert-medium-squad2-distilled

by Deepset deepset/bert-medium-squad2-distilled

Haystack version 1.x distillation feature was used for training. deepset/bert-large-uncased-whole-word-masking-squad2 was used as the teacher model. Haystack is an AI orchestration framework to build customizable, production-ready LLM applications.

Parameters41M
Context512
Weights329.0 MB
Licensemit
AccessOpen weights
Monthly Downloads32.2k

Runs On

What it takes to serve bert-medium-squad2-distilled (41M parameters): the memory its weights need at each precision, and the cheapest way to rent enough data-center GPUs to hold them.

PrecisionWeightsMemory neededCheapest setupPer hourAlso fits
16-bit 0.1 GB 0.1 GB 1x MI300X (192 GB)
Vultr
$1.85 1x H100 $1.99 · 1x MI325X $2.00
8-bit 0.0 GB 0.0 GB 1x MI300X (192 GB)
Vultr
$1.85 1x H100 $1.99 · 1x MI325X $2.00
4-bit 0.0 GB 0.0 GB 1x MI300X (192 GB)
Vultr
$1.85 1x H100 $1.99 · 1x MI325X $2.00

Memory is the weights at that precision plus 20% for the runtime and a short context; a long context needs more. Prices are the lowest on-demand hourly rates in the SAVRN Index, read Sep 18, 2026.

Model Card

By Deepset, published under mit, revision 35d9bf85420e.

Haystack version 1.x distillation feature was used for training. deepset/bert-large-uncased-whole-word-masking-squad2 was used as the teacher model. Haystack is an AI orchestration framework to build customizable, production-ready LLM applications. You can use this model in Haystack to do extractive question answering on documents. To load and run the model with Haystack: For a complete example with an extractive question answering pipeline that scales over many documents, check out the corresponding Haystack tutorial. - Timo Möller: timo.moeller [at] deepset.ai deepset is the company behind the production-ready open-source AI framework Haystack. We also have a Discord community open to…

Read Deepset's full model card

bert-medium-squad2-distilled for Extractive QA

Overview

Language model: deepset/roberta-base-squad2-distilled
Language: English
Training data: SQuAD 2.0 training set
Eval data: SQuAD 2.0 dev set
Infrastructure: 1x V100 GPU
Published: Apr 21st, 2021

Details

  • Haystack version 1.x distillation feature was used for training. deepset/bert-large-uncased-whole-word-masking-squad2 was used as the teacher model.

Hyperparameters

batch_size = 6
n_epochs = 2
max_seq_len = 384
learning_rate = 3e-5
lr_schedule = LinearWarmup
embeds_dropout_prob = 0.1
temperature = 5
distillation_loss_weight = 1

Usage

In Haystack

Haystack is an AI orchestration framework to build customizable, production-ready LLM applications. You can use this model in Haystack to do extractive question answering on documents. To load and run the model with Haystack:

# After running pip install haystack-ai "transformers[torch,sentencepiece]"

from haystack import Document
from haystack.components.readers import ExtractiveReader

docs = [
    Document(content="Python is a popular programming language"),
    Document(content="python ist eine beliebte Programmiersprache"),
]

reader = ExtractiveReader(model="deepset/bert-medium-squad2-distilled")
reader.warm_up()

question = "What is a popular programming language?"
result = reader.run(query=question, documents=docs)
# {'answers': [ExtractedAnswer(query='What is a popular programming language?', score=0.5740374326705933, data='python', document=Document(id=..., content: '...'), context=None, document_offset=ExtractedAnswer.Span(start=0, end=6),...)]}

For a complete example with an extractive question answering pipeline that scales over many documents, check out the corresponding Haystack tutorial.

In Transformers

from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline

model_name = "deepset/bert-medium-squad2-distilled"

# a) Get predictions
nlp = pipeline('question-answering', model=model_name, tokenizer=model_name)
QA_input = {
    'question': 'Why is model conversion important?',
    'context': 'The option to convert models between FARM and transformers gives freedom to the user and let people easily switch between frameworks.'
}
res = nlp(QA_input)

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

Performance

"exact": 68.6431398972458
"f1": 72.7637083790805

Authors

  • Timo Möller: timo.moeller [at] deepset.ai
  • Julian Risch: julian.risch [at] deepset.ai
  • Malte Pietsch: malte.pietsch [at] deepset.ai
  • Michel Bartels: michel.bartels [at] deepset.ai

About us

deepset is the company behind the production-ready open-source AI framework Haystack.

Some of our other work: - Distilled roberta-base-squad2 (aka "tinyroberta-squad2") - German BERT, GermanQuAD and GermanDPR, German embedding model - deepset Cloud, deepset Studio

Get in touch and join the Haystack community

For more info on Haystack, visit our GitHub repo and Documentation. We also have a Discord community open to everyone!

Twitter | LinkedIn | Discord | GitHub Discussions | Website | YouTube

By the way: we're hiring!

Configuration

Architecture
BertForQuestionAnswering
Context length (tokens)
512
Layers
8
Hidden size
512
Feed-forward size
2,048
Attention heads
8
Vocabulary size
30,522
Model type
bert

Identity and Version

Repository
deepset/bert-medium-squad2-distilled
Publisher
Deepset
Task
Question answering
Modality
Text
Library
transformers
Parameters
41M parameters
Languages
en
Revision
35d9bf85420e75cd5685551e825e02fd2c553b4c
First published
2022-03-02
Last updated
2024-09-24

Files and Weights

9 files, 329.7 MB in total. The weights are 2 files totalling 329.0 MB in bin, safetensors.

Weights2 files · 329.0 MB
Configuration2 files · 788 B
Tokenizer3 files · 697.9 KB
Documentation1 file · 5.9 KB
Repository1 file · 1.2 KB
Every file
FileTypeSizeSHA-256
model.safetensorsWeights164.5 MB 5c13c474e798
pytorch_model.binWeights164.5 MB a9c401109aa5
config.jsonConfiguration676 B
special_tokens_map.jsonConfiguration112 B
README.mdDocumentation5.9 KB
.gitattributesRepository1.2 KB
tokenizer.jsonTokenizer466.1 KB
tokenizer_config.jsonTokenizer335 B
vocab.txtTokenizer231.5 KB

License and Download

License
mit
Access
Open weights, no gate
Download size
329.0 MB
Download from Deepset

Released by Deepset through its official repository on Hugging Face. Read the license.

Built From

  • Trained on (disclosed) squad_v2

Evaluations

Each result is shown as reported, with the conditions its reporter stated. None is a SAVRN measurement. A comparison lines two results up only when their configuration, unit and setup are all stated and identical.

BenchmarkConditionsResultReported byRevisionDate
squad_v2 Configuration squad_v2Task Question AnsweringMetric Exact MatchComparison conditions not established 69.8231 deepset
Publisher reported
Evaluated revision not stated
squad_v2 Configuration squad_v2Task Question AnsweringMetric F1Comparison conditions not established 72.9232 deepset
Publisher reported
Evaluated revision not stated

Memory Requirements

PrecisionWeights in memory
As published329.0 MB
16-bit0.1 GB
8-bit0.0 GB
4-bit0.0 GB

Weights only, from the published parameter count; the key-value cache and runtime add to this.

Questions About bert-medium-squad2-distilled

How much GPU memory does bert-medium-squad2-distilled need?

About 0.1 GB at 16-bit and 0 GB at 4-bit: the weights (41M parameters) plus a working margin. A long context needs more.

What is the cheapest GPU to run bert-medium-squad2-distilled on?

At 16-bit, 1x MI300X from $1.85 an hour; at 4-bit, 1x MI300X from $1.85 an hour, at the lowest on-demand prices the SAVRN Index lists.

Can I use bert-medium-squad2-distilled commercially?

Yes. bert-medium-squad2-distilled is released under MIT License. The MIT License is a short permissive license. It permits commercial use, modification and redistribution, provided the copyright notice and permission notice are included.

What is bert-medium-squad2-distilled's context length?

512 tokens, from the maximum position embeddings in its published configuration.

Similar Models

Model · Question answering

minilm-uncased-squad2

Deepset

Haystack is an AI orchestration framework to build customizable, production-ready LLM applications. You can use this model in Haystack to do extractive question answering on documents. To load and run the model with Haystack: For a complete example with an extractive question answering pipeline that scales over many documents, check out the corresponding Haystack tutorial. Evaluated on the SQuAD 2.0 dev set with the official eval script. Timo Möller: [email protected] deepset is the company behind the production-ready open-source AI framework Haystack. We also have a Discord community open to everyone!

Open weights cc-by-4.0 33M parameters 512 tokens transformers

Model · Question answering

mobilebert-uncased-squad-v2

Qingqing Cao

MobileBERT is a thin version of BERTLARGE, while equipped with bottleneck structures and a carefully designed balance between self-attentions and feed-forward networks. This model was fine-tuned from the HuggingFace checkpoint google/mobilebert-uncased on SQuAD2.0. CPU: Intel(R) Core(TM) i7-6800K CPU @ 3.40GHz Memory: 32 GiB GPUs: 2 GeForce GTX 1070, each with 8GiB memory GPU driver: 418.87.01, CUDA: 10.1 It took about 3.5 hours to finish. Note that the above results didn't involve any hyperparameter search.

Open weights mit 25M parameters 512 tokens transformers

Model · Question answering

mobilebert-uncased-squad-v1

Qingqing Cao

MobileBERT is a thin version of BERTLARGE, while equipped with bottleneck structures and a carefully designed balance between self-attentions and feed-forward networks. This model was fine-tuned from the HuggingFace checkpoint google/mobilebert-uncased on SQuAD1.1. CPU: Intel(R) Core(TM) i7-6800K CPU @ 3.40GHz Memory: 32 GiB GPUs: 2 GeForce GTX 1070, each with 8GiB memory GPU driver: 418.87.01, CUDA: 10.1 It took about 3 hours to finish. Note that the above results didn't involve any hyperparameter search.

Open weights mit 25M parameters 512 tokens transformers

The DistilBERT model was proposed in the blog post Smaller, faster, cheaper, lighter: Introducing DistilBERT, adistilled version of BERT, and the paper DistilBERT, adistilled version of BERT: smaller, faster, cheaper and lighter. DistilBERT is a small, fast, cheap and light Transformer model trained by distilling BERT base. It has 40% less parameters than bert-base-uncased, runs 60% faster while preserving over 95% of BERT's performances as measured on the GLUE language understanding benchmark. This model is a fine-tune checkpoint of DistilBERT-base-cased, fine-tuned using (a second step of) knowledge distillation on SQuAD v1.1. - See this repository for more about Distil\ (a class of…

Open weights apache-2.0 65M parameters 512 tokens transformers

The DistilBERT model was proposed in the blog post Smaller, faster, cheaper, lighter: Introducing DistilBERT, adistilled version of BERT, and the paper DistilBERT, adistilled version of BERT: smaller, faster, cheaper and lighter. DistilBERT is a small, fast, cheap and light Transformer model trained by distilling BERT base. It has 40% less parameters than bert-base-uncased, runs 60% faster while preserving over 95% of BERT's performances as measured on the GLUE language understanding benchmark. This model is a fine-tune checkpoint of DistilBERT-base-uncased, fine-tuned using (a second step of) knowledge distillation on SQuAD v1.1. - See this repository for more about Distil\ (a class of…

Open weights apache-2.0 66M parameters 512 tokens transformers