ihgn/paraphrase-detection
Initialize tokenizer and model
tokenizer = BartTokenizer.frompretrained('ihgn/paraphrase-detection') model = BartForConditionalGeneration.frompretrained("ihgn/paraphrase-detection").to(device) sourcesentence = "This was a series of nested angular standards , so that measurements in azimuth and elevation could be done directly in polar coordinates relative to the ecliptic." targetparaphrase = "This was a series of nested polar scales , so that measurements in azimuth and elevation could be performed directly in angular coordinates relative to the ecliptic"
def paraphrasedetection(model, tokenizer, sourcesentence, targetparaphrase): # Tokenize the input sentence inputs = tokenizer.encodeplus(sourcesentence + ' <sep> ' + targetparaphrase, return_tensors='pt')
# Classify the input using the model with torch.nograd(): outputs = model.generate(inputs['inputids'].to(device))
# Get the predicted label predictedlabel = 1 if generatedtext == '1' else 0 print("Predicted Label:", predicted_label)
paraphrasedetection(model, tokenizer, sourcesentence, target_paraphrase)
