Evaluate your model responses for Hallucination, Bias, and Toxicity
OpenAI
Anthropic
`openlit.evals.Hallucination()` Class Parameters
Hallucination
class:Name | Description | Default Value | Example Value |
---|---|---|---|
provider | The name of the LLM provider, either "openai" or "anthropic" . | "openai" | "openai" |
api_key | API key for LLM authentication, set via OPENAI_API_KEY or ANTHROPIC_API_KEY environment variables. | None | os.getenv("OPENAI_API_KEY") |
model | Specific model to use with the LLM provider (optional). | None | "gpt-4o" |
base_url | Base URL for the LLM API (optional). | None | "https://api.openai.com/v1" |
custom_categories | Additional categories for detection (optional). | None | {"custom_category": "Custom description"} |
threshold_score | Score above which a verdict is “yes” (indicating hallucination). | 0.5 | 0.7 |
collect_metrics | Enable metrics collection. | False | True |
`measure` Method Parameters
measure
method to analyze a specific text:Name | Description | Example Value |
---|---|---|
prompt | The prompt provided by the user. | "Discuss Einstein's achievements" |
contexts | A list of context sentences relevant to the task. | ["Einstein discovered the photoelectric effect."] |
text | The text to analyze for hallucination. | "Einstein won the Nobel Prize in 1969 for the theory of relativity." |
Categories
Category | Definition |
---|---|
factual_inaccuracy | Incorrect facts, e.g., Context: [“Paris is the capital of France.”]; Text: “Lyon is the capital.” |
nonsensical_response | Irrelevant info, e.g., Context: [“Discussing music trends.”]; Text: “Golf uses clubs on grass.” |
gibberish | Nonsensical text, e.g., Context: [“Discuss advanced algorithms.”]; Text: “asdas asdhasudqoiwjopakcea.” |
contradiction | Conflicting info, e.g., Context: [“Einstein was born in 1879.”]; Text: “Einstein was born in 1875 and 1879.” |
Explanation
Output
OpenAI
Anthropic
`openlit.evals.BiasDetector()` Class Parameters
BiasDetector
class:Name | Description | Default Value | Example Value |
---|---|---|---|
provider | The name of the LLM provider, either "openai" or "anthropic" . | "openai" | "openai" |
api_key | API key for LLM authentication, set via OPENAI_API_KEY or ANTHROPIC_API_KEY environment variables. | None | os.getenv("OPENAI_API_KEY") |
model | Specific model to use with the LLM provider (optional). | None | "gpt-4o" |
base_url | Base URL for the LLM API (optional). | None | "https://api.openai.com/v1" |
custom_categories | Additional categories for detection (optional). | None | {"custom_category": "Custom description"} |
threshold_score | Score above which a verdict is “yes” (indicating bias). | 0.5 | 0.6 |
collect_metrics | Enable metrics collection. | False | True |
`measure` Method Parameters
measure
method to analyze a specific text:Name | Description | Example Value |
---|---|---|
prompt | The prompt provided by the user. | "Discuss workplace equality." |
contexts | A list of context sentences relevant to the task. | ["Everyone should have equal opportunity regardless of background."] |
text | The text to analyze for bias. | "Older employees tend to struggle with new technology." |
Categories
Category | Definition |
---|---|
sexual_orientation | Biases or assumptions about an individual’s sexual preferences. |
age | Biases related to the age of an individual. |
disability | Biases or stereotypes concerning individuals with disabilities. |
physical_appearance | Biases based on the physical look of an individual. |
religion | Biases or prejudices connected to a person’s religious beliefs. |
pregnancy_status | Biases towards individuals who are pregnant or have children. |
marital_status | Biases related to whether someone is single, married, divorced, etc. |
nationality / location | Biases associated with an individual’s country or place of origin. |
gender | Biases related to an individual’s gender. |
ethnicity | Assumptions or stereotypes based on racial or ethnic background. |
socioeconomic_status | Biases regarding an individual’s economic and social position. |
Explanation
Output
OpenAI
Anthropic
`openlit.evals.ToxicityDetector()` Class Parameters
ToxicityDetector
class:Name | Description | Default Value | Example Value |
---|---|---|---|
provider | The name of the LLM provider, either "openai" or "anthropic" . | "openai" | "openai" |
api_key | API key for LLM authentication, set via OPENAI_API_KEY or ANTHROPIC_API_KEY environment variables. | None | os.getenv("OPENAI_API_KEY") |
model | Specific model to use with the LLM provider (optional). | None | "gpt-4o" |
base_url | Base URL for the LLM API (optional). | None | "https://api.openai.com/v1" |
custom_categories | Additional categories for detection (optional). | None | {"custom_category": "Custom description"} |
threshold_score | Score above which a verdict is “yes” (indicating toxicity). | 0.5 | 0.6 |
collect_metrics | Enable metrics collection. | False | True |
`measure` Method Parameters
measure
method to analyze a specific text:Name | Description | Example Value |
---|---|---|
prompt | The prompt provided by the user. | "Engage in a respectful discussion about global events." |
contexts | A list of context sentences relevant to the task. | ["Conversations should remain civil and informative."] |
text | The text to analyze for toxicity. | "Your opinion is absurd, and only an idiot would think that." |
Categories
Category | Definition |
---|---|
threat | Language that threatens harm or danger to others, e.g., “You’ll regret saying things like that.” |
dismissive | Dismissive or belittling language, e.g., “Your opinion is worthless.” |
hate | Hateful or intensely negative language, e.g., “Only an idiot would think this.” |
mockery | Mocking or sarcastic tone, e.g., “Brilliant observation! Did it take you all day to come up with that?” |
personal_attack | Language attacking a person’s character or abilities, e.g., “You’re clueless.” |
Explanation
Output
OpenAI
Anthropic
`openlit.evals.All()` Class Parameters
All
class:Name | Description | Default Value | Example Value |
---|---|---|---|
provider | The name of the LLM provider, either "openai" or "anthropic" . | "openai" | "openai" |
api_key | API key for LLM authentication, set via OPENAI_API_KEY or ANTHROPIC_API_KEY environment variables. | None | os.getenv("OPENAI_API_KEY") |
model | Specific model to use with the LLM provider (optional). | None | "gpt-4o" |
base_url | Base URL for the LLM API (optional). | None | "https://api.openai.com/v1" |
custom_categories | Additional categories for detection (optional). | None | {"custom_category": "Custom description"} |
threshold_score | Score above which a verdict is “yes” (indicating an issue). | 0.5 | 0.6 |
collect_metrics | Enable metrics collection. | False | True |
`measure` Method Parameters
measure
method to analyze a specific text:Name | Description | Example Value |
---|---|---|
prompt | The prompt provided by the user. | "Discuss the achievements of scientists." |
contexts | A list of context sentences relevant to the task. | ["Einstein discovered the photoelectric effect."] |
text | The text to analyze for bias, toxicity, or hallucination. | "Einstein won the Nobel Prize in 1969 for discovering black holes." |
Bias Categories
Category | Definition |
---|---|
sexual_orientation | Involves biases or assumptions about an individual’s sexual preferences. |
age | Biases related to the age of an individual. |
disability | Biases or stereotypes concerning individuals with disabilities. |
physical_appearance | Biases based on the physical look of an individual. |
religion | Biases or prejudices connected to a person’s religious beliefs. |
pregnancy_status | Biases towards individuals who are pregnant or have children. |
marital_status | Biases related to whether someone is single, married, divorced, etc. |
nationality / location | Biases associated with an individual’s country or place of origin. |
gender | Biases related to an individual’s gender. |
ethnicity | Assumptions or stereotypes based on racial or ethnic background. |
socioeconomic_status | Biases regarding an individual’s economic and social position. |
Toxicity Categories
Category | Definition |
---|---|
threat | Language that threatens harm or danger to others. |
dismissive | Dismissive or belittling language. |
hate | Hateful or intensely negative language. |
mockery | Mocking or sarcastic tone. |
personal_attack | Language attacking a person’s character or abilities. |
Hallucination Categories
Category | Definition |
---|---|
factual_inaccuracy | Incorrect facts. |
nonsensical_response | Irrelevant info. |
gibberish | Nonsensical text. |
contradiction | Conflicting info. |
Explanation
Output