> This page is for version v0.24.1.
> For other versions, use one of these documentation indexes:
> - Latest (default): https://docs.nvidia.com/nemo/guardrails/latest/llms.txt
> - v0.24.1: https://docs.nvidia.com/nemo/guardrails/v0.24.1/llms.txt
> - v0.24.0: https://docs.nvidia.com/nemo/guardrails/v0.24.0/llms.txt
> - v0.23.0: https://docs.nvidia.com/nemo/guardrails/v0.23.0/llms.txt
> - v0.22.0: https://docs.nvidia.com/nemo/guardrails/v0.22.0/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nemo/guardrails/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/nemo/guardrails/_mcp/server.

# nemoguardrails.library.hallucination.actions

## Module Contents

### Functions

| Name                                                                                                 | Description                                                                                               |
| ---------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
| [`_hallucination_outcome`](#nemoguardrails-library-hallucination-actions-_hallucination_outcome)     | -                                                                                                         |
| [`self_check_hallucination`](#nemoguardrails-library-hallucination-actions-self_check_hallucination) | Checks if the last bot response is a hallucination by checking multiple completions for self-consistency. |

### Data

[`HALLUCINATION_NUM_EXTRA_RESPONSES`](#nemoguardrails-library-hallucination-actions-HALLUCINATION_NUM_EXTRA_RESPONSES)

[`log`](#nemoguardrails-library-hallucination-actions-log)

### API

```python
nemoguardrails.library.hallucination.actions._hallucination_outcome(
    is_hallucination: bool
) -> nemoguardrails.actions.rail_outcome.RailOutcome
```

```python
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.

```python
nemoguardrails.library.hallucination.actions.HALLUCINATION_NUM_EXTRA_RESPONSES = 2
```

```python
nemoguardrails.library.hallucination.actions.log = logging.getLogger(__name__)
```