Specialized Cyber Defense & Operational Agents

Problem Statement

Data Loss Prevention (DLP) engines use regular expressions (e.g., matching 16-digit numbers for credit cards) that trigger high false-positive rates on random numbers, serial numbers, or sample data files.

Goal

Implement an AI agent that performs semantic content classification to accurately label unstructured documents (e.g., PII, PHI, PCI, Intellectual Property).

Outcome Measurement

  1. Classification Accuracy: 94% precision in document classification across complex corporate data stores.
  2. Reduction in False DLP Alerts: 88% reduction in false-positive DLP alerts.

How the Code was Built

Evaluates semantic context inside document passages to determine data classification compliance.

Executable Code

from pydantic import BaseModel, Field
from langchain_openai import ChatOpenAI
class DLPClassification(BaseModel):
data_classification: str = Field(description="PUBLIC, INTERNAL, CONFIDENTIAL, or RESTRICTED_PII")
contains_sensitive_data: bool
detected_data_types: list[str]
suggested_file_label: str
def classify_document_content(document_text: str) -> DLPClassification:
llm = ChatOpenAI(model="gpt-4o", temperature=0)
structured_llm = llm.with_structured_output(DLPClassification)
prompt = f"Analyze document text for sensitive data classification labeling:\n{document_text}"
return structured_llm.invoke(prompt)
if __name__ == "__main__":
sample_text = "Patient John Doe (DOB: 1980-05-12) was prescribed 50mg of Medication X following diagnosis of Condition Y."
res = classify_document_content(sample_text)
print(f"Classification: {res.data_classification}")
print(f"Detected Types: {res.detected_data_types}")
print(f"File Label: {res.suggested_file_label}")

Leave a Reply

Trending