A web app and Python pipeline for evaluating model card content against AI policy documents (GDPR, EU AI Act, CCPA, AIDA, Colorado), then generating:
- policy-level compliance scores and explanations
- section summaries and top-level summary
- interactive heatmap outputs
app.py- Quart web server and upload endpointai_pipeline.py- core async evaluation pipelinepolicies/- policy text files used for evaluationrelevancy_maps/- section-to-article mappings per policytemplates/- frontend HTML templatesutils/- summary + visualization helpersuploads/,reports/,static/,cost_reports/- generated runtime artifacts
- Python 3.10+ (3.11 or 3.12 recommended)
- An Anthropic API key
git clone <your-repo-url>
cd policy_annotator_website
python3 -m venv .venv
source .venv/bin/activateThis project imports more packages than currently listed in requirements.txt, so install both:
pip install -r requirements.txt
pip install quart aiofiles python-dotenv langchain-anthropic seaborn matplotlib numpyIf you want to make this reproducible for everyone, update requirements.txt with the same packages.
Create a .env file in the project root:
ANTHROPIC_API_KEY=your_anthropic_api_key_hereNotes:
.envis gitignored and should not be committed.- If the key is missing/invalid, evaluations will fail when LLM calls are made.
python3 app.pyThen open:
- Open the homepage.
- Upload a model card CSV file.
- Optionally select which policies to run.
- Submit and wait for evaluation to complete.
- Review returned heatmaps and summaries.
Your uploaded CSV should include columns:
SectionYour Response
Rows with missing values are skipped during model card markdown conversion.
At runtime, the app creates/updates:
uploads/- uploaded CSV files (UUID-prefixed)reports/- generated report text filesstatic/- generated heatmap HTML filescost_reports/- token/cost markdown reports
This repo also includes a dedicated policy parsing workflow in policy_parser/, especially for converting policy text into structured clause tables using Claude.
See the detailed guide:
You can call run_ai_pipeline(...) from Python:
import asyncio
from ai_pipeline import run_ai_pipeline
async def main():
heatmap_files, summaries, top_level_summary, section_summaries = await run_ai_pipeline(
model_card_path="uploads/example.csv",
policy_folder="policies",
output_path="reports/example_report.txt",
selected_policies=["GDPR", "EU"] # optional
)
print(heatmap_files)
asyncio.run(main())Useful scripts in this repo include:
parse_relevancy_rating.pyprocess_relevancy_ratings.pyfilter_excel_by_max_score.pygenerate_irrelevancy_map.py
Run any script directly, for example:
python3 process_relevancy_ratings.pyModuleNotFoundErrorfor Quart / langchain / aiofiles- Install missing packages in the active virtual environment.
ANTHROPIC_API_KEYmissing- Set it in
.envand restart the app.
- Set it in
- Upload rejected
- Only
.csvuploads are accepted byapp.py.
- Only
- No policies selected / bad names
selected_policiesmust match policy filenames without.txt(for exampleGDPR,EU,CCPA).
- Main app entrypoint:
app.py - Server port:
8000 - Policy files are loaded from
policies/ - Relevancy mappings are loaded from
relevancy_maps/*_relevancy_map.py
- Never commit real API keys.
- Rotate keys if they are ever exposed in commit history.