Learn how to create Software Bills of Materials for AI and machine learning models, including training data, model architectures, and dependencies

Updated:

SBOM for AI/ML Models: Complete Implementation Guide

As artificial intelligence and machine learning models become critical infrastructure components, teams need a way to track more than ordinary package dependencies. AI-specific SBOMs and AI bills of materials extend traditional SBOM concepts to cover model artifacts, datasets, training environments, prompts, agents, licenses, and security evidence.

Why AI Models Need SBOMs

Traditional SBOMs weren't designed for the unique challenges of AI/ML systems:

  • Training Data Provenance: Where did the data come from?
  • Model Architecture Tracking: What neural network design was used?
  • Framework Dependencies: TensorFlow, PyTorch, JAX versions
  • Hardware Requirements: GPU/TPU specifications
  • Ethical Considerations: Bias detection and fairness metrics

Components of an AI/ML SBOM

1. Model Metadata

Essential information about the model itself:

{
  "model": {
    "name": "sentiment-analyzer-v2",
    "version": "2.1.0",
    "architecture": "BERT-base-uncased",
    "task": "text-classification",
    "created": "2025-01-15T10:30:00Z",
    "hash": {
      "algorithm": "SHA-256",
      "value": "e3b0c44298fc1c149afbf4c8996fb924..."
    }
  }
}

2. Training Data Inventory

Document all data sources:

{
  "training_data": {
    "datasets": [
      {
        "name": "IMDB Movie Reviews",
        "version": "1.0",
        "source": "https://datasets.example.com/imdb",
        "license": "Apache-2.0",
        "size": "50000 samples",
        "collection_date": "2024-06-01",
        "preprocessing": ["tokenization", "normalization"]
      }
    ],
    "augmentation": {
      "techniques": ["back-translation", "paraphrasing"],
      "ratio": 0.2
    }
  }
}

3. Framework and Dependencies

Track all software components:

frameworks:
  - name: tensorflow
    version: 2.15.0
    license: Apache-2.0
  - name: transformers
    version: 4.36.0
    license: Apache-2.0

dependencies:
  - numpy: 1.24.3
  - pandas: 2.0.3
  - scikit-learn: 1.3.0
  - tokenizers: 0.15.0

4. Training Environment

Document the computational environment:

{
  "training_environment": {
    "hardware": {
      "gpu": "NVIDIA A100 40GB",
      "gpu_count": 8,
      "cpu": "AMD EPYC 7763",
      "memory": "512GB"
    },
    "software": {
      "os": "Ubuntu 22.04 LTS",
      "cuda": "12.1",
      "python": "3.11.5"
    },
    "duration": "72 hours",
    "carbon_footprint": "450 kg CO2"
  }
}

Implementing AI-SBOM Generation

Step 1: Automated Tracking During Training

# ai_sbom_generator.py
import json
import hashlib
from datetime import datetime
import torch
import transformers

class AISBOMGenerator:
    def __init__(self, model_name, version):
        self.sbom = {
            "schema_version": "AI-BOM-1.0",
            "model_name": model_name,
            "version": version,
            "created": datetime.now().isoformat(),
            "components": {}
        }

    def track_dataset(self, dataset_info):
        """Track training dataset information"""
        self.sbom["training_data"] = {
            "name": dataset_info["name"],
            "source": dataset_info["source"],
            "size": len(dataset_info["data"]),
            "hash": self._calculate_hash(dataset_info["data"]),
            "license": dataset_info.get("license", "Unknown")
        }

    def track_model_architecture(self, model):
        """Extract model architecture details"""
        self.sbom["architecture"] = {
            "type": model.__class__.__name__,
            "parameters": sum(p.numel() for p in model.parameters()),
            "layers": len(list(model.modules())),
            "configuration": model.config.to_dict() if hasattr(model, 'config') else {}
        }

    def track_dependencies(self):
        """Capture all Python dependencies"""
        import pkg_resources
        self.sbom["dependencies"] = [
            {
                "name": pkg.project_name,
                "version": pkg.version
            }
            for pkg in pkg_resources.working_set
        ]

    def track_training_metrics(self, metrics):
        """Record training performance metrics"""
        self.sbom["training_metrics"] = {
            "accuracy": metrics.get("accuracy"),
            "loss": metrics.get("loss"),
            "epochs": metrics.get("epochs"),
            "batch_size": metrics.get("batch_size"),
            "learning_rate": metrics.get("learning_rate")
        }

    def generate_sbom(self, output_path="ai_sbom.json"):
        """Generate the final AI-SBOM"""
        with open(output_path, 'w') as f:
            json.dump(self.sbom, f, indent=2)
        return self.sbom

    def _calculate_hash(self, data):
        """Calculate SHA-256 hash of data"""
        if isinstance(data, str):
            data = data.encode()
        return hashlib.sha256(data).hexdigest()

Step 2: Integration with ML Pipelines

# mlflow_integration.py
import mlflow
from ai_sbom_generator import AISBOMGenerator

def train_with_sbom_tracking(model, dataset, config):
    # Initialize SBOM generator
    sbom_gen = AISBOMGenerator(
        model_name=config["model_name"],
        version=config["version"]
    )

    # Track dataset
    sbom_gen.track_dataset({
        "name": dataset.name,
        "source": dataset.source,
        "data": dataset.get_sample(),
        "license": dataset.license
    })

    # Track model architecture
    sbom_gen.track_model_architecture(model)

    # Track dependencies
    sbom_gen.track_dependencies()

    # Train model
    with mlflow.start_run():
        # Training code here
        metrics = train_model(model, dataset, config)

        # Track metrics
        sbom_gen.track_training_metrics(metrics)

        # Generate and log SBOM
        sbom = sbom_gen.generate_sbom()
        mlflow.log_artifact("ai_sbom.json")

    return model, sbom

AI-SBOM Standards and Formats

CycloneDX for ML

CycloneDX 1.7 can represent machine learning models as components and can attach a model card to describe intended use, limitations, training details, performance metrics, and ethical considerations. Use standard CycloneDX fields first, then add organization-specific properties only when your downstream tools understand them.

<component type="machine-learning-model">
  <name>sentiment-classifier</name>
  <version>1.0.0</version>
  <description>Transformer model for sentiment analysis</description>
  <modelCard>
    <modelParameters>
      <approach>
        <type>supervised</type>
      </approach>
      <task>text-classification</task>
    </modelParameters>
    <considerations>
      <useCases>
        <useCase>Classify customer feedback sentiment</useCase>
      </useCases>
      <technicalLimitations>
        <technicalLimitation>Not validated for medical or legal decisions</technicalLimitation>
      </technicalLimitations>
    </considerations>
  </modelCard>
  <properties>
    <property name="ai.training.dataset">IMDB-Reviews</property>
    <property name="ai.training.framework">TensorFlow</property>
  </properties>
</component>

SPDX AI Profile

SPDX 3.x work includes AI, dataset, software, and relationship profiles that are useful for AI-SBOMs. In practice, model governance teams should use SPDX to connect model artifacts, datasets, software dependencies, licenses, and audit evidence rather than treating the model as a standalone package list.

# Conceptual SPDX 3.x graph shape, not a complete serialized document.
profileConformance:
  - core
  - software
  - ai
name: AI Model Bill of Materials
elements:
  - type: AIModel
    name: sentiment-analyzer
    summary: Text classification model based on a transformer architecture
  - type: Dataset
    name: training-reviews
    summary: Licensed review dataset used during training
relationships:
  - from: sentiment-analyzer
    relationshipType: trainedOn
    to: training-reviews

Security Considerations for AI-SBOMs

1. Model Poisoning Detection

Track indicators of potential poisoning:

{
  "security_metrics": {
    "data_validation": {
      "outlier_detection": "enabled",
      "data_sanitization": "applied",
      "poisoning_defense": "gradient_clipping"
    },
    "model_validation": {
      "backdoor_scanning": "completed",
      "adversarial_testing": "passed",
      "robustness_score": 0.92
    }
  }
}

2. Privacy Compliance

Document privacy measures:

{
  "privacy_compliance": {
    "differential_privacy": {
      "enabled": true,
      "epsilon": 1.0,
      "delta": 1e-5
    },
    "data_anonymization": "k-anonymity",
    "pii_removal": "automated",
    "privacy_review_status": "documented"
  }
}

3. Bias and Fairness Metrics

Include fairness assessments:

{
  "fairness_metrics": {
    "demographic_parity": 0.95,
    "equal_opportunity": 0.93,
    "disparate_impact": 1.12,
    "tested_groups": ["gender", "age", "ethnicity"],
    "mitigation_applied": "reweighting"
  }
}

Best Practices for AI-SBOM Management

1. Version Control Integration

# Git hooks for automatic SBOM generation
#!/bin/bash
# .git/hooks/pre-commit

# Generate AI-SBOM before committing model files
if git diff --cached --name-only | grep -q "\.h5\|\.pt\|\.onnx"; then
    python generate_ai_sbom.py
    git add ai_sbom.json
fi

2. Continuous Monitoring

# monitor_ai_sbom.py
def monitor_model_drift(model_sbom, production_metrics):
    """Monitor for model drift and update SBOM"""
    drift_detected = False

    if production_metrics["accuracy"] < model_sbom["training_metrics"]["accuracy"] * 0.95:
        drift_detected = True

    if drift_detected:
        update_sbom_with_drift_alert(model_sbom)
        trigger_retraining()

3. Supply Chain Validation

def validate_ai_supply_chain(sbom):
    """Validate all components in AI supply chain"""
    issues = []

    # Check dataset licenses
    for dataset in sbom["training_data"]["datasets"]:
        if not is_license_compatible(dataset["license"]):
            issues.append(f"License issue: {dataset['name']}")

    # Verify framework versions
    for dep in sbom["dependencies"]:
        if has_known_vulnerability(dep["name"], dep["version"]):
            issues.append(f"Vulnerable dependency: {dep['name']}")

    return issues

Tools for AI-SBOM Generation

Open Source Tools

  1. ModelCards Toolkit (Google)
  • Automated model documentation
  • Integrates with TensorFlow
  • Exports to various formats
  1. AI Fairness 360 (IBM)
  • Bias detection metrics
  • Fairness assessment
  • SBOM-compatible reports
  1. MLflow
  • Experiment tracking
  • Model registry
  • Artifact management

Commercial Solutions

  1. Weights & Biases
  • Comprehensive tracking
  • Automated SBOM generation
  • Enterprise compliance features
  1. Neptune.ai
  • Model metadata management
  • Dependency tracking
  • Audit trail generation

Regulatory Compliance

EU AI Act Requirements

The EU AI Act mandates transparency for high-risk AI systems:

  • Technical documentation of training data
  • Model architecture disclosure
  • Performance metrics reporting
  • Bias mitigation measures

NIST AI Risk Management Framework

Align your AI-SBOM with NIST guidelines:

  • Map AI risks to SBOM components
  • Document risk mitigation strategies
  • Include testing and validation results
  • Maintain audit trails

Future of AI-SBOMs

Emerging Standards

  • ISO/IEC 23053: AI trustworthiness
  • IEEE P2894: AI model governance
  • ISO/IEC 23894: AI risk management

Integration with LLMs

For Large Language Models, additional tracking includes:

  • Pre-training corpora sources
  • Fine-tuning datasets
  • Prompt engineering templates
  • Retrieval augmentation sources
  • Safety filters and guardrails

Conclusion

AI-SBOMs are useful for maintaining transparency, security, and compliance evidence in machine learning systems. By tracking data sources, model architecture, dependencies, prompts, agents, and performance metrics, organizations can make AI systems easier to audit, reproduce, and govern.

Start by documenting the model, training data, software dependencies, runtime environment, and governance evidence your reviewers already ask for. Then map that evidence into CycloneDX, SPDX, or an internal schema that your tooling can validate.

---

Next step: validate the software-dependency SBOM for your AI service with the SBOM Validator, then document model, dataset, prompt, and runtime metadata alongside it.

Share this article