langfair logo

langfair

cvs-health/langfair

LangFair: Use-Case Level LLM Bias and Fairness Assessments

GraphCanon updated 1w · GitHub synced 1w

261 stars47 forksLast push 1mo Python Other

Decision brief

LangFair is a Python library designed for assessing bias and fairness in large language model (LLM) use cases using user-specific prompts.

Good fit when

  • - You need to conduct bias and fairness assessments specific to the application domain of your LLM.
  • - Your project requires evaluation through output-based metrics suitable for governance audits.

Avoid when

  • - If you require access to internal model states for your evaluations, as LangFair focuses on output-based metrics instead.
  • - You are looking for a static benchmark assessment that does not consider use-case-specific prompts, preferring generalized metrics over tailored evaluations.

Observed Jul 12, 2026 · Source: enrich:decision_facts

Verify the decision

Maintenance and security

Full trust report
Maintenance
Steady (39d since push)
As of 1w
Provenance
Not a fork · Organization account
As of 1w
Security (OSV)
No lockfile
As of 1mo

Public GitHub metadata and optional OSV scans. Signals, not a guarantee. Trust methodology.

Install

pip install langfair
PyPI

Similar tools

Same-category neighbours. No typed graph edges are catalogued for this tool yet.

Evidence and technical details

Sourced facts, taxonomy, compatibility claims, README excerpt, and machine-readable endpoints.

Overview

A comprehensive Python library designed to conduct bias and fairness assessments of large language model (LLM) use cases.

Capability facts

Languages
python

Source: github.language+pyproject.toml · Aug 8, 2026

Categories

Compatibility

Sourced claims from the README excerpt - not unsourced marketing copy.

LangChain integrationLangChain

Source: README excerpt (regex_v1, Aug 8, 2026)

nses, we can use LangFair's `ResponseGenerator` class. First, we must create a `langchain` LLM object. Below we use `ChatVertexAI`, but **any of [LangChain’s LLM classes
Source link
Python runtimePython

Source: README excerpt (regex_v1, Aug 8, 2026)

LangFair is a comprehensive Python library designed for conducting bias and fairness assessments of large language
Source link

Tags

README

Badge image

LangFair: Use-Case Level LLM Bias and Fairness Assessments

LangFair is a comprehensive Python library designed for conducting bias and fairness assessments of large language model (LLM) use cases. This repository includes various supporting resources, including

🚀 Why Choose LangFair?

Static benchmark assessments, which are typically assumed to be sufficiently representative, often fall short in capturing the risks associated with all possible use cases of LLMs. These models are increasingly used in various applications, including recommendation systems, classification, text generation, and summarization. However, evaluating these models without considering use-case-specific prompts can lead to misleading assessments of their performance, especially regarding bias and fairness risks.

LangFair addresses this gap by adopting a Bring Your Own Prompts (BYOP) approach, allowing users to tailor bias and fairness evaluations to their specific use cases. This ensures that the metrics computed reflect the true performance of the LLMs in real-world scenarios, where prompt-specific risks are critical. Additionally, LangFair's focus is on output-based metrics that are practical for governance audits and real-world testing, without needing access to internal model states.

Badge image

Note: This diagram illustrates the workflow for assessing bias and fairness in text generation and summarization use cases.

⚡ Quickstart Guide

(Optional) Create a virtual environment for using LangFair

We recommend creating a new virtual environment using venv before installing LangFair. To do so, please follow instructions here.

Installing LangFair

The latest version can be installed from PyPI:

pip install langfair

Usage Examples

Below are code samples illustrating how to use LangFair to assess bias and fairness risks in text generation and summarization use cases. The below examples assume the user has already defined a list of prompts from their use case, prompts.

Generate LLM responses

To generate responses, we can use LangFair's ResponseGenerator class. First, we must create a langchain LLM object. Below we use ChatVertexAI, but any of LangChain’s LLM classes may be used instead. Note that InMemoryRateLimiter is to used to avoid rate limit errors.

from langchain_google_vertexai import ChatVertexAI
from langchain_core.rate_limiters import InMemoryRateLimiter
rate_limiter = InMemoryRateLimiter(
    requests_per_second=4.5, check_every_n_seconds=0.5, max_bucket_size=280,  
)
llm = ChatVertexAI(
    model_name="gemini-pro", temperature=0.3, rate_limiter=rate_limiter
)

We can use ResponseGenerator.generate_responses to generate 25 responses for each prompt, as is convention for toxicity evaluation.

from langfair.generator import ResponseGenerator
rg = ResponseGenerator(langchain_llm=llm)
generat

For agents

This page has a .md twin and JSON over the API.

Was this helpful?

Anonymous feedback helps us improve pages and translations.