# Factual Consistency

This scanner checks if the provided content disagrees with a specific statement or question, this test ensures language model results are accurate and logical.

**Parameters**:

`data:`

* `prompt` (str): Prompt given to the model
* `response` (str): Reponse given by the model, which will be checked for factual consistency

`arguments:`

* `threshold` (float, optional): Threshold to determine if the response is factually correct. Default is 0.5.
* `use_onnx` (bool, optional): Whether to use onnx model to check for factual consistency.

**Interpretation**:

Higher score represents more logical and factually correct model response. The test passes if the model response is correct.

#### Code Example:

```python
prompt = "Angela Merkel is a politician in Germany and leader of the CDU."
response = "This text is about economics"

evaluator.add_test(
    test_names=["factual_consistency_guardrail"],
    data={'prompt':prompt,
          'response': response,
    },
    arguments={'model': 'gpt-4', 'threshold': 1.0},
).run()

evaluator.print_results()

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.raga.ai/ragaai-catalyst/ragaai-metric-library/additional-metrics/guardrails/factual-consistency.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
