Project-level guidance for AI-assisted development. This overrides generic defaults.
EquiLens is a black-box bias detection framework for SLMs and LLMs. It uses prompt engineering to probe models without access to their weights or internals — sending carefully constructed prompts and measuring differential responses across demographic groups (gender, race, occupation, etc.).
B.Tech final year project at Amrita Vishwa Vidyapeetham by VKrishna04.
Phase 1 — Corpus Generator (src/Phase1_CorpusGenerator/)
generate_corpus.py word_lists.json → CSV corpus
word_lists.json demographic names, traits, professions
test_config.py pre-flight config validator
Phase 2 — Model Auditor (src/Phase2_ModelAuditor/)
audit_model.py sends prompts to Ollama, records responses
enhanced_audit_model.py retry/resume, GPU acceleration, concurrency
run_both_auditors.py comparison runner
Phase 3 — Analytics (src/Phase3_Analysis/)
analytics.py statistical tests, HTML/Markdown reports, AI insights
analyze_results.py CLI entry for analysis
equilens package (src/equilens/)
cli.py Typer CLI — `equilens` command
backend_server.py uvicorn launcher (used by `equilens web`)
backup.py APScheduler-based periodic backup + retention
dashboard/
routes.py Jinja2 HTML page routes (6 pages)
templates/ base.html + 6 page templates (Alpine.js + Chart.js CDN)
static/ style.css (CSS design system) + app.js (Alpine utils)
backend/api.py FastAPI REST backend + dashboard router + SSE endpoint
backend/jobs.py Background job runners
backend/database.py SQLite job tracking
telemetry.py Stats counters (seed from data/telemetry.json)
core/
manager.py EquiLensManager — orchestrates all components
ollama_config.py Smart Ollama URL detection (local vs Docker)
ports.py Dynamic port management
docker.py Docker service management
gpu.py GPU/CUDA detection
infra/ Docker/infrastructure files (Dockerfile, docker-compose.yml, etc.)
| Command | What it does |
|---|---|
uv run equilens web |
Launches single FastAPI server with built-in dashboard at :8000 |
uv run equilens backend |
Launches FastAPI backend only (API-only, same server) |
uv run equilens audit --model llama3.2 |
CLI bias audit |
uv run equilens analyze <results.csv> |
CLI analysis |
uv run equilens status |
System health check |
docker compose -f infra/docker-compose.yml up |
Full Docker stack |
uv sync # install deps
uv run pytest # run tests
uv run ruff check src/ # lint
uv run ruff format src/ # format- Never break the three-phase pipeline independence — Phase 1 output (CSV) must work as Phase 2 input without modification.
- The dashboard is served by the same FastAPI process as the REST API. No separate server. No Gradio.
gradio_app.py,web_ui.py, andstart_all.pyhave been deleted — do not recreate them. - Ollama URL detection is environment-aware: local gets
localhost:11434, Docker getshost.docker.internal:11434. Don't hardcode URLs. - The
data/telemetry.jsonseed counters are intentional — they represent the "baseline" for the stats bar. Don't reset them to 0. - Backup paths in
backup.pyare anchored to_PROJECT_ROOT = Path(__file__).resolve().parent.parent.parent— not CWD. This is required for APScheduler which runs in a background thread with an unpredictable CWD. Do not change to relative paths. - Docker files live in
infra/only. Docker commands usedocker compose -f infra/docker-compose.yml.
- Gender — male vs female names in identical prompts
- Racial/Ethnic — Western vs non-Western names
- Occupational — profession-based stereotyping
- Sentiment — positive/negative trait association by group
- Counterfactual — response change when only demographic changes
- Associative — implicit bias via word association
src/Phase1_CorpusGenerator/word_lists.json— manually curated, changes need domain knowledgesrc/Phase1_CorpusGenerator/word_lists_schema.json— schema for word_lists.jsondata/jobs/equilens_jobs.db— live SQLite job databaseuv.lock— don't manually edit, letuv syncmanage it
Tests in tests/ are a mix of unit and integration. Most integration tests require Ollama running. Run unit tests only:
uv run pytest tests/unit/