nemoguardrails.evaluate.evaluate_hallucination
nemoguardrails.evaluate.evaluate_hallucination
Module Contents
Classes
Functions
API
Helper class for running the hallucination rails evaluation for a Guardrails app. It contains all the configuration parameters required to run the evaluation.
Sample extra responses with temperature=1.0 from the LLM for hallucination check.
Parameters:
The prompt to generate extra responses for.
Number of extra responses to generate.
Returns:
List[str]: The list of extra responses.
Run and print the hallucination rail evaluation.
Run the hallucination rail evaluation. For each prompt, generate 2 extra responses from the LLM and check consistency with the bot response. If inconsistency is detected, flag the prompt as hallucination.
Returns:
Tuple[List[HallucinationPrediction], int]: Tuple containing hallucination predictions and the number flagged.
Main function to run the hallucination rails evaluation.
Parameters:
The path to the config folder.
Dataset path.
Number of samples to evaluate.
Output directory for predictions.
Whether to write the predictions to a file.