MAIS - ML Model Audit & Inspection System
A Python library that watches for potentially risky model or dataset loads. MAIS analyzes code in real-time to detect when you're trying to load models that might require special permissions or licensing. It works as a Jupyter notebook plugin and as a plain Python library — instantiate MAIS() in a regular script and it automatically hooks into your imports the same way it hooks into notebook cells.
Detection
MAIS uses provider-based detection: specialized AST and regex detectors per ML/AI provider, combining structural analysis with pattern matching for broad coverage.
| Provider | Coverage |
|---|---|
| HuggingFace | Transformers, Hub model loads, datasets integration |
| OpenAI | Full API client and model usage |
| PyTorch | torch.load and extended model-loading patterns |
| Anthropic | Claude API integrations |
| LangChain | LangChain components, chains, and framework usage |
| LlamaIndex | LlamaIndex document processing |
Architecture Overview
MAIS uses a flexible, strategy-based architecture with multiple specialized components:
Additional Architecture Views
| View | Purpose | Link |
|---|---|---|
| 📊 Dependencies | Component relationships & data flow | MAIS_DEPENDENCY.svg |
| ⚡ Process Flow | End-to-end analysis workflow | MAIS_PROCESS.svg |
| 🏗️ DDD Layers | Domain-driven design structure | MAIS_ARCHITECTURE.svg |
Core Components
📥 Input Layer
Processes various types of source code inputs:
- Source Code: Direct Python code analysis
- Notebooks: Jupyter notebook cell analysis
- Requirements: Dependency file scanning
- Python Files: Static file analysis
🔍 Provider-Specific Detectors
Specialized detectors for different ML/AI providers and frameworks:
- OpenAI: Detects GPT, DALL-E, and OpenAI API usage
- HuggingFace: Identifies Transformers, Datasets, and Hub model loads
- Anthropic: Catches Claude API integrations
- LangChain: Finds LangChain components and chains
- LlamaIndex: Detects LlamaIndex document processing
⚙️ Detection Strategies
Pluggable analysis approaches that detectors can use:
- AST Strategy: Advanced parsing with variable resolution for complex code analysis
- Regex Strategy: Fast pattern matching for simple detection scenarios
- LLM-based Strategy: Future AI-powered code understanding
📊 Intermediate Output
Analysis results from provider detectors:
- Model Findings: Detected model usage with metadata
- Risk Assessment: Security and compliance evaluation
- Inventory Mapping: Model-to-provider relationship mapping
📋 JSON Schema Standardization
Converts findings into structured format:
- AI Detection JSON Schema: Standardized detection results format
- Provider Attribution: Links findings to specific ML providers
- Risk Categorization: Security and compliance classifications
📦 SBOM Generation
Creates comprehensive software bills of materials:
- manifest-cli Integration: Uses external SBOM generation tools
- SBOM Builder: Internal component for SBOM creation
- Dependency Analysis: Maps AI/ML dependencies
📤 Output Formats
Multiple standard formats for integration:
- CycloneDX JSON: Industry-standard SBOM format
- SPDX JSON: Open-source license compliance format
Installation
# Using pip
pip install mais
# Import and initialize the MAIS plugin
from mais import MAIS
m = MAIS(api_token="<manifest-api-token>")
# Now run your notebook as normal
# MAIS will monitor for potentially risky model loads
Using MAIS in a Plain Python Script
MAIS isn't limited to Jupyter — you can use it directly from any Python script, CI job, or service. Instantiating MAIS() outside of a notebook automatically installs script-mode hooks that mirror the per-cell behavior you get in Jupyter:
- One-shot scan of your entry script (
__main__) at construction time. - Per-module import hook (
sys.meta_pathfinder) that analyzes the source of each first-party module you import before it executes. Stdlib andsite-packagesmodules are skipped automatically — only your user code is scanned.
from mais import MAIS
# Instantiating MAIS in a regular script automatically:
# 1. Reads and analyzes the running script's source.
# 2. Installs an import hook so every user module you import next
# gets analyzed before it runs (just like a Jupyter cell).
m = MAIS(api_token="<manifest-api-token>", verbosity="DEBUG")
from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("moonshotai/Kimi-K2-Instruct")
from datasets import load_dataset
dataset = load_dataset("ProlificAI/social-reasoning-rlhf")
# Methods like register_model() and create_sbom() work without any
# extra plumbing — MAIS uses the cached script source automatically.
m.register_model("my_custom_model", "1.0", "Acme", "USA")
m.create_sbom(path=".", publish=False)
# Need to detach the import hook (e.g. in tests)?
m.uninstall()
Expected output (truncated):
MAIS [DEBUG]: Jupyter plugin initialized
MAIS [DEBUG]: Found dataset loading call: load_dataset('ProlificAI/social-reasoning-rlhf')
MAIS [DEBUG]: Datasets found: [{'title': 'ProlificAI/social-reasoning-rlhf', ...}]
MAIS [DEBUG]: Custom model registration → POST https://api.manifestcyber.com/v1/model-analysis/custom
MAIS [DEBUG]: Model '<id>' registered successfully
✅ SBOM Created — sbom.json written at .
Google Colab Usage
Perfect for environments where you can't set environment variables:
from google.colab import userdata
api_token = userdata.get('MANIFEST_API_KEY')
from mais import MAIS
m = MAIS(api_token=api_token)
SBOM Generation
# Generate an SBOM for your project or notebook environment.
m.create_sbom(path=".", publish=False)
SBOM Publishing
m.create_sbom(path=".", publish=True)
Environment Variables
MAIS supports configuration through environment variables:
Core Configuration
MANIFEST_API_TOKEN- API token for MOSAIC/Manifest integrationMAIS_MOSAIC_API_URL- Override default API URLMAIS_DEFAULT_VERBOSITY- Set default logging levelMAIS_API_TIMEOUT- API request timeout in seconds
All configuration values can be overridden with MAIS_ prefix.
Metadata
Release files for mais 3.0.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mais-3.0.9.tar.gz | 38.7 MB | Without provenance | Details for mais-3.0.9.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mais-3.0.9-py3-none-any.whl | Python 3 | none | any | Details for mais-3.0.9-py3-none-any.whl |
Total release size: 77.7 MB
Release files / mais-3.0.9.tar.gz
| Download URL | mais-3.0.9.tar.gz |
|---|---|
| Size | 38.7 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4bd6761b96a079897089b5b9f3b036c28dc55a2cfa65b4356b53d11b329c2534
|
|
BLAKE2b-256 checksum How to use checksums |
915cea725ba3c8a23b994aba9ff5f309975f98c28d027b3e111e3b46dba1cf59
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.16
|
Release files / mais-3.0.9-py3-none-any.whl
| Download URL | mais-3.0.9-py3-none-any.whl |
|---|---|
| Size | 39.0 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
78b531c5d71d4534827d9f204302b0d5890e4214696bd31e2a16082909e1ff9e
|
|
BLAKE2b-256 checksum How to use checksums |
3c6a49b2e4a10c7034bcd47f38823117b0577bcc31454594638081cf997449f7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.16
|
Security for mais 3.0.9
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.