nemoguardrails.library.hallucination.actions

View as Markdown

Module Contents

Functions

NameDescription
self_check_hallucinationChecks if the last bot response is a hallucination by checking multiple completions for self-consistency.

Data

HALLUCINATION_NUM_EXTRA_RESPONSES

log

API

nemoguardrails.library.hallucination.actions.self_check_hallucination(
llm: nemoguardrails.types.LLMModel,
llm_task_manager: nemoguardrails.llm.taskmanager.LLMTaskManager,
context: typing.Optional[dict] = None,
use_llm_checking: bool = True,
config: typing.Optional[nemoguardrails.RailsConfig] = None,
kwargs = {}
)
async

Checks if the last bot response is a hallucination by checking multiple completions for self-consistency.

:return: True if hallucination is detected, False otherwise.

nemoguardrails.library.hallucination.actions.HALLUCINATION_NUM_EXTRA_RESPONSES = 2
nemoguardrails.library.hallucination.actions.log = logging.getLogger(__name__)