Downloads · 30 days
30
11% of all-time downloads
Innovatewithapple/bert-dense-retriever
bert-dense-retriever is a feature extraction model from Innovatewithapple. Use it when you need embeddings to search or compare text. It is set up for transformers. The card lists the license as mit.
--- license: mit language: - en libraryname: transformers pipelinetag: feature-extraction tags: - bert - dense-retrieval - semantic-search - information-retrieval - ms-marco - faiss ---
Downloads · 30 days
30
11% of all-time downloads
All-time downloads
267
Public
Parameters
109M
438 MB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors438 MB · 100%
From the Hugging Face model README
license: mit language:
A dense semantic retrieval model fine-tuned on the MS MARCO Passage Ranking dataset using BERT-base-uncased.
The model encodes natural language queries and passages into dense vector embeddings that can be indexed with FAISS for efficient semantic search.
This repository contains the complete Hugging Face compatible model including tokenizer, configuration, and custom model implementation.
Backbone
Pooling
Embedding Normalization
Similarity Metric
Training Objective
| Parameter | Value |
|---|---|
| Optimizer | AdamW |
| Learning Rate | 2e-5 |
| Batch Size | 32 |
| Epochs | 10 |
| Weight Decay | 0.01 |
| Temperature | 0.05 |
| Model | Recall@10 | MRR | nDCG@10 |
|---|---|---|---|
| BERT-base-uncased | 0.4793 | 0.2837 | 0.3301 |
| Fine-tuned Dense Retriever | 0.9693 | 0.8521 | 0.8810 |
The fine-tuned model substantially improves retrieval quality on the evaluation set compared with the untuned BERT-base encoder.
The table below compares the proposed retrieval pipeline against the BM25 baseline reported by the original BEIR benchmark.
| Dataset | Retrieval Strategy | BM25 (BEIR) NDCG@10 | Pipeline NDCG@10 | Recall@10 | Recall@100 | Improvement |
|---|---|---|---|---|---|---|
| FEVER | Hybrid + Cross Encoder | 0.7530 | 0.9791 | 0.9873 | 0.9937 | +0.2261 |
| Quora | Dense + Cross Encoder | 0.7830 | 0.9686 | 0.9858 | 0.9938 | +0.1856 |
| HotpotQA | Dense + Cross Encoder | 0.6030 | 0.8977 | 0.8853 | 0.8960 | +0.2947 |
| FiQA | Dense + Cross Encoder | 0.2361 | 0.7512 | 0.8055 | — | +0.5151 |
| TREC-COVID | Hybrid + Cross Encoder | 0.6559 | 0.6868 | 0.0181 | 0.1110 | +0.0309 |
Note: BM25 scores are taken from the original BEIR benchmark and are included as the lexical retrieval baseline for comparison.
from transformers import AutoTokenizer, AutoModel
model_name = "Innovatewithapple/bert-dense-retriever"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModel.from_pretrained(
model_name,
trust_remote_code=True,
)
inputs = tokenizer(
"What is deep learning?",
return_tensors="pt"
)
embeddings = model(**inputs)
print(embeddings.shape)
This model is designed for:
GitHub Repository:
https://github.com/Innovatewithapple/dense-semantic-retrieval
Mihir Vyas