def get_bertscore(output, sampled_passages): # spacy sentence tokenization sentences = [sent.text.strip() for sent in nlp(output).sents] selfcheck_bertscore = SelfCheckBERTScore(rescale_with_baseline=True) sent_scores_bertscore = selfcheck_bertscore.predict( sentences = sentences, # list of sentences sampled_passages = sampled_passages, # list of sampled passages ) df = pd.DataFrame({ 'Sentence Number': range(1, len(sent_scores_bertscore) + 1), 'Hallucination Score': sent_scores_bertscore }) return df