Skip to main content

An agentic fairness and AI-risk analysis platform for detecting bias in text and images

Project description

FairSense-AgentiX

An agentic fairness and AI-risk analysis platform developed by the Vector Institute.

code checks integration tests docs codecov GitHub License


FairSense-AgentiX is an intelligent bias detection and risk assessment platform that uses agentic AI workflows to analyze text, images, and datasets for fairness concerns. Unlike traditional ML classifiers, FairSense employs a reasoning agent that plans, selects tools, critiques outputs, and refines them iteratively.

✨ Key Features

  • 🤖 Agentic Reasoning - ReAct loop with dynamic tool selection and self-critique
  • 🔍 Multi-Modal Analysis - Text bias detection, image bias detection, and AI risk assessment
  • 🛠️ Flexible Tool Ecosystem - OCR, Vision-Language Models, embeddings, FAISS, and LLMs
  • 🌐 Production-Ready APIs - FastAPI REST API + WebSocket streaming + React UI
  • ⚙️ Highly Configurable - Swap LLM providers, tools, and models on the fly

📦 Installation

From PyPI (Recommended)

pip install fairsense-agentix

Optional: PaddleOCR backend

The default OCR backend is Tesseract (CPU-friendly, no extra setup). For GPU-accelerated PaddleOCR (higher accuracy on rotated/complex text), install the paddle extra:

pip install fairsense-agentix[paddle]

This pulls in paddlepaddle, which has platform-specific wheels and is much heavier — only install if you need it. Once installed, set FAIRSENSE_OCR_TOOL=paddleocr (or auto to let the runtime pick based on GPU availability).

From Source

git clone https://github.com/VectorInstitute/fairsense-agentix.git
cd fairsense-agentix
uv sync
source .venv/bin/activate

Requirements

  • Python 3.12+
  • 4GB+ RAM (for ML models)
  • API key for OpenAI or Anthropic (for LLM functionality)

🚀 Quick Start

from fairsense_agentix import FairSense

# Initialize the engine
engine = FairSense()

# Analyze text for bias
result = engine.analyze_text(
    "We're looking for a young, energetic developer to join our startup team."
)

print(f"Bias detected: {result.bias_detected}")
print(f"Risk level: {result.risk_level}")
for instance in result.bias_instances:
    print(f"  - {instance['type']} ({instance['severity']}): {instance['text_span']}")

Full Documentation: https://vectorinstitute.github.io/fairsense-agentix/


🧑🏿‍💻 Developing

Installing dependencies

The development environment can be set up using uv. Hence, make sure it is installed and then run:

uv sync
source .venv/bin/activate

In order to install dependencies for testing (codestyle, unit tests, integration tests), run:

uv sync --dev
source .venv/bin/activate

In order to exclude installation of packages from a specific group (e.g. docs), run:

uv sync --no-group docs

Getting Started

Run the FastAPI service

uv run uvicorn fairsense_agentix.service_api.server:app --reload

Endpoints (all under /v1/...):

Route Description
POST /analyze JSON payload with content, optional input_type, options
POST /analyze/upload multipart/form-data for images
POST /batch & GET /batch/{id} Submit + inspect batch jobs
GET /health Health probe
WS /stream/{run_id} Stream telemetry/agent events for a run

The API auto-detects text/image/CSV inputs, but you can override by setting input_type to bias_text, bias_image, or risk.

Run the Claude-inspired UI

cd ui
npm install
npm run dev

Set VITE_API_BASE (defaults to http://localhost:8000) to point at the API. The UI provides:

  • Unified input surface (text field + drag/drop image upload)
  • Live agent timeline sourced from telemetry events
  • Downloadable HTML highlights and risk tables
  • Launchpad for batch jobs

Key configuration knobs

Configure via environment variables (see .env for the full list). Most relevant:

Variable Description
FAIRSENSE_LLM_PROVIDER openai, anthropic, or fake
FAIRSENSE_LLM_MODEL_NAME e.g. gpt-4, claude-3-5-sonnet
FAIRSENSE_LLM_API_KEY Provider API key
FAIRSENSE_OCR_TOOL auto, tesseract, paddleocr, fake
FAIRSENSE_CAPTION_MODEL auto, blip2, blip, fake
FAIRSENSE_ENABLE_REFINEMENT enables evaluator-driven retries (default true)
FAIRSENSE_EVALUATOR_ENABLED toggles Phase 7 evaluators
FAIRSENSE_BIAS_EVALUATOR_MIN_SCORE passing score (0–100, default 75)

All settings can be overridden at runtime:

FAIRSENSE_LLM_PROVIDER=anthropic \
FAIRSENSE_LLM_MODEL_NAME=claude-3-5-sonnet-20241022 \
uv run uvicorn fairsense_agentix.service_api.server:app

Running tests

uv run pytest

During test collection we automatically override any .env values that point at real providers/devices so the suite always uses the lightweight fake toolchain. This guarantees deterministic, offline-friendly tests even if you have FAIRSENSE_LLM_PROVIDER=openai (or Anthropic) configured locally. To opt-in to exercising the real stack, export FAIRSENSE_TEST_USE_REAL=1 before running pytest.

Acknowledgments

Resources used in preparing this research were provided, in part, by the Province of Ontario, the Government of Canada through CIFAR, and companies sponsoring the Vector Institute.

This research was funded by the European Union's Horizon Europe research and innovation programme under the AIXPERT project (Grant Agreement No. 101214389).

Contributing

If you are interested in contributing to the library, please see CONTRIBUTING.md. This file contains many details around contributing to the code base, including development practices, code checks, tests, and more.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fairsense_agentix-0.2.0.tar.gz (5.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fairsense_agentix-0.2.0-py3-none-any.whl (5.1 MB view details)

Uploaded Python 3

File details

Details for the file fairsense_agentix-0.2.0.tar.gz.

File metadata

  • Download URL: fairsense_agentix-0.2.0.tar.gz
  • Upload date:
  • Size: 5.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for fairsense_agentix-0.2.0.tar.gz
Algorithm Hash digest
SHA256 3e9f74967440b36ad42d6b7491144025dd892ce6fe165e25c3d49d588e00e405
MD5 2e4816d9de5bda7b16759feb28a2229b
BLAKE2b-256 0456a2876cc07ce092a702c80b74e596c7eab066105ae5447ce20ef579bd3bce

See more details on using hashes here.

Provenance

The following attestation bundles were made for fairsense_agentix-0.2.0.tar.gz:

Publisher: publish.yml on VectorInstitute/fairsense-agentix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fairsense_agentix-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for fairsense_agentix-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 33c4110180e9bbdcf8cf9b15d7a262238358f2ad27b1783481d6aa3415d6bf52
MD5 b29dac8d287d971121a04f3cc5007977
BLAKE2b-256 5355eee0a29c29aff7c1abb1a5e5ec99c99fb5d346745d8c8e9d25c3fd1caffb

See more details on using hashes here.

Provenance

The following attestation bundles were made for fairsense_agentix-0.2.0-py3-none-any.whl:

Publisher: publish.yml on VectorInstitute/fairsense-agentix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page