ContextLens: Modeling Imperfect Privacy and Safety Context for Legal Compliance
Organizations: Beihang University · HKUST · National University of Singapore · Faculty of Law, University of Macau
Abstract
Individuals' concerns about data privacy and AI safety are highly contextualized and extend beyond sensitive patterns. Addressing these issues requires reasoning about the context to identify and mitigate potential risks. Though researchers have widely explored using large language models (LLMs) as evaluators for contextualized safety and privacy assessments, these efforts typically assume the availability of complete and clear context, whereas real-world contexts tend to be ambiguous and incomplete. In this paper, we propose ContextLens, a semi-rule-based framework that leverages LLMs to ground the input context in the legal domain and explicitly identify both known and unknown factors for legal compliance. Instead of directly assessing safety outcomes, our ContextLens instructs LLMs to answer a set of crafted questions that span over applicability, general principles and detailed provisions to assess compliance with pre-defined priorities and rules. We conduct extensive experiments on existing compliance benchmarks that cover the General Data Protection Regulation (GDPR) and the EU AI Act. The results suggest that our ContextLens can significantly improve LLMs' compliance assessment and surpass existing baselines without any training. Additionally, our ContextLens can further identify the ambiguous and missing factors.
Figures & tables
| Domain | Permit | Prohibit | Not Applicable | Total |
|---|---|---|---|---|
| GDPR | 150 | 478 | 0 | 628 |
| AI Act | 202 | 187 | 211 | 600 |
| Evaluation Types | Evaluated Models | EU AI Act | GDPR | Average | |||
|---|---|---|---|---|---|---|---|
| Acc | Macro-F1 | Acc | Macro-F1 | Acc | Macro-F1 | ||
| Direct | Qwen2.5-7B-Instruct | 46.33 | 41.89 | 88.37 | 85.36 | 67.35 | 63.63 |
| Llama-3.1-8B-Instruct | 58.67 | 59.36 | 86.88 | 84.06 | 72.78 | 71.71 | |
| OpenThinker-7B | 70.50 | 69.72 | 87.26 | 81.82 | 78.88 | 75.77 | |
| GPT-4o-mini | 71.16 | 70.92 | 92.19 | 89.29 | 81.68 | 80.11 | |
| GPT-4o | 75.33 | 73.39 | 92.19 | 90.02 | 83.76 | 81.71 | |
| GDPR | AI Act | |||
|---|---|---|---|---|
| Ratio | Avg # | Ratio | Avg # | |
| Llama-3.1-8B-Instruct | 98.57 | 4.93 | 98.33 | 5.22 |
| GPT-4o-mini | 99.04 | 5.22 | 100.00 | 5.50 |
| Gemini-2.5-Flash | 100.00 | 7.48 | 100.00 | 5.73 |
| Article 5: Principles | Article 6: Lawfulness | Article 40,42: Obligations | |||||||
|---|---|---|---|---|---|---|---|---|---|
| Correct | Wrong | Correct | Wrong | Correct | Wrong | ||||
| Llama-3.1-8B-Instruct | 80.82 | 95.71 | +14.89 | 75.44 | 74.28 | -1.16 | 91.03 | 95.71 | +4.68 |
| GPT-4o-mini | 90.46 | 100.00 | +9.54 | 39.86 | 68.62 | +28.76 | 90.12 | 100.00 | +9.88 |
| Gemini-2.5-Flash | 99.23 | 100.00 | +0.77 | 58.23 | 63.20 | +4.97 | 95.21 | 97.16 | +1.95 |
| Case Context: Microsoft updated its Privacy Policy and communicated the changes via email and on its website. All users were informed, and the updates did not reduce user rights but clarified existing practices. |
| Ground Truth: Permitted |
| Gemini-2.5-Flash’s Structured Output : |
| { |
| Method | Dataset | Model | Input # | Response # |
|---|---|---|---|---|
| Direct | AI Act | GPT-4o | 238.31 | 8.36 |
| AI Act | GPT-4o-mini | 238.31 | 92.92 | |
| GDPR | GPT-4o | 149.17 | 7.45 | |
| GDPR | GPT-4o-mini | 149.17 | 68.62 | |
| ContextLens | AI Act | GPT-4o | 522.29 | 195.30 |
| AI Act | GPT-4o-mini | 522.29 | 194.56 |
Appendix figures & tables7 assets
Supplementary material from the paper’s appendix.
Appendix
| GDPR | AI Act | |||
| Cohen | Fleiss | Cohen | Fleiss | |
| Llama-3.1-8B-Instruct | 100.00 | 95.87 | ||
| GPT-4o-mini | 100.00 | 21.25 | 96.63 | 79.93 |
| Gemini-2.5-Flash | 100.00 | 91.02 | ||
| Multiple Choice Template Used for Direct Prompting |
| Determine the relationship between the provided event and the <domain> regulations. You have three options for your conclusion: |
| (A) The event is prohibited by <domain> . |
| (B) The event is permitted by <domain> . |
| (C) The event is not related to <domain> . |
| Event: <event> Output Format: Choice: [A. Prohibited | B. Permitted | C. Not related ] |
| ContextLens’ Context Analysis Prompt Template for the EU AI Act |
| As an expert context analyzer, your task is to analyze the given case and identify if there is any AI system involved. If there is AI system involved, please identify the name, type, usage and actions of the AI system. |
| Definition of AI system: |
| An AI system is defined as: A machine-based system designed to operate with varying levels of autonomy and that may exhibit adaptiveness after deployment and that, for explicit or implicit objectives, infers, from the input it receives, how to generate outputs such as predictions, content, recommendations, or decisions that can influence physical or virtual environments. |
| Please follow these steps: |
| 1. Analyze the case and identify if there is any AI system involved. If there is an AI system involved, please identify the name of the AI system, the type of the AI system, and the usage of the AI system. |
| 2. If there is an AI system involved, please identify atomic actions that are performed by the AI system and the target of the action. If there is more than one action, please identify all of them. |
| Model | Default # | Original Acc | Updated Acc |
|---|---|---|---|
| Qwen2.5-7b-Instruct | 22 | 85.19 | 85.64 |
| Llama-3.1-8B-Instruct | 8 | 88.85 | 89.19 |
| GPT-4o | 19 | 89.31 | 90.13 |
| DeepSeek-R1 (671B) | 26 | 80.89 | 83.22 |
| o3-mini | 24 | 85.35 | 86.42 |
| Gemini-2.5-Flash | 31 | 83.12 | 85.09 |
| RAG Types | Models | EU AI Act | GDPR |
|---|---|---|---|
| LegalBERT | GPT-4o-mini | 69.67 | 92.20 |
| GPT-4o | 78.83 | 90.76 | |
| o3-mini | 34.33 | 69.11 | |
| BM25 | GPT-4o-mini | 74.33 | 91.24 |
| GPT-4o | 77.75 | 90.92 | |
| o3-mini | 80.33 | 91.24 |
| Dataset | Model | Accuracy ( SD) | 95% CI |
|---|---|---|---|
| AI_ACT | gpt-4o | ||
| AI_ACT | gpt-4o-mini | ||
| GDPR | gpt-4o | ||
| GDPR | gpt-4o-mini |
| Case Context: A doctor operates a website to provide information and services to patients and potential patients. However, the website lacks a privacy policy, which is necessary to inform users about how their personal data is collected, used, and protected. This omission means that users are not informed about the handling of their personal data when they visit the website. |
| Ground Truth: prohibited |
| DeepSeek-R1’s Structured Output : |
| { |