langfair  by cvs-health

LLM bias and fairness assessment SDK

Created 1 year ago
251 stars

Top 99.9% on SourcePulse

GitHubView on GitHub
1 Expert Loves This Project
Project Summary

<2-3 sentences summarising what the project addresses and solves, the target audience, and the benefit.> LangFair is a Python library designed for use-case-level bias and fairness assessments of Large Language Models (LLMs). It addresses the limitations of static benchmarks by enabling users to conduct evaluations tailored to their specific LLM applications through a "Bring Your Own Prompts" (BYOP) approach. This ensures that fairness metrics accurately reflect real-world performance and risks, focusing on practical, output-based measures suitable for governance audits. The library is targeted at engineers, researchers, and power users needing to rigorously evaluate LLM behavior.

How It Works

LangFair's core methodology centers on a "Bring Your Own Prompts" (BYOP) strategy, empowering users to define evaluation datasets specific to their LLM use cases. The framework prioritizes output-based metrics, which are practical for governance audits and real-world testing without requiring access to internal model states. Key functionalities include generating LLM responses, computing toxicity, stereotype associations, and counterfactual fairness metrics. For streamlined assessments in text generation and summarization, the AutoEval class automates multiple evaluation steps.

Quick Start & Requirements

  • Installation: pip install langfair
  • Prerequisites: Requires a LangChain LLM object (e.g., ChatVertexAI). A virtual environment is recommended. GPU support is optional for accelerating toxicity computation (torch.device("cuda")).
  • Links: Documentation site, Medium tutorial, Software paper, Research paper.

Highlighted Details

  • Offers a comprehensive suite of bias and fairness metrics, categorized into Toxicity, Counterfactual Fairness, Stereotype, Recommendation, and Classification fairness.
  • Includes "red-teaming" capabilities for assessing worst-case toxicity and counterfactual generations via adversarial prompts.
  • The AutoEval class provides a semi-automated evaluation for text generation and summarization use cases, consolidating toxicity, stereotype, and counterfactual metrics.
  • Focuses on practical, output-based metrics suitable for governance audits and real-world testing.

Maintenance & Community

The project lists a development team comprising Dylan Bouchard, Mohit Singh Chauhan, David Skarbrevik, Viren Bajaj, and Zeya Ahmad. No external community channels (e.g., Discord, Slack) or roadmaps are explicitly linked in the provided text. Internal commit history is not made public.

Licensing & Compatibility

The README does not explicitly state the software's license. This omission prevents an immediate assessment of compatibility for commercial use or closed-source linking.

Limitations & Caveats

The AutoEval class is specifically highlighted for text generation and summarization use cases; users may need to manually apply individual metrics for other LLM applications. The absence of a stated license is a critical adoption blocker. Internal commit history is not public, potentially limiting transparency.

Health Check
Last Commit

2 weeks ago

Responsiveness

Inactive

Pull Requests (30d)
2
Issues (30d)
0
Star History
4 stars in the last 30 days

Explore Similar Projects

Starred by Shizhe Diao Shizhe Diao(Author of LMFlow; Research Scientist at NVIDIA), Pawel Garbacki Pawel Garbacki(Cofounder of Fireworks AI), and
3 more.

promptbench by microsoft

0.1%
3k
LLM evaluation framework
Created 2 years ago
Updated 5 days ago
Feedback? Help us improve.