Sentence-BERT Quantized Model for Text Similarity & Paraphrase Detection
This repository hosts a quantized version of the Sentence-BERT (SBERT) model, fine-tuned on the Quora Question Pairs dataset for text similarity and paraphrase detection. The model computes semantic similarity between two input sentences and has been optimized for efficient deployment using ONNX quantization.
Model Details
Model Architecture:
Sentence-BERT (
all-MiniLM-L6-v2
)
from sentence_transformers import SentenceTransformer
# Load the fine-tuned model
model = SentenceTransformer("fine-tuned-model")
# Encode two sentences and compute cosine similarity
sentence1 = "How can I learn Python?"
sentence2 = "What is the best way to study Python?"
emb1 = model.encode(sentence1)
emb2 = model.encode(sentence2)
# Cosine similarityimport numpy as np
score = np.dot(emb1, emb2) / (np.linalg.norm(emb1) * np.linalg.norm(emb2))
print("Similarity Score:", score)
# Threshold to classify as paraphraseprint("Paraphrase"if score > 0.75else"Not Paraphrase")
Threshold for classification:
0.75 cosine similarity
Fine-Tuning Details
Dataset
Source:
Quora Question Pairs (Kaggle)
Size:
400K+ question pairs labeled as paraphrase or not
Training Configuration
Epochs:
3
Batch Size:
16
Evaluation Steps:
1000
Warmup Steps:
1000
Loss Function:
CosineSimilarityLoss
Quantization
Method:
ONNX dynamic quantization
Tool:
Hugging Face Optimum + ONNX Runtime
Repository Structure
.
├── fine-tuned-model/ # Fine-tuned SBERT model directory
├── sbert_onnx/ # Quantized ONNX model directory
├── test_functions.py # Code for evaluation and testing
├── README.md # Project documentation
Limitations
The cosine similarity threshold (0.75) may need tuning for different domains.
ONNX quantization may introduce slight performance degradation compared to full-precision models.
SBERT embeddings do not produce classification logits, only similarity scores.
Contributing
Contributions are welcome! Please open an issue or submit a pull request for bug fixes or improvements.
Runs of AventIQ-AI sBERT_Text_Similarity on huggingface.co
11
Total runs
0
24-hour runs
-1
3-day runs
4
7-day runs
7
30-day runs
More Information About sBERT_Text_Similarity huggingface.co Model
sBERT_Text_Similarity huggingface.co
sBERT_Text_Similarity huggingface.co is an AI model on huggingface.co that provides sBERT_Text_Similarity's model effect (), which can be used instantly with this AventIQ-AI sBERT_Text_Similarity model. huggingface.co supports a free trial of the sBERT_Text_Similarity model, and also provides paid use of the sBERT_Text_Similarity. Support call sBERT_Text_Similarity model through api, including Node.js, Python, http.
sBERT_Text_Similarity huggingface.co is an online trial and call api platform, which integrates sBERT_Text_Similarity's modeling effects, including api services, and provides a free online trial of sBERT_Text_Similarity, you can try sBERT_Text_Similarity online for free by clicking the link below.
AventIQ-AI sBERT_Text_Similarity online free url in huggingface.co:
sBERT_Text_Similarity is an open source model from GitHub that offers a free installation service, and any user can find sBERT_Text_Similarity on GitHub to install. At the same time, huggingface.co provides the effect of sBERT_Text_Similarity install, users can directly use sBERT_Text_Similarity installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
sBERT_Text_Similarity install url in huggingface.co: