Spaces:
Runtime error
Runtime error
File size: 567 Bytes
cf63839 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
import torch
from selfcheckgpt.modeling_selfcheck import SelfCheckNLI
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
selfcheck_nli = SelfCheckNLI(device=device) # set device to 'cuda' if GPU is available
def nli_confidence(proofs, sentences):
sent_scores_nli = selfcheck_nli.predict(
sentences = sentences, # list of sentences
sampled_passages = proofs, # list of sampled passages
)
#print(sent_scores_nli)
sent_scores_nli = [1-s for s in sent_scores_nli]
return sent_scores_nli |