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.0

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.0
File Size Uploaded Provenance Actions
polaudit-1.0.0.tar.gz 93.8 kB With provenance Details for polaudit-1.0.0.tar.gz

Built distribution (wheel)

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

Total release size: 182.7 kB

Release files / polaudit-1.0.0.tar.gz

Download URL polaudit-1.0.0.tar.gz
Size 93.8 kB
Tags Source
SHA-256 checksum
How to use checksums
9382e79a3a569d416cb755eb963698ef8196aca23d78fd48af3742d4995bd1e9
BLAKE2b-256 checksum
How to use checksums
04b3d9db8a0f43739d4c4bd157f47b7431868d156245f6fcb127c6fc0227b513
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.0-py3-none-any.whl

Download URL polaudit-1.0.0-py3-none-any.whl
Size 89.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
27801c7de40192404c7f57d0f540df1b7b3d3379a5e974ed49e1a05710b49597
BLAKE2b-256 checksum
How to use checksums
e448b8d94d777ff22c5ed8ad8becef5be94b2c89f5f4b0692b6119e63706a3a4
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.0

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.0.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.0 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