Skip to content

High-performance, edge-native compliance engine for the Fair Housing Act (FHA). Powered by ModernBERT, providing privacy-first local inference to detect real estate violations in real-time.

License

Notifications You must be signed in to change notification settings

ZheWang-stack/FairProp-Inspector

FairProp Inspector

License: MIT CI Model: ModernBERT Python 3.9+ Code style: black PRs Welcome

The Compliance Layer for Real Estate AI Agent.

FairProp Inspector is a high-performance, latency-critical inference engine designed to detect Fair Housing Act (FHA) violations in real-time. Unlike legacy regex-based solutions, FairProp leverages Small Language Models (SLMs) fine-tuned on compliance datasets to understand context, nuance, and intent.

Built for the On-Device AI era, it runs efficiently on edge hardware while maintaining privacy-first architecture.

graph TD
    A[FHA Rules & Heuristics] --> B[Synthetic Generator <i>(GPT-4o Distillation)</i>]
    B --> C[(Synthetic Dataset)]
    C --> D[ModernBERT Fine-tuning <i>(BF16 / FlashAttention)</i>]
    D --> E{Model Serialization}
    E --> F[PyTorch Checkpoint]
    E --> G[ONNX Export <i>(Quantized)</i>]
    G --> H[Edge Inference <i>(Browser/Embedded)</i>]
    F --> I[Compliance API/Platform]
Loading

Part of the FairProp AI Platform ecosystem.

πŸš€ Key Features

  • SOTA Architecture: Powered by ModernBERT, delivering 8192 context length and Flash Attention backend.
  • Edge-Native: Optimized for ONNX Runtime export, enabling sub-20ms latency on CPU.
  • Data Engine: Includes a synthetic data generation pipeline (scripts/generate_synthetic.py) utilizing LLM distillation (GPT-4o) to bootstrap compliance supervision.
  • Privacy-First: No data leaves your infrastructure. Full compliance checks happen locally.

πŸ› οΈ Installation

From Source (Recommended)

git clone https://github.com/ZheWang-stack/FairProp-Inspector.git
cd FairProp-Inspector
pip install -e .

Direct from GitHub

pip install git+https://github.com/ZheWang-stack/FairProp-Inspector.git

Note

PyPI package coming soon! For now, please install from source.

πŸ“Š Performance Comparison

FairProp Inspector bridges the gap between simple regex rules and expensive cloud APIs:

Method Latency Accuracy Privacy Cost
Regex Rules <1ms ~65% βœ… Local Free
Cloud API (GPT-4) 800ms ~95% ❌ Cloud $$$$
FairProp Inspector ~18ms ~94% βœ… Local Free

Benchmarks run on Intel i7-12700K CPU with ONNX Runtime optimization.

⚑ Quick Start

Get started in 30 seconds:

from src.inference.predict import predict

# Detect FHA violations instantly
text = "No kids under 12 allowed"
label, confidence = predict(text, "artifacts/model")

print(f"{label}: {confidence:.1%}")
# Output: NON_COMPLIANT: 99.8%

Try it now:

python examples/quickstart.py

πŸ“š Examples

Explore our ready-to-run examples:

See examples/README.md for detailed usage instructions.

πŸ—οΈ Architecture

The Inspector Pipeline

Our pipeline moves away from "black box" APIs to measurable, controllable local inference.

  1. Synthetic Distillation: We use gpt-4o to generate "Edge Case" violations (e.g., subtle steering like "Perfect for active adults").
  2. Training: We fine-tune ModernBERT-base using bf16 precision and gradient checkpointing.
  3. Inference: The model classifies text segments as COMPLIANT vs NON_COMPLIANT with probability calibration.

πŸ’» Usage

1. Training (Fine-tuning)

Train the inspector on your proprietary or synthetic data.

# Uses Flash Attention & BF16 automatically if specific hardware is detected
python src/trainer/train.py --data data/processed/synthetic.json --epochs 5 --batch_size 16

2. Synthetic Data Generation

Bootstrap your dataset using our chain-of-thought distillation script.

export OPENAI_API_KEY="sk-..."
python src/generator/generate_data.py --count 1000 --output data/processed/synthetic_train.json

3. Inference

python src/inference/predict.py "No kids under 12 allowed in the specialized quiet zone."
# Output: [NON_COMPLIANT] 98.4% Confidence

πŸ“– Documentation

  • Training Guide - Complete guide to training custom models with GPT-4 prompt templates
  • Benchmarks - Performance comparison and accuracy testing
  • Examples - Ready-to-run code samples
  • ROADMAP - Project development plan and quarterly goals
  • CHANGELOG - Version history and release notes

🀝 Contributing

We welcome contributions from the community! Please see:

πŸ“„ License

This project is licensed under the MIT License.


Built with ❀️ for Fair Housing Compliance
⭐ Star us on GitHub | πŸ› Report Bug | πŸ’‘ Request Feature

About

High-performance, edge-native compliance engine for the Fair Housing Act (FHA). Powered by ModernBERT, providing privacy-first local inference to detect real estate violations in real-time.

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published