nyu-mll/glue
Viewer • Updated • 1.49M • 419k • 520
How to use peeyush01/albert-paraphrase-detector with Transformers:
# Load model directly
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("peeyush01/albert-paraphrase-detector")
model = AutoModelForSequenceClassification.from_pretrained("peeyush01/albert-paraphrase-detector", device_map="auto")This is a fine-tuned version of albert-base-v2 on paraphrase detection tasks such as GLUE-QQP (Quora Question Pairs) and MRPC (Microsoft Research Paraphrase Corpus).
It can be used to determine whether two sentences are paraphrases (semantically similar) or not.
Example usage:
model = AutoModelForSequenceClassification.from_pretrained('peeyush01/albert-paraphrase-detector')
tokenizer = AutoTokenizer.from_pretrained('peeyush01/albert-paraphrase-detector-tokenizer')
def predict_paraphrase(sentence1, sentence2):
inputs = tokenizer(sentence1, sentence2, return_tensors="pt", padding=True, truncation=True)
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
probs = torch.softmax(logits, dim=1)
paraphrase_prob = probs[0][1].item()
return {"Paraphrase": paraphrase_prob, "Not Paraphrase": 1 - paraphrase_prob}
import torch
pairs = [
("The movie was fantastic!", "The film was amazing!"),
("He is playing cricket.", "She is reading a book."),
]
for s1, s2 in pairs:
result = predict_paraphrase(s1, s2)
print(f"Sentence 1: {s1}")
print(f"Sentence 2: {s2}")
print(f"Result: {result}\n")
1 → Paraphrase (semantically equivalent) 0 → Not paraphrasemax_length). sentence1, sentence2, and idx were dropped. label → labels. albert-base-v2 Trainer) Trainer. (Expected range for ALBERT-base on MRPC — please replace with your actual run metrics if available)
The fine-tuned ALBERT model achieves strong performance on the MRPC benchmark, demonstrating effectiveness at capturing semantic similarity and paraphrase relationships between sentence pairs.
Base model
albert/albert-base-v2