|
| 1 | +# PIPL-Compliant Cloud-Edge Collaborative Privacy-Preserving Prompt Processing Framework |
| 2 | + |
| 3 | +This example implements a PIPL-compliant cloud-edge collaborative privacy-preserving LLM inference workflow validated with the ChnSentiCorp-Lite dataset, including: |
| 4 | + |
| 5 | +- Edge-first inference with hard sample mining |
| 6 | +- Adaptive privacy desensitization (regex, NER masking, differential privacy) |
| 7 | +- Privacy and performance metrics visualization |
| 8 | +- Zero raw text cross-border transmission |
| 9 | +- Real-time PIPL compliance verification and audit logging |
| 10 | + |
| 11 | +## Directory Structure |
| 12 | + |
| 13 | +``` |
| 14 | +edge-cloud_collaborative_learning_bench/ |
| 15 | +├── benchmarkingjob.yaml # Benchmarking job configuration |
| 16 | +├── README.md # Project documentation |
| 17 | +├── requirements.txt # Python dependencies |
| 18 | +├── test_algorithms/ # Test algorithms directory |
| 19 | +│ ├── algorithm.yaml # Algorithm configuration |
| 20 | +│ ├── privacy_preserving_llm/ # Privacy-preserving LLM main module |
| 21 | +│ │ ├── __init__.py |
| 22 | +│ │ └── privacy_preserving_llm.py |
| 23 | +│ ├── privacy_detection/ # Privacy detection module |
| 24 | +│ │ ├── __init__.py |
| 25 | +│ │ ├── pipl_classifier.py |
| 26 | +│ │ ├── pii_detector.py |
| 27 | +│ │ └── risk_evaluator.py |
| 28 | +│ └── privacy_encryption/ # Privacy encryption module |
| 29 | +│ ├── __init__.py |
| 30 | +│ ├── differential_privacy.py |
| 31 | +│ ├── saliency_masking.py |
| 32 | +│ ├── dimensionality_reduction.py |
| 33 | +│ └── compliance_monitor.py |
| 34 | +└── testenv/ # Test environment directory |
| 35 | + ├── testenv.yaml # Test environment configuration |
| 36 | + ├── privacy_metrics.py # Privacy evaluation metrics |
| 37 | + └── performance_metrics.py # Performance evaluation metrics |
| 38 | +``` |
| 39 | + |
| 40 | +## Project Background |
| 41 | + |
| 42 | +The rapid advancement of large language models (LLMs) has driven the adoption of cloud-edge collaborative inference architectures, where computationally intensive inference tasks are distributed between edge devices and cloud servers to optimize performance and resource utilization. However, this paradigm introduces critical privacy challenges, particularly when processing user prompts containing sensitive personal information. With the enactment of China's Personal Information Protection Law (PIPL), which mandates strict requirements for cross-border data transmission including "minimal necessity" and "security assurance" principles, organizations face an urgent need to develop privacy-preserving solutions that comply with regulatory requirements while maintaining inference quality. Traditional approaches often require transmitting raw text across borders, creating significant privacy risks and regulatory compliance challenges. This project addresses the fundamental tension between privacy protection and inference utility in cloud-edge collaborative LLM systems, particularly in scenarios requiring cross-border data processing. |
| 43 | + |
| 44 | +## Problems Solved |
| 45 | + |
| 46 | +This project addresses three critical problems in cloud-edge collaborative LLM inference systems. First, it eliminates the privacy leakage risks associated with raw text cross-border transmission by implementing a zero raw text transmission architecture that converts sensitive prompts into anonymized feature vectors before any cross-border transfer occurs. Second, it ensures PIPL compliance by implementing strict adherence to Articles 38-40 of PIPL, including minimal necessity checks, privacy budget management, and real-time compliance verification mechanisms. Third, it resolves the privacy-utility trade-off challenge by developing adaptive privacy desensitization techniques—including differential privacy, saliency-guided masking, and dimensionality reduction—that preserve inference quality while providing strong privacy guarantees. The framework prevents unauthorized reconstruction of original user data from transmitted anonymized vectors, ensuring that sensitive personal information such as names, identification numbers, and locations cannot be recovered by cloud-side adversaries or through membership inference attacks. |
| 47 | + |
| 48 | +## Project Results |
| 49 | + |
| 50 | +The project has achieved comprehensive results across multiple dimensions. Technically, it delivers a complete PIPL-compliant cloud-edge collaborative privacy-preserving prompt processing framework integrated into KubeEdge-Ianvs, featuring edge-first inference with hard sample mining, adaptive privacy desensitization (regex patterns, NER masking, and differential privacy), and real-time compliance monitoring with audit logging. The framework achieves zero raw text cross-border transmission while maintaining inference accuracy comparable to non-privacy-preserving baselines. Academically, it introduces ChnSentiCorp-Lite, the first PIPL-compliant cross-border LLM inference benchmark dataset with 3,000 samples, multi-layer privacy annotations, synthetic PII templates, and dedicated attack evaluation subsets for comprehensive privacy assessment. The project provides a complete evaluation methodology covering utility metrics (task accuracy, end-to-end latency), privacy metrics (Neighbourhood MIA, LOSS Attack, LiRA), and compliance metrics (minimal necessity validation, budget compliance checks, audit integrity verification). Practically, the framework demonstrates successful deployment with Llama-3-8B-Instruct on edge devices and GPT-4o-mini on cloud servers, showcasing production-ready capabilities for privacy-preserving LLM inference in regulated environments. |
| 51 | + |
| 52 | +## Core Features |
| 53 | + |
| 54 | +### 1. Edge-side Privacy Protection |
| 55 | +- Perform irreversible privacy transformation on user's sensitive input prompts |
| 56 | +- Convert raw text into anonymized feature vectors |
| 57 | +- Complete PII detection, entity recognition, and privacy classification locally |
| 58 | + |
| 59 | +### 2. Cloud-side Inference Processing |
| 60 | +- Perform inference based solely on anonymized vectors, never accessing raw text |
| 61 | +- Receive minimal necessary tags to execute core inference tasks |
| 62 | +- Ensure "Zero Raw Text Cross-Border" and "Minimal Tags Cross-Border" |
| 63 | + |
| 64 | +### 3. PIPL Compliance Assurance |
| 65 | +- Strictly adhere to "minimal necessity" and "security assurance" principles |
| 66 | +- Real-time privacy budget management and audit logging |
| 67 | +- Compliance verification before cross-border transmission |
| 68 | + |
| 69 | +## Model Configuration |
| 70 | + |
| 71 | +### Edge Model |
| 72 | +- **Model**: Llama-3-8B-Instruct (4-bit quantized) |
| 73 | +- **Function**: Local PIPL entity recognition, semantic classification, and anonymized vector generation |
| 74 | +- **Deployment**: Adapted for edge computing environments (e.g., NVIDIA T4) |
| 75 | + |
| 76 | +### Cloud Model |
| 77 | +- **Model**: GPT-4o-mini (API access) |
| 78 | +- **Function**: Receive anonymized vectors to perform core inference tasks |
| 79 | +- **Deployment**: OpenAI API format, ensuring scalable deployment |
| 80 | + |
| 81 | +## Dataset |
| 82 | + |
| 83 | +**ChnSentiCorp-Lite** - First PIPL-compliant cross-border LLM inference benchmark dataset |
| 84 | + |
| 85 | +- **Total Samples**: 3,000 (2,000 train, 500 validation, 500 test) |
| 86 | +- **Data Source**: Carefully curated subset of ChnSentiCorp Chinese sentiment analysis dataset |
| 87 | +- **Format**: JSONL with comprehensive privacy annotations |
| 88 | +- **Size**: ~15MB (lightweight for rapid evaluation) |
| 89 | + |
| 90 | +### Key Dataset Contributions |
| 91 | +- **Multi-layer Privacy Annotations**: Each sample tagged with privacy sensitivity levels and PII entity types |
| 92 | +- **Synthetic PII Templates**: 50+ built-in templates for dynamic generation of realistic Chinese personal information |
| 93 | +- **PIPL Compliance Mapping**: Granular annotations indicating cross-border transfer permissions under PIPL Articles 38-40 |
| 94 | +- **Attack Evaluation Subsets**: Dedicated samples for Neighbourhood MIA, LOSS, and LiRA attack testing |
| 95 | + |
| 96 | +## Quick Start |
| 97 | + |
| 98 | +### Requirements |
| 99 | +- Python 3.8+ |
| 100 | +- NVIDIA GPU (recommended T4 or higher) |
| 101 | +- API access keys (OpenAI or compatible services) |
| 102 | + |
| 103 | +### Installation Steps |
| 104 | + |
| 105 | +1. Install dependencies: |
| 106 | +```bash |
| 107 | +pip install -r requirements.txt |
| 108 | +``` |
| 109 | + |
| 110 | +2. Configure API keys: |
| 111 | +```bash |
| 112 | +export EDGE_API_KEY="your_edge_model_api_key" |
| 113 | +export CLOUD_API_KEY="your_cloud_model_api_key" |
| 114 | +``` |
| 115 | + |
| 116 | +3. Run benchmark: |
| 117 | +```bash |
| 118 | +ianvs -f benchmarkingjob.yaml |
| 119 | +``` |
| 120 | + |
| 121 | +## Evaluation Methods |
| 122 | + |
| 123 | +### 1. Utility Evaluation |
| 124 | +- **Task Accuracy**: Compare accuracy changes before and after enabling privacy transformations |
| 125 | +- **End-to-End Latency**: Measure total time from user prompt input to receiving final response |
| 126 | + |
| 127 | +### 2. Privacy Evaluation |
| 128 | +- **Neighbourhood MIA**: Model-agnostic approach using semantically similar neighbor samples |
| 129 | +- **LOSS Attack**: Traditional loss-based membership inference baseline |
| 130 | +- **LiRA**: Advanced likelihood ratio test with theoretical optimality properties |
| 131 | + |
| 132 | +### 3. Compliance Evaluation |
| 133 | +- **Minimal Necessity Check**: Payload structure validation |
| 134 | +- **Budget Compliance Check**: ε accumulation validation |
| 135 | +- **Audit Integrity Check**: Log coverage verification |
| 136 | + |
| 137 | +## Technical Architecture |
| 138 | + |
| 139 | +The system adopts strict separation of duties between cloud and edge to ensure compliance of data processing workflows: |
| 140 | + |
| 141 | +1. **Privacy Detection Module**: Identifies and classifies privacy-sensitive information in user prompts |
| 142 | +2. **Privacy Encryption Module**: Performs irreversible transformation of sensitive prompts into anonymized vectors |
| 143 | +3. **Edge Inference**: Local privacy processing and preliminary inference |
| 144 | +4. **Cloud Collaboration**: Advanced inference based on anonymized data |
| 145 | +5. **Compliance Monitoring**: Real-time monitoring and audit logging |
| 146 | + |
| 147 | +## Privacy Protection Technologies |
| 148 | + |
| 149 | +- **Differential Privacy**: L2-norm clipping, Gaussian noise injection, budget tracking |
| 150 | +- **Saliency-Guided Masking**: Attention-based token importance with configurable suppression |
| 151 | +- **Dimensionality Reduction**: Johnson-Lindenstrauss projection with semantic preservation |
| 152 | +- **Compliance Verification**: Real-time monitoring and audit logging |
| 153 | + |
| 154 | +## Contributing |
| 155 | + |
| 156 | +We welcome contributions, bug reports, and improvement suggestions. Please follow these steps: |
| 157 | + |
| 158 | +1. Fork this repository |
| 159 | +2. Create a feature branch |
| 160 | +3. Commit your changes |
| 161 | +4. Push to the branch |
| 162 | +5. Create a Pull Request |
| 163 | + |
| 164 | +## License |
| 165 | + |
| 166 | +This project uses the same license as KubeEdge-Ianvs. |
| 167 | + |
| 168 | +## Contact |
| 169 | + |
| 170 | +For questions or suggestions, please contact us through GitHub Issues. |
0 commit comments