You can use Quotient’s SDK to automatically detect hallucinations and other reliability issues in your AI outputs.

Initialize the Logger with Detections

from quotientai import QuotientAI

quotient = QuotientAI(api_key="your-quotient-api-key")

logger = quotient.logger.init(
    app_name="my-first-app",
    environment="dev",
    sample_rate=1.0,
    # this will automatically run hallucination detection on 100% of your model outputs in relation to the documents you provide
    hallucination_detection=True,
    hallucination_detection_sample_rate=1.0,
)

Send Logs with Detections Enabled

log_id = logger.log(
    user_query="What is the capital of France?",
    model_response="The path to greatness is through hard work and dedication.",
    documents=[
        "France is a country in Western Europe.",
        "Paris is the capital of France.",
    ],
)

Poll for Detections

Synchronously poll for detection results using the client:

detection = logger.poll_for_detection(log_id=log_id)

Parameters:

log_id
string
required

The log ID of the log you want to poll for detections.

timeout
int
default:"300"

The maximum time to wait for a response in seconds.

poll_interval
float
default:"2.0"

The interval between checks in seconds.

Returns:

detection
object
required

The detection results.

Detections Dashboard

Go to the Detections Dashboard to see your logs and any detected hallucinations.

Analyze and Improve

Use the Detections Dashboard to:

  • See all of your logs and detections
  • Filter by app, environment, and timestamps.