Overview

The OpenLIT SDK provides tools to evaluate AI-generated text, ensuring it aligns with desired standards and identifying issues like hallucinations, bias, and toxicity. We offer four main evaluation modules:

Evaluations

Hallucination Detection

Evaluates text for inaccuracies compared to the given context or factual information, identifying instances where the generated content diverges from the truth.

Usage

Use LLM-based detection with providers like OpenAI or Anthropic:

import openlit

# Optionally, set your API key as an environment variable
import os
os.environ["OPENAI_API_KEY"] = "<YOUR_API_KEY>"

# Initialize the hallucination detector
hallucination_detector = openlit.evals.Hallucination(provider="openai")

# Measure hallucination in text
result = hallucination_detector.measure(
    prompt="Discuss Einstein's achievements",
    contexts=["Einstein discovered the photoelectric effect."],
    text="Einstein won the Nobel Prize in 1969 for the theory of relativity."
)

Supported Providers and LLMs

Parameters

Classification Categories

How it Works

JSON Output:

Bias Detection

Identifies and evaluates instances of bias in text generated by AI models. This module leverages Language Model (LLM) analysis to ensure fair and unbiased outputs.

Usage

Use LLM-based detection with providers like OpenAI or Anthropic:

import openlit

# Optionally, set your API key as an environment variable
import os
os.environ["OPENAI_API_KEY"] = "<YOUR_API_KEY>"

# Initialize the bias detector
bias_detector = openlit.evals.BiasDetector(provider="openai")

# Measure bias in text
result = bias_detector.measure(
    prompt="Discuss workplace equality.",
    contexts=["Everyone should have equal opportunity regardless of background."],
    text="Older employees tend to struggle with new technology."
)

Supported Providers and LLMs

Parameters

Classification Categories

How it Works

JSON Output:

Toxicity Detection

Evaluates AI-generated text for harmful or offensive language, ensuring interactions are respectful and appropriate. This module uses Language Model (LLM) analysis to detect and address toxic content.

Usage

Use LLM-based detection with providers like OpenAI or Anthropic:

import openlit

# Optionally, set your API key as an environment variable
import os
os.environ["OPENAI_API_KEY"] = "<YOUR_API_KEY>"

# Initialize the toxicity detector
toxicity_detector = openlit.evals.ToxicityDetector(provider="openai")

# Measure toxicity in text
result = toxicity_detector.measure(
    prompt="Engage in a respectful discussion about global events.",
    contexts=["Conversations should remain civil and informative."],
    text="Your opinion is absurd, and only an idiot would think that."
)

Supported Providers and LLMs

Parameters

Classification Categories

How it Works

JSON Output:

All Evaluations

Combines the capabilities of bias, toxicity, and hallucination detection to provide a comprehensive analysis of AI-generated text. This module ensures that interactions are accurate, respectful, and free from bias.

Usage

Use LLM-based detection with providers like OpenAI or Anthropic:

import openlit

# Optionally, set your API key as an environment variable
import os
os.environ["OPENAI_API_KEY"] = "<YOUR_API_KEY>"

# Initialize the all evaluations detector
all_evals_detector = openlit.evals.All(provider="openai")

# Measure issues in text
result = all_evals_detector.measure(
    prompt="Discuss the achievements of scientists.",
    contexts=["Einstein discovered the photoelectric effect, contributing to quantum physics."],
    text="Einstein won the Nobel Prize in 1969 for discovering black holes."
)

Supported Providers and LLMs

Parameters

Classification Categories

How it Works

JSON Output: