def get_self_check_nli(output, sampled_passages): # spacy sentence tokenization sentences = [sent.text.strip() for sent in nlp(output).sents] selfcheck_nli = SelfCheckNLI(device=mps_device) # set device to 'cuda' if GPU is available sent_scores_nli = selfcheck_nli.predict( sentences = sentences, # list of sentences sampled_passages = sampled_passages, # list of sampled passages ) df = pd.DataFrame({ 'Sentence Number': range(1, len(sent_scores_nli) + 1), 'Probability of Contradiction': sent_scores_nli }) return df