dplecko/fgai

0

stars

31

commits

Python

primary language

Aug 26, 2026

updated

README

Causal Bias Detection for Generative AI

This works studies the foundations of causal bias detection for generative artificial intelligence (AI) models.


Part I: LLM Data Generation (py/)

The python pipeline elicits the observational distributions of language models by prompting them to write stories based on with different conditioning sets (∅ → {X, Z} → {X, Z, W}, where X, Z, W correspond to variable sets in the standard fairness model).

File Organization

FilePurpose
py/elicit.pyMain entry point: samples rows from real data, runs LLM generation and annotation steps for the required variables
py/generation.pyBuilds supporting functionality for py/elicit.py
py/data_helpers.pyHelpers for data loading
py/model_load.pyModeling loading and specification

Part 2: Causal Estimation (r/)

The R side loads the (partially) generated datasets for each (dataset, model) pair and estimates the causal fairness measures using one-step debiasing.

File Organization

The key scripts are the following:

FilePurpose
scripts/bias-stereo.RSummarizes the overall model behavior across datasets and stages
scripts/bias-similarity.RComputes bias signature similarity between models
scripts/bias-families.RAnalyzes if models from the same family have similar bias signatures
scripts/case-studies-select.RSelects interesting case-studies
scripts/case-studies-wfall.RGenerates waterfall plots for the selected case studies
scripts/annotator-agreement.RCross-annotator agreement (Llama 3 70B vs Command A 111B)
scripts/annotator-vs-human.RCompares annotator output against human-labeled ground truth
scripts/annotator-sensitivity.RSensitivity of estimates to annotator choice
scripts/annotator-na-analysis.RAnalyzes "Answer not available" rates across annotation attempts
scripts/sens-prompt.RSensitivity to prompt format (narrative vs. bulleted list)
scripts/sens-tempp.RSensitivity to decoding parameters (temperature / top-p)

Furthermore, the r/ infrastructure is organized as:

FilePurpose
r/helpers.RShared core: load_model_dataestimate_withinextract_stage_effects
r/one-step-debias.RCore causal fairness estimation (one-step debiasing)
r/helpers-stereo.RScoring/classification helpers (amplify / dampen / reverse / no bias)
r/helpers-similarity.R9D bias-vector extraction for similarity comparisons
r/helpers-wfall.RWaterfall (TV decomposition) plotting helpers
r/zzz-deps.RPackage dependencies

Contributors

dplecko

31 commits

dplecko/fgai

0

stars

31

commits

Python

primary language

Aug 26, 2026

updated

README

Causal Bias Detection for Generative AI

This works studies the foundations of causal bias detection for generative artificial intelligence (AI) models.


Part I: LLM Data Generation (py/)

The python pipeline elicits the observational distributions of language models by prompting them to write stories based on with different conditioning sets (∅ → {X, Z} → {X, Z, W}, where X, Z, W correspond to variable sets in the standard fairness model).

File Organization

FilePurpose
py/elicit.pyMain entry point: samples rows from real data, runs LLM generation and annotation steps for the required variables
py/generation.pyBuilds supporting functionality for py/elicit.py
py/data_helpers.pyHelpers for data loading
py/model_load.pyModeling loading and specification

Part 2: Causal Estimation (r/)

The R side loads the (partially) generated datasets for each (dataset, model) pair and estimates the causal fairness measures using one-step debiasing.

File Organization

The key scripts are the following:

FilePurpose
scripts/bias-stereo.RSummarizes the overall model behavior across datasets and stages
scripts/bias-similarity.RComputes bias signature similarity between models
scripts/bias-families.RAnalyzes if models from the same family have similar bias signatures
scripts/case-studies-select.RSelects interesting case-studies
scripts/case-studies-wfall.RGenerates waterfall plots for the selected case studies
scripts/annotator-agreement.RCross-annotator agreement (Llama 3 70B vs Command A 111B)
scripts/annotator-vs-human.RCompares annotator output against human-labeled ground truth
scripts/annotator-sensitivity.RSensitivity of estimates to annotator choice
scripts/annotator-na-analysis.RAnalyzes "Answer not available" rates across annotation attempts
scripts/sens-prompt.RSensitivity to prompt format (narrative vs. bulleted list)
scripts/sens-tempp.RSensitivity to decoding parameters (temperature / top-p)

Furthermore, the r/ infrastructure is organized as:

FilePurpose
r/helpers.RShared core: load_model_dataestimate_withinextract_stage_effects
r/one-step-debias.RCore causal fairness estimation (one-step debiasing)
r/helpers-stereo.RScoring/classification helpers (amplify / dampen / reverse / no bias)
r/helpers-similarity.R9D bias-vector extraction for similarity comparisons
r/helpers-wfall.RWaterfall (TV decomposition) plotting helpers
r/zzz-deps.RPackage dependencies

Contributors

dplecko

31 commits

Languages

Python

66.1%

R

29.5%

Shell

4.4%