ranavikas jayash391 commited on
Commit
7f17662
1 Parent(s): 1c85a17

Update nexus.py (#3)

Browse files

- Update nexus.py (ad8eb420d63a225c1e4502358f9f64f9d66ca14e)


Co-authored-by: Jayash Bhardwaj <jayash391@users.noreply.huggingface.co>

Files changed (1) hide show
  1. nexus.py +7 -1
nexus.py CHANGED
@@ -29,7 +29,13 @@ endpoint = 'https://api.together.xyz/inference'
29
  # Load the hallucination evaluation model
30
  model_name = "vectara/hallucination_evaluation_model"
31
  model = AutoModelForSequenceClassification.from_pretrained(model_name, trust_remote_code=True)
32
- tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
 
 
 
 
 
 
33
 
34
  def search_pubmed(query: str) -> Optional[List[str]]:
35
  """
 
29
  # Load the hallucination evaluation model
30
  model_name = "vectara/hallucination_evaluation_model"
31
  model = AutoModelForSequenceClassification.from_pretrained(model_name, trust_remote_code=True)
32
+ tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
33
+
34
+ def vectara_hallucination_evaluation_model(text):
35
+ inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=512)
36
+ outputs = model(**inputs)
37
+ hallucination_probability = outputs.logits[0][0].item()
38
+ return hallucination_probability
39
 
40
  def search_pubmed(query: str) -> Optional[List[str]]:
41
  """