import re
from typing import Dict, List, Optional, Union
from enum import Enum
class ItemType(Enum):
MODEL = "model"
CODE = "code"
DATA = "data"
class ECCN(str, Enum):
EAR99 = "EAR99" # No license required for most exports
_3A090 = "3A090" # Certain integrated circuits (e.g., AI accelerators)
_3D001 = "3D001" # Software for 3A001 items
_3D991 = "3D991" # Mass market software
_4A090 = "4A090" # High-performance computers/AI systems
_4D001 = "4D001" # Software for 4A001 computers
_4D090 = "4D090" # Software for 4A090 systems
_4E001 = "4E001" # Technology for 4A systems
_5D002 = "5D002" # Encryption software
_9B115 = "9B115" # Aerospace simulation software
OTHER = "Consult BIS/CCL for specific ECCN"
class ExportControlsClassifier:
"""
Rule-based ECCN Classifier for AI/ML Models, Code, and Data.
Based on US EAR Commerce Control List (CCL) as of 2024:
- Focuses on dual-use AI-related items (Categories 3,4,5,9).
- AI models treated as "software" or "commodity."
- Thresholds derived from BIS rules (e.g., Oct 2023/Jan 2024 amendments for HPC/AI).
- **Disclaimer**: This is a simplified tool for initial screening. Always consult EAR/CCL,
BIS, or legal expert for binding classification. Self-classification is not guaranteed.
Usage:
classifier = ExportControlsClassifier()
eccn = classifier.classify(item_type=ItemType.MODEL, description="Llama-70B model weights", params=70e9)
"""
# Thresholds from BIS rules (approximate for AI/HPC)
HPC_TDP_THRESHOLD_W = 480 # 4A090.a
AI_TOTAL_PROCESSING_PERFORMANCE_TP_W = 4800 # 4A090.b (for AI systems)
MODEL_PARAMS_THRESHOLD = 1e11 # Hypothetical/emerging for large foundation models (BIS proposals)
ENCRYPTION_KEY_LENGTH = 256 # For 5D002
def __init__(self):
self.rules = {
ItemType.MODEL: self._classify_model,
ItemType.CODE: self._classify_code,
ItemType.DATA: self._classify_data,
}
def classify(
self,
item_type: Union[ItemType, str],
description: str,
**kwargs
) -> Dict[str, Union[ECCN, str]]:
"""
Classify item to ECCN.
Args:
item_type: 'model', 'code', or 'data'
description: Text description (used for keyword matching)
**kwargs: Additional params (e.g., params=float for models, is_encrypted=bool for code)
Returns:
Dict with 'eccn' and 'reasoning'
"""
if isinstance(item_type, str):
item_type = ItemType(item_type.lower())
classify_fn = self.rules[item_type]
return classify_fn(description.lower(), **kwargs)
def _classify_model(self, desc: str, params: Optional[float] = None, is_open_source: bool = False) -> Dict:
if is_open_source and "huggingface" in desc or "public" in desc:
return {"eccn": ECCN.EAR99, "reasoning": "Publicly available open-source models are typically EAR99."}
if params and params >= self.MODEL_PARAMS_THRESHOLD:
return {"eccn": ECCN._4D090, "reasoning": "Very large foundation model (>100B params); potential 4A090/4D090 control."}
if any(kw in desc for kw in ["diffusion", "stable diffusion", "generative ai", "multimodal"]):
return {"eccn": ECCN._4D001, "reasoning": "Generative AI models may require 4D001 if designed for HPC."}
if any(kw in desc for kw in ["quantum", "simulator"]):
return {"eccn": ECCN.OTHER, "reasoning": "Quantum/ML simulators; check 3D001 or 4D001."}
return {"eccn": ECCN.EAR99, "reasoning": "Standard ML model; likely EAR99 unless meets performance thresholds."}
def _classify_code(self, desc: str, is_encrypted: bool = False, lines: Optional[int] = None, **kwargs) -> Dict:
if is_encrypted or any(kw in desc for kw in ["encryption", "crypto", "symmetric", "aes"]):
return {"eccn": ECCN._5D002, "reasoning": "Encryption software (5D002); check mass market exception (5D992)."}
if any(kw in desc for kw in ["compiler", "hpc", "supercomputer", "ai training"]):
return {"eccn": ECCN._4D001, "reasoning": "Software for high-performance computing/AI (4D001/4D090)."}
if any(kw in desc for kw in ["simulation", "cfd", "aerospace", "propulsion"]):
return {"eccn": ECCN._9B115, "reasoning": "Simulation software for controlled items (9B115)."}
if lines and lines < 1000 and "mass market" in desc:
return {"eccn": ECCN._3D991, "reasoning": "Mass-market software (3D991)."}
return {"eccn": ECCN.EAR99, "reasoning": "General-purpose code; EAR99."}
def _classify_data(self, desc: str, is_sensitive: bool = False, size_gb: Optional[float] = None) -> Dict:
if is_sensitive or any(kw in desc for kw in ["proprietary tech", "defense", "nuclear", "missile"]):
return {"eccn": ECCN._4E001, "reasoning": "Controlled technical data/technology (4E001 or spec'd tech)."}
if any(kw in desc for kw in ["training data", "synthetic", "large scale"]):
if size_gb and size_gb > 1000:
return {"eccn": ECCN.OTHER, "reasoning": "Very large datasets for AI; potential tech control if proprietary."}
return {"eccn": ECCN.EAR99, "reasoning": "Public or general datasets; EAR99."}
return {"eccn": ECCN.EAR99, "reasoning": "Non-technical data; EAR99."}
# Example Usage
if __name__ == "__main__":
classifier = ExportControlsClassifier()
# Model examples
print(classifier.classify(ItemType.MODEL, "GPT-4 like 175B param model", params=175e9))
# {'eccn': <ECCN._4D090>, 'reasoning': 'Very large foundation model (>100B params); potential 4A090/4D090 control.'}
print(classifier.classify(ItemType.MODEL, "BERT-base", params=110e6, is_open_source=True))
# {'eccn': <ECCN.EAR99>, 'reasoning': 'Publicly available open-source models are typically EAR99.'}
# Code examples
print(classifier.classify(ItemType.CODE, "AI training framework for HPC clusters", is_encrypted=False))
# {'eccn': <ECCN._4D001>, 'reasoning': 'Software for high-performance computing/AI (4D001/4D090).'}
print(classifier.classify(ItemType.CODE, "AES-256 encryption library"))
# {'eccn': <ECCN._5D002>, 'reasoning': 'Encryption software (5D002); check mass market exception (5D992).'}
# Data examples
print(classifier.classify(ItemType.DATA, "Common Crawl dataset", size_gb=5000))
# {'eccn': <ECCN.OTHER>, 'reasoning': 'Very large datasets for AI; potential tech control if proprietary.'}
print(classifier.classify(ItemType.DATA, "CIFAR-10 images", is_sensitive=False))
# {'eccn': <ECCN.EAR99>, 'reasoning': 'Non-technical data; EAR99.'}
Key Notes on This Classifier
- Rule-Based: Uses keyword matching, thresholds from BIS (e.g., 4A090 for AI systems >4800 TPP), and heuristics. Expand with regex/ML for production.
- AI-Specific Focus: Maps to relevant CCL entries (3A090/4A090/4D090 for semiconductors/AI hardware/software).
- Open-Source Exception: Public models/datasets (e.g., Hugging Face) → EAR99 (per EAR §734.8).
- Limitations:
- Not legal advice; use CCATS/SNARL for official classification.
- Emerging AI rules (BIS AI diffusion model proposals) not fully codified—monitor Federal Register.
- De minimis, direct product rules, and end-use checks separate from ECCN.
- Extensibility: Add
train_model() for ML-based classification on historical BIS data.
For custom rules or integration, provide more details! 🕵️♂️