nemoguardrails.library.hallucination.actions

View as Markdown

Module Contents

Functions

NameDescription
_hallucination_outcome-
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._hallucination_outcome(
is_hallucination: bool
) -> nemoguardrails.actions.rail_outcome.RailOutcome
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,
bot_message: typing.Optional[str] = None,
last_bot_prompt: typing.Optional[str] = None,
kwargs = {}
) -> nemoguardrails.actions.rail_outcome.RailOutcome
async

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

:return: A blocking outcome if hallucination is detected, otherwise an allowing outcome.

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