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)
1from sentence_transformers import SentenceTransformer
23# Load the fine-tuned model4model = SentenceTransformer("fine-tuned-model")56# Encode two sentences and compute cosine similarity7sentence1 ="How can I learn Python?"8sentence2 ="What is the best way to study Python?"910emb1 = model.encode(sentence1)11emb2 = model.encode(sentence2)1213# Cosine similarity14import numpy as np
15score = np.dot(emb1, emb2)/(np.linalg.norm(emb1)* np.linalg.norm(emb2))16print("Similarity Score:", score)1718# Threshold to classify as paraphrase19print("Paraphrase"if score >0.75else"Not Paraphrase")