Spaces:
Sleeping
Sleeping
Update nexus.py
Browse files
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(
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
"""
|