Skip to main content

polaudit

An audit framework for LLM alignment with human subgroups, based on polarization. Whose perspective does an LLM's label reflect? When people disagree about a text, a language model's single label sides with someone. polaudit finds the texts where annotators are polarized, finds which annotator characteristic (gender, politics, age, ...) explains the split, and measures which side each model takes.

A model must choose a side on a polarized text

The audit in four steps

  1. Detect polarization. Each text gets a DFU score (distance from unimodality). A text with DFU above 0 is polarized.
  2. Attribute it. A polarized text is attributed to a characteristic when every group of that characteristic is internally unimodal (a-posteriori unimodality, AU). Groups in fewer than 10 attributed texts are removed.
  3. Ask the models. Your prompt, your models, optionally with a persona.
  4. Measure alignment. Cohen's kappa between the model's labels and each group's position, with bootstrap intervals and a chance check.

The audit framework

Install

pip install polaudit                                  # the AU analysis
pip install "polaudit[plots,openai,gemini]"           # figures and the model providers you use

Try it in a minute (no data, no keys)

from polaudit import run_dataset
from polaudit.toy import toy_spec, toy_ratings

result = run_dataset(toy_spec(), raw=toy_ratings())
print(result.describe())
result.per_dimension        # attributed texts per characteristic

Your own data, prompt and model

from polaudit import DatasetSpec, ModelHub, annotate, load_model_inputs, run_dataset, save_au_tables

spec = DatasetSpec(
    name="mydata",
    load=lambda root: my_dataframe,        # columns: item_id, text, rating, plus one column per characteristic
    dimensions={"gender": ("gender", {"m": "man", "f": "woman"}),
                "politics": ("politics", {"l": "left", "r": "right"})},
)
result = run_dataset(spec, raw=my_dataframe, min_au_texts=10)     # min_au_texts=0 keeps all AU texts
save_au_tables({"mydata": result.au}, "results")

def my_prompt(texts, item):
    return f"Rate how toxic each {item} is from 1 to 5.\nFormat: score=<n>, label=<toxic/civil>\n\n{texts}"

annotate(ModelHub.from_env()["chatgpt"], load_model_inputs("results/aposteriori_for_models.csv"), "results", prompt=my_prompt, run="baseline")

Full documentation

This page is the short version. The full documentation lives on GitHub, with nine tutorials (a short document and a runnable notebook each), every parameter, and the code that reproduces the paper:

The paper

This package is the code of Polarization Auditing Framework for LLMs: a Toxicity Detection Study (authors anonymous for review) and follows the current version of the paper.

Metadata

Release files for polaudit 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for polaudit 1.0.1
File Size Uploaded Provenance Actions
polaudit-1.0.1.tar.gz 93.8 kB With provenance Details for polaudit-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for polaudit 1.0.1
File Interpreter ABI Platform Actions
polaudit-1.0.1-py3-none-any.whl Python 3 none any Details for polaudit-1.0.1-py3-none-any.whl

Total release size: 182.8 kB

Release files / polaudit-1.0.1.tar.gz

Download URL polaudit-1.0.1.tar.gz
Size 93.8 kB
Tags Source
SHA-256 checksum
How to use checksums
6ff29dbfd23b450f4da9ece3b069cdedd07a779499d82d51d32856aa6d7e0280
BLAKE2b-256 checksum
How to use checksums
43c1382b3c27dde04a159b971d8fb59de362379242fb210d17eb3c7edaed1b1f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

Release files / polaudit-1.0.1-py3-none-any.whl

Download URL polaudit-1.0.1-py3-none-any.whl
Size 89.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d3c424569dd654e80a99d8556468a5e571e9d43dfb1994d65d92a4a80d4a75a6
BLAKE2b-256 checksum
How to use checksums
286c08c822268018336adb88c9848488bc21a3021242fbb2de42ccbb2b759aa1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

Security for polaudit 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for polaudit-1.0.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page