Downloads · 30 days
0
mia-project-2025/bert-base-uncased-feature-extraction-quora-question-pairs
bert-base-uncased-feature-extraction-quora-question-pairs is a machine learning model from mia-project-2025. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as apache-2.0.
This model uses feature-based transfer learning with tomaarsen/bert-base-nq-prompts as a frozen encoder, combined with a lightweight feedforward classifier trained on the Quora Question Pairs dataset.
Downloads · 30 days
0
Access
Public
Updated Aug 21, 2025
Repo size
1.6 MB
Likes
0
Public
Click a slice to open those files.
.log1.8 MB · 53%
From the Hugging Face model README
This model uses feature-based transfer learning with tomaarsen/bert-base-nq-prompts as a frozen encoder, combined with a lightweight feedforward classifier trained on the Quora Question Pairs dataset.
It classifies whether two questions are duplicates or not.
tomaarsen/bert-base-nq-prompts (frozen)lr=3e-5)| Metric | Score |
|---|---|
| Train Loss | 0.3224 |
| Eval Loss | 0.3559 |
| Accuracy | 83.42% |
| Precision | 79.36% |
| Recall | 74.87% |
| F1 Score | 77.05% |
| ROC AUC | 91.50% |
import torch
from transformers import AutoTokenizer
from torch import nn
# Load tokenizer and model
tokenizer = AutoTokenizer.from_pretrained("tomaarsen/bert-base-nq-prompts")
model = torch.load("bert_feature_based_quora.pt", map_location="cpu")
model.eval()
def predict_duplicate(q1, q2):
# Extract embeddings
inputs1 = tokenizer(q1, return_tensors="pt", padding=True, truncation=True)
inputs2 = tokenizer(q2, return_tensors="pt", padding=True, truncation=True)
with torch.no_grad():
# Load frozen encoder
encoder = torch.load("bert_feature_based_quora_weights.pt", map_location="cpu")
emb1 = encoder(**inputs1).last_hidden_state[:, 0, :]
emb2 = encoder(**inputs2).last_hidden_state[:, 0, :]
features = torch.cat([emb1, emb2], dim=1)
# Predict
logits = model(features)
pred = torch.argmax(logits, dim=1).item()
return "Duplicate" if pred == 1 else "Not Duplicate"
# Example
print(predict_duplicate("How can I learn Python?", "What are the best ways to learn Python programming?"))