paname 0.0.1.dev0__tar.gz → 0.0.1.dev2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. paname-0.0.1.dev2/PKG-INFO +396 -0
  2. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/README.md +1 -5
  3. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/README_FR.md +1 -5
  4. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/pyproject.toml +26 -3
  5. paname-0.0.1.dev0/PKG-INFO +0 -226
  6. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/.gitignore +0 -0
  7. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/CHANGELOG.md +0 -0
  8. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/LICENSE +0 -0
  9. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/LICENSES/CC0-1.0.txt +0 -0
  10. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/LICENSES/MIT.txt +0 -0
  11. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/paname_use_cases/apertus70b_canaries.py +0 -0
  12. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/paname_use_cases/bert_wnut.py +0 -0
  13. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/paname_use_cases/cifar10_mobilenet.py +0 -0
  14. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/paname_use_cases/discoverable_extraction_wikipedia.py +0 -0
  15. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/paname_use_cases/gpt2_imdb.py +0 -0
  16. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/paname_use_cases/gpt2_imdb_overfit.py +0 -0
  17. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/paname_use_cases/gpt2_wikitext.py +0 -0
  18. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/paname_use_cases/ministrallm_fineweb_gguf.py +0 -0
  19. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/paname_use_cases/ministrallm_fineweb_hf_lm.py +0 -0
  20. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/paname_use_cases/ministrallm_fineweb_vllm_offline.py +0 -0
  21. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/paname_use_cases/pleias1b_wtotext.py +0 -0
  22. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/paname_use_cases/pythia_mimir.py +0 -0
  23. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/paname_use_cases/random_forest_1m.py +0 -0
  24. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/paname_use_cases/resnet18_cifar10_shadow.py +0 -0
  25. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/paname_use_cases/sklearn_classifier_synthetic.py +0 -0
  26. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/paname_use_cases/sklearn_regressor_synthetic.py +0 -0
  27. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/paname_use_cases/utils/cifar10_helpers.py +0 -0
  28. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/paname_use_cases/utils/huggingface_text_helpers.py +0 -0
  29. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/paname_use_cases/utils/sklearn_helpers.py +0 -0
  30. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/__init__.py +0 -0
  31. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/config.py +0 -0
  32. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/extraction_techniques/__init__.py +0 -0
  33. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/extraction_techniques/configurable.py +0 -0
  34. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/extraction_techniques/discoverable_extraction/__init__.py +0 -0
  35. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/extraction_techniques/discoverable_extraction/evaluation.py +0 -0
  36. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/extraction_techniques/discoverable_extraction/metrics.py +0 -0
  37. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/extraction_techniques/mia/__init__.py +0 -0
  38. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/extraction_techniques/mia/attack_model.py +0 -0
  39. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/extraction_techniques/mia/base.py +0 -0
  40. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/extraction_techniques/mia/gradient.py +0 -0
  41. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/extraction_techniques/mia/hop_skip_jump.py +0 -0
  42. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/extraction_techniques/mia/likelihood_ratio.py +0 -0
  43. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/extraction_techniques/mia/lira.py +0 -0
  44. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/extraction_techniques/mia/loss.py +0 -0
  45. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/extraction_techniques/mia/min_k_prob.py +0 -0
  46. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/extraction_techniques/mia/neighborhood.py +0 -0
  47. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/extraction_techniques/mia/noise_label_only.py +0 -0
  48. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/extraction_techniques/mia/perplexity.py +0 -0
  49. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/extraction_techniques/mia/reference_based.py +0 -0
  50. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/extraction_techniques/mia/rmia.py +0 -0
  51. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/extraction_techniques/mia/shadow_model_pool/__init__.py +0 -0
  52. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/extraction_techniques/mia/shadow_model_pool/base.py +0 -0
  53. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/extraction_techniques/mia/shadow_model_pool/local_model.py +0 -0
  54. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/extraction_techniques/mia/zlib.py +0 -0
  55. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/extraction_techniques/reconstruction/__init__.py +0 -0
  56. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/extraction_techniques/reconstruction/base.py +0 -0
  57. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/extraction_techniques/reconstruction/diffusion_clique.py +0 -0
  58. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/extraction_techniques/reconstruction/informed_adversary.py +0 -0
  59. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/extraction_techniques/reconstruction/llm_from_sampling.py +0 -0
  60. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/extraction_techniques/reconstruction/utils.py +0 -0
  61. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/io/__init__.py +0 -0
  62. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/io/dataset.py +0 -0
  63. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/io/huggingface.py +0 -0
  64. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/io/sklearn.py +0 -0
  65. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/io/torch.py +0 -0
  66. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/metrics/__init__.py +0 -0
  67. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/metrics/base.py +0 -0
  68. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/metrics/metrics.py +0 -0
  69. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/metrics/mia.py +0 -0
  70. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/metrics/reconstruction.py +0 -0
  71. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/mia_runner.py +0 -0
  72. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/perturbators/__init__.py +0 -0
  73. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/perturbators/base.py +0 -0
  74. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/perturbators/gaussian.py +0 -0
  75. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/perturbators/hsja.py +0 -0
  76. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/perturbators/text_neighbors.py +0 -0
  77. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/py.typed +0 -0
  78. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/reporting/__init__.py +0 -0
  79. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/reporting/lang.py +0 -0
  80. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/reporting/report.py +0 -0
  81. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/scripts/__init__.py +0 -0
  82. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/scripts/discoverable_extraction.py +0 -0
  83. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/scripts/mia.py +0 -0
  84. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/scripts/reconstruction.py +0 -0
  85. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/signal_extraction/__init__.py +0 -0
  86. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/signal_extraction/extractors.py +0 -0
  87. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/signal_extraction/model_wrappers/__init__.py +0 -0
  88. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/signal_extraction/model_wrappers/base.py +0 -0
  89. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/signal_extraction/model_wrappers/gguf_lm.py +0 -0
  90. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/signal_extraction/model_wrappers/huggingface_base.py +0 -0
  91. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/signal_extraction/model_wrappers/huggingface_diffusers.py +0 -0
  92. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/signal_extraction/model_wrappers/huggingface_lm.py +0 -0
  93. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/signal_extraction/model_wrappers/huggingface_text_utils.py +0 -0
  94. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/signal_extraction/model_wrappers/huggingface_token_classification.py +0 -0
  95. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/signal_extraction/model_wrappers/online_api_lm.py +0 -0
  96. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/signal_extraction/model_wrappers/onnx.py +0 -0
  97. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/signal_extraction/model_wrappers/sklearn.py +0 -0
  98. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/signal_extraction/model_wrappers/text_generation_utils.py +0 -0
  99. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/signal_extraction/model_wrappers/text_sampling.py +0 -0
  100. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/signal_extraction/model_wrappers/torch_classifier.py +0 -0
  101. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/signal_extraction/model_wrappers/vllm_offline_lm.py +0 -0
  102. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/signal_extraction/utils/__init__.py +0 -0
  103. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/signal_extraction/utils/process_logprobs.py +0 -0
  104. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/signal_extraction/utils/signal_transformations.py +0 -0
  105. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/typing.py +0 -0
  106. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/use_case.py +0 -0
  107. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/utils/__init__.py +0 -0
  108. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/utils/device.py +0 -0
  109. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/utils/gradient_estimation.py +0 -0
  110. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/utils/lp.py +0 -0
  111. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/utils/resampling.py +0 -0
  112. {paname-0.0.1.dev0 → paname-0.0.1.dev2}/src/paname/utils/seeding.py +0 -0
@@ -0,0 +1,396 @@
1
+ Metadata-Version: 2.5
2
+ Name: paname
3
+ Version: 0.0.1-dev2
4
+ Summary: Assess self-conformity of ML models by running extraction techniques.
5
+ Author: ANSSI, CNIL, Inria
6
+ Author-email: "Pôle d'Expertise de la Régulation Numérique (PEReN)" <contact@peren.gouv.fr>
7
+ License-Expression: MIT
8
+ License-File: LICENSES/CC0-1.0.txt
9
+ License-File: LICENSES/MIT.txt
10
+ Requires-Python: >=3.11
11
+ Requires-Dist: accelerate>=1.12.0
12
+ Requires-Dist: certifi>=2026.10.19
13
+ Requires-Dist: datasets>=4.4.1
14
+ Requires-Dist: matplotlib>=3.10.7
15
+ Requires-Dist: networkx>=3.0
16
+ Requires-Dist: numpy>=2.0.2
17
+ Requires-Dist: openai>=2.29.0
18
+ Requires-Dist: pandas>=2.3.3
19
+ Requires-Dist: platformdirs>=4.9.6
20
+ Requires-Dist: protobuf>=6.33.5
21
+ Requires-Dist: pydantic-settings>=2.12.0
22
+ Requires-Dist: pydantic>=2.12.5
23
+ Requires-Dist: rapidfuzz>=3.0.0
24
+ Requires-Dist: requests>=2.33.1
25
+ Requires-Dist: scikit-learn>=1.7.2
26
+ Requires-Dist: seaborn>=0.13.2
27
+ Requires-Dist: sentencepiece>=0.2.1
28
+ Requires-Dist: torch>=2.10.0
29
+ Requires-Dist: torchvision>=0.25
30
+ Requires-Dist: transformers>=4.45.0
31
+ Requires-Dist: tyro>=1.0.11
32
+ Provides-Extra: diffusion
33
+ Requires-Dist: diffusers>=0.40.0; extra == 'diffusion'
34
+ Provides-Extra: gguf-llm
35
+ Requires-Dist: llama-cpp-python<0.3.26,>=0.3.18; extra == 'gguf-llm'
36
+ Provides-Extra: onnx-cpu
37
+ Requires-Dist: onnx2pytorch>=0.5.3; extra == 'onnx-cpu'
38
+ Requires-Dist: onnx>=1.15.0; extra == 'onnx-cpu'
39
+ Requires-Dist: onnxruntime>=1.15.0; extra == 'onnx-cpu'
40
+ Requires-Dist: onnxscript>=0.7.0; extra == 'onnx-cpu'
41
+ Provides-Extra: onnx-gpu
42
+ Requires-Dist: onnx2pytorch>=0.5.3; extra == 'onnx-gpu'
43
+ Requires-Dist: onnx>=1.15.0; extra == 'onnx-gpu'
44
+ Requires-Dist: onnxruntime-gpu>=1.15.0; (sys_platform != 'darwin') and extra == 'onnx-gpu'
45
+ Requires-Dist: onnxscript>=0.7.0; extra == 'onnx-gpu'
46
+ Provides-Extra: vllm-llm
47
+ Requires-Dist: vllm>=0.18.0; (sys_platform != 'darwin') and extra == 'vllm-llm'
48
+ Description-Content-Type: text/markdown
49
+
50
+ <!--
51
+ # SPDX-FileCopyrightText: 2026 PANAME Consortium (ANSSI, CNIL, Inria and PEReN)
52
+ #
53
+ # SPDX-License-Identifier: MIT
54
+ -->
55
+
56
+ <p align="center">
57
+ <picture>
58
+ <source media="(prefers-color-scheme: dark)" srcset="https://github.com/paname-lib/paname/tree/main/assets/logo/Paname_baseline_rvb_dark.svg">
59
+ <img src="https://github.com/paname-lib/paname/tree/main/assets/logo/Paname_baseline_rvb.svg" alt="PANAME Logo" width="600">
60
+ </picture>
61
+ </p>
62
+
63
+ <h1 align="center">PANAME : Privacy Auditing of AI Models</h1>
64
+
65
+
66
+ <p align="right"><strong><a href="README_FR.md">Lire en français</a></strong></p>
67
+
68
+ # Overview
69
+
70
+ PANAME aims to facilitate the assessment of AI models' compliance with the GDPR by aggregating and standardizing the implementation of extraction techniques used to evaluate the memorization of personal data.
71
+
72
+ To this end, the library is designed to:
73
+
74
+ - define and implement abstractions that factor out the implementation of the various extraction techniques;
75
+ - make it easier and cheaper to run extraction techniques on production AI models;
76
+ - enable the contribution and standardization of new extraction techniques from the academic community.
77
+
78
+ In practice, extraction techniques fall into 3 categories:
79
+
80
+ - **Membership Inference Attacks (MIA)**: guess whether a sample was present in the training data (binary classification).
81
+ - **Attribute Inference Attacks (AIA)**: infer information about a potentially sensitive data column (*not yet implemented*).
82
+ - **Reconstruction Attacks (RA)**: reconstruct training samples.
83
+
84
+ These extraction techniques require varying degrees of prior knowledge (*priors*) and of access to the training data and the AI model, which is referred to as the **Threat Model**.
85
+ The performance of extraction techniques can vary depending on the Threat Model, which can help guide mitigation mechanisms in AI systems.
86
+
87
+ An introductory note on the theory of extraction testing is available in the [documentation](https://github.com/paname-lib/paname/tree/main/docs/source/theory.rst).
88
+
89
+ ## Context
90
+
91
+ **According to [EDPB Opinion 28/2024 of 17/12/2024](https://www.edpb.europa.eu/our-work-tools/our-documents/opinion-board-art-64/opinion-282024-certain-data-protection-aspects_en) and [the CNIL's practical guidance sheets](https://www.cnil.fr/fr/ia-analyser-le-statut-dun-modele-dia-au-regard-du-rgpd):**
92
+
93
+ * AI models trained on personal data cannot, in all cases, be considered anonymous.
94
+ * In most cases, an assessment must be carried out if the controller wishes to conclude that its model is anonymous.
95
+ * In practice, this assessment must take into account the means reasonably likely to be used to re-identify personal data, which may include extraction techniques such as:
96
+ * Membership Inference Attacks;
97
+ * Attribute Inference Attacks;
98
+ * Reconstruction Attacks.
99
+ * The level of testing to consider may depend on the context in which the AI model is developed and deployed.
100
+
101
+ # Installation
102
+
103
+ Clone the repository and access the project:
104
+
105
+ ```bash
106
+ git clone https://github.com/paname-lib/paname.git
107
+ cd paname
108
+ ```
109
+
110
+ To install the project's dependencies with the `uv` package and project manager (v0.13.4):
111
+
112
+ ```bash
113
+ uv sync
114
+ ```
115
+
116
+ To install the dependencies needed for contributing (linting, documentation generation, etc.), add: `--dev --group docs`
117
+
118
+ ## Special case for ONNX models
119
+
120
+ To run the use cases relying on ONNX, install the appropriate extra:
121
+ - `uv sync --extra onnx-cpu` (for CPU inference)
122
+ - `uv sync --extra onnx-gpu` (for GPU inference with CUDA, ⚠️ **unavailable** on macOS)
123
+
124
+ ## Special case for diffusion attacks
125
+
126
+ To work with the diffusion use cases, you need to sync and run the tests with the `--extra diffusion` option:
127
+
128
+ ```bash
129
+ uv sync --extra diffusion
130
+ ```
131
+
132
+ ## Special case for LLM inference engines
133
+
134
+ There are 4 implementations for LLM inference in PANAME:
135
+
136
+ - `transformers` (built on `torch`), installed by default;
137
+ - "OpenAI-compatible" APIs, also installed by default;
138
+ - GGUF models via llama.cpp: must be installed manually with `--extra gguf-llm` (to install a GPU-enabled build of llama.cpp, use the build flag `CMAKE_ARGS="-DGGML_CUDA=ON"`);
139
+ - models instantiated via vLLM in "offline inference" mode (not as an API, ⚠️ **unavailable** on macOS and on CPU): this also requires installing with `--extra vllm-llm`.
140
+
141
+ ## Development environment with a container
142
+
143
+ A Dockerfile is provided to reproduce the development environment (Python 3.11, uv 0.13.4) :
144
+
145
+ ```bash
146
+ docker build -t paname . # or podman
147
+ docker container run -it --rm paname:latest
148
+ ```
149
+
150
+ # Tests
151
+
152
+ The test suite is documented in [`CONTRIBUTING.md`](https://github.com/paname-lib/paname/tree/main/CONTRIBUTING.md). For a quick
153
+ verification of an end-user install:
154
+
155
+ ```bash
156
+ uv run poe test-fast # tests that do not call Hugging Face; suitable for CPU configurations
157
+ uv run poe test-all # all tests, which is only possible with CUDA because of the dependencies
158
+ ```
159
+
160
+ # Usage examples
161
+
162
+ ## Notebooks
163
+
164
+ Notebooks to get started with the library are available in the `examples/cookbook/` folder.
165
+
166
+ These notebooks aim to give developers a first idea of what can be done with **PANAME**. They are progressive tutorials for mastering the library and its abstractions.
167
+
168
+ The following notebooks explain how to build use cases, adapters (wrappers) and run extractions with PANAME:
169
+ - [`1.mia_getting_started.ipynb`](https://github.com/paname-lib/paname/tree/main/examples/cookbook/1.mia_getting_started.ipynb): getting started with MIAs — loading data, training models and running a basic membership inference audit.
170
+ - [`2.mia_CLM_w_precomputed_workflow.ipynb`](https://github.com/paname-lib/paname/tree/main/examples/cookbook/2.mia_CLM_w_precomputed_workflow.ipynb): runs MIAs on an overfitted GPT-2 model using a precomputed reference signal.
171
+ - [`2bis.mia_w_various_CLM_wrappers.ipynb`](https://github.com/paname-lib/paname/tree/main/examples/cookbook/2bis.mia_w_various_CLM_wrappers.ipynb): applies the same MIA to an LLM served through different back-ends — a Hugging Face model, an OpenAI-compatible API via vLLM, a GGUF model via llama.cpp and vLLM offline — showing that only the wrapper changes while the rest of the pipeline stays identical.
172
+ - [`3.mia_torchclassifier_w_shadow_models.ipynb`](https://github.com/paname-lib/paname/tree/main/examples/cookbook/3.mia_torchclassifier_w_shadow_models.ipynb): runs a shadow-model attack on a torch-based image classifier.
173
+ - [`4.mia_w_custom_wrapper.ipynb`](https://github.com/paname-lib/paname/tree/main/examples/cookbook/4.mia_w_custom_wrapper.ipynb): shows how to build a custom wrapper to connect a model's signals to compatible attacks.
174
+ - [`5.mia_evaluation_dataset_best_practices.ipynb`](https://github.com/paname-lib/paname/tree/main/examples/cookbook/5.mia_evaluation_dataset_best_practices.ipynb): best practices for building an MIA evaluation dataset (evaluation regimes, biases, …).
175
+ - [`6.mia_w_label_only_hopskip.ipynb`](https://github.com/paname-lib/paname/tree/main/examples/cookbook/6.mia_w_label_only_hopskip.ipynb): label-only membership inference with the HopSkipJump attack.
176
+ - [`7.reconstruction_diffusion_carlini2023.ipynb`](https://github.com/paname-lib/paname/tree/main/examples/cookbook/7.reconstruction_diffusion_carlini2023.ipynb): extracts training images from a text-to-image diffusion model (Carlini et al., 2023) by generating many candidates per prompt and keeping those that form clusters of near-duplicates; the reconstructions are evaluated against the memorized images (requires `--extra diffusion`).
177
+ - [`8.discoverable_extraction.ipynb`](https://github.com/paname-lib/paname/tree/main/examples/cookbook/8.discoverable_extraction.ipynb): generates `(n, p)`-discoverable extraction curves for a local Hugging Face model.
178
+
179
+ A few extra, unlisted scripts and notebooks live in [`examples/others/`](https://github.com/paname-lib/paname/tree/main/examples/others/). They are not part of the numbered tutorial series.
180
+
181
+ ## Registered use cases
182
+
183
+ The [`paname_use_cases`](https://github.com/paname-lib/paname/tree/main/paname_use_cases/) folder offers examples of what needs to be implemented to run membership inference attacks on a given target model + dataset pair, in the `PanameUseCase` format defined in the script `src/paname/use_case.py`.
184
+
185
+ > [!warning]
186
+ > ⚠️ The models and datasets referenced by the `paname_use_cases` use cases are not redistributed with PANAME; they are downloaded from their original sources at run time. They remain subject to their own licensing terms, held by their respective rights holders, which take precedence over the repository's MIT license. Check their original license before use.
187
+
188
+ To run the `Loss` MIA on the pre-registered `SKLEARN_CLASSIFIER_SYNTHETIC` use case, run:
189
+
190
+ ```bash
191
+ uv run paname mia run --use-case-name SKLEARN_CLASSIFIER_SYNTHETIC --mias Loss
192
+ ```
193
+
194
+ You can override the constructor parameters of the extracted techniques through a
195
+ `--configs.<group>.*` clause (see `uv run paname <technique> run --help`):
196
+
197
+ ```bash
198
+ uv run paname mia run --use-case-name GPT2_WIKITEXT --mias Min-k-prob Perplexity \
199
+ --configs.min-k-prob.k 5
200
+ ```
201
+
202
+ > [!note]
203
+ > A MIA may require more than the audit dataset and the target model. For example a calibration dataset, or additional proxy models. MIA-PanameUseCase compatibility is currently left to the user.
204
+
205
+ > [!note]
206
+ > The CLI is organized by extraction technique — `mia`, `discoverable-extraction` and
207
+ > `reconstruction` — each exposing `list`, `run` and `use-cases` subcommands.
208
+ > Use `uv run paname --help` to explore them (the historical `run-mia` / `list-mias` /
209
+ > `list-use-cases` commands remain available).
210
+
211
+ # Consortium
212
+
213
+ PANAME is a joint project of ANSSI, CNIL, INRIA and PEReN.
214
+
215
+ # Acknowledgment
216
+
217
+ This work was (partially) funded by the National Research Agency under the France 2030 program, with the reference ANR-25-APEV-0001.
218
+
219
+ # License
220
+
221
+ This project is licensed under MIT. A full copy of the license
222
+ text can be found in the file [MIT.txt](https://github.com/paname-lib/paname/tree/main/LICENSES/MIT.txt).
223
+
224
+ <hr>
225
+ <!--
226
+ # SPDX-FileCopyrightText: 2026 PANAME Consortium (ANSSI, CNIL, Inria and PEReN)
227
+ #
228
+ # SPDX-License-Identifier: MIT
229
+ -->
230
+
231
+ <p align="center">
232
+ <picture>
233
+ <source media="(prefers-color-scheme: dark)" srcset="https://github.com/paname-lib/paname/tree/main/assets/logo/Paname_baseline_rvb_dark.svg">
234
+ <img src="https://github.com/paname-lib/paname/tree/main/assets/logo/Paname_baseline_rvb.svg" alt="PANAME Logo" width="600">
235
+ </picture>
236
+ </p>
237
+
238
+ <h1 align="center">PANAME : Privacy Auditing of AI Models</h1>
239
+
240
+
241
+ <p align="right"><strong><a href="README.md">Read in English</a></strong></p>
242
+
243
+ # Présentation
244
+
245
+ PANAME vise à faciliter l'évaluation de la conformité des modèles d'IA au RGPD, en agrégeant et en standardisant la mise en œuvre des techniques d'extraction pour évaluer la mémorisation de données personnelles.
246
+
247
+ À cette fin, la bibliothèque est conçue pour :
248
+
249
+ - définir et implémenter des abstractions visant à factoriser l'implémentation des différentes techniques d'extraction ;
250
+ - faciliter l'exécution de techniques d'extraction sur des modèles d'IA en production à moindre coût ;
251
+ - permettre la contribution et la standardisation de nouvelles techniques d'extraction provenant de la communauté académique.
252
+
253
+ En pratique, les techniques d'extraction sont segmentées en 3 types :
254
+
255
+ - **Attaques par inférence d'appartenance (*Membership Inference Attacks - MIA*)** : deviner si un échantillon était présent dans les données d'entraînement (classification binaire).
256
+ - **Attaques par inférence d'attributs (*Attribute Inference Attacks - AIA*)** : inférer des informations sur une colonne de données potentiellement sensibles (*pas encore implémentées*).
257
+ - **Attaques par reconstruction (*Reconstruction Attacks - RA*)** : reconstruire des échantillons d'entraînement.
258
+
259
+ Ces techniques d'extraction nécessitent plus ou moins de connaissances préalables (*priors*) et d'accès aux données d'entraînement ainsi qu'au modèle d'IA, ce que l'on appelle le **Modèle de Menace** (*Threat Model*).
260
+ La performance des techniques d'extraction peut varier en fonction du Modèle de Menace, ce qui peut aider à orienter les mécanismes d'atténuation (*mitigation*) dans les systèmes d'IA.
261
+
262
+ Une note d'introduction à la théorie des tests d'extraction est disponible dans la [documentation](https://github.com/paname-lib/paname/tree/main/docs/source/theory.rst).
263
+
264
+ ## Contexte
265
+
266
+ **Selon [l'avis 28/2024 du 17/12/2024 du CEPD](https://www.edpb.europa.eu/our-work-tools/our-documents/opinion-board-art-64/opinion-282024-certain-data-protection-aspects_en) et [les fiches pratiques de la CNIL](https://www.cnil.fr/fr/ia-analyser-le-statut-dun-modele-dia-au-regard-du-rgpd) :**
267
+
268
+ * Les modèles d’IA entraînés sur des données à caractère personnel ne peuvent pas, dans tous les cas, être considérés comme anonymes.
269
+ * Dans la plupart des cas, une évaluation doit être menée si le responsable du traitement souhaite conclure au caractère anonyme de son modèle.
270
+ * En pratique, cette évaluation doit s’appuyer sur les moyens raisonnablement susceptibles d’être utilisés pour réidentifier les données personnelles, ce qui peut inclure des techniques d’extraction telles que :
271
+ * les attaques par inférence d’appartenance (*Membership Inference Attacks*) ;
272
+ * les attaques par inférence d’attributs (*Attribute Inference Attacks*) ;
273
+ * les attaques par reconstruction (*Reconstruction Attacks*).
274
+ * Le niveau de tests à envisager peut dépendre du contexte de développement et de déploiement du modèle d’IA.
275
+
276
+ # Installation
277
+
278
+ Cloner le dépôt et accéder au projet :
279
+
280
+ ```bash
281
+ git clone https://github.com/paname-lib/paname.git
282
+ cd paname
283
+ ```
284
+
285
+ Pour installer les dépendances du projet avec le gestionnaire de paquets et de projets `uv` (v0.13.4) :
286
+
287
+ ```bash
288
+ uv sync
289
+ ```
290
+
291
+ Pour installer les dépendances nécessaires pour contribuer (analyse syntaxique, génération de la documentation, etc.), ajouter : `--dev --group docs`
292
+
293
+ ## Cas particulier pour les modèles ONNX
294
+
295
+ Pour exécuter les cas d'utilisation reposant sur ONNX, installez l'extra approprié :
296
+ - `uv sync --extra onnx-cpu` (pour l'inférence CPU)
297
+ - `uv sync --extra onnx-gpu` (pour l'inférence GPU avec CUDA, ⚠️ **indisponible** sur macOS)
298
+
299
+ ## Cas particulier pour les attaques de diffusion
300
+
301
+ Pour travailler avec les cas d'utilisation de diffusion, vous devrez synchroniser et exécuter les tests à l'aide de l'option `--extra diffusion` :
302
+
303
+ ```bash
304
+ uv sync --extra diffusion
305
+ ```
306
+
307
+ ## Cas particulier des moteurs d'inférence de LLM
308
+
309
+ Il y a 4 implémentations pour l'inférence de LLM dans PANAME :
310
+
311
+ - `transformers` (repose sur `torch`), installée par défaut ;
312
+ - des API « compatibles OpenAI », également installées par défaut ;
313
+ - des modèles au format GGUF via llama.cpp : il faut installer manuellement avec `--extra gguf-llm` (pour installer une version de llama.cpp compatible GPU, il faut le _build flag_ `CMAKE_ARGS="-DGGML_CUDA=ON"`) ;
314
+ - des modèles instanciés via vLLM en « offline inference » (non en API, ⚠️ **indisponible** sur macOS et sur CPU) : là aussi il faut installer avec `--extra vllm-llm`.
315
+
316
+ ## Environnement de développement avec un conteneur
317
+
318
+ Un Dockerfile est fourni pour reproduire l'environnement de développement (Python 3.11, uv 0.13.4) :
319
+
320
+ ```bash
321
+ docker build -t paname . # or podman
322
+ docker container run -it --rm paname:latest
323
+ ```
324
+
325
+ # Tests
326
+
327
+ La suite de tests est documentée dans [`CONTRIBUTING.md`](https://github.com/paname-lib/paname/tree/main/CONTRIBUTING.md). Pour une
328
+ vérification rapide d'une installation :
329
+
330
+ ```bash
331
+ uv run poe test-fast # exécute les tests qui ne font pas appel à Hugging Face ; adapté aux configurations CPU
332
+ uv run poe test-all # exécute tous les tests, ce qui n'est possible qu'avec CUDA en raison des dépendances
333
+ ```
334
+
335
+ # Exemples d'utilisation
336
+
337
+ ## Notebooks
338
+
339
+ Des notebooks de prise en main de la bibliothèque sont disponibles dans le dossier `examples/cookbook/`.
340
+
341
+ L’objectif de ces notebooks est de donner aux développeurs une première idée de ce qu’il est possible de faire avec **PANAME**. Ils consistent en des tutoriels progressifs pour bien maîtriser la bibliothèque et ses abstractions.
342
+
343
+ Les notebooks suivants expliquent comment construire des cas d’usage, des adaptateurs (wrappers) et lancer des extractions avec PANAME :
344
+ - [`1.mia_getting_started.ipynb`](https://github.com/paname-lib/paname/tree/main/examples/cookbook/1.mia_getting_started.ipynb) : prise en main des MIA : chargement de données, entraînement de modèles et lancement d’un audit d’inférence d’appartenance de base.
345
+ - [`2.mia_CLM_w_precomputed_workflow.ipynb`](https://github.com/paname-lib/paname/tree/main/examples/cookbook/2.mia_CLM_w_precomputed_workflow.ipynb) : exécute des MIA sur un modèle GPT-2 surentraîné en utilisant un signal de référence pré-calculé.
346
+ - [`2bis.mia_w_various_CLM_wrappers.ipynb`](https://github.com/paname-lib/paname/tree/main/examples/cookbook/2bis.mia_w_various_CLM_wrappers.ipynb) : applique la même MIA sur un LLM servi via différents back-ends — un modèle Hugging Face, une API compatible OpenAI via vLLM, un modèle GGUF via llama.cpp et vLLM hors-ligne — en montrant que seul le wrapper change alors que le reste du pipeline reste identique.
347
+ - [`3.mia_torchclassifier_w_shadow_models.ipynb`](https://github.com/paname-lib/paname/tree/main/examples/cookbook/3.mia_torchclassifier_w_shadow_models.ipynb) : exécute une attaque par modèles fantômes (shadow models) sur un classifieur d’images basé sur torch.
348
+ - [`4.mia_w_custom_wrapper.ipynb`](https://github.com/paname-lib/paname/tree/main/examples/cookbook/4.mia_w_custom_wrapper.ipynb) : montre comment construire un wrapper personnalisé pour connecter les signaux d’un modèle aux attaques compatibles.
349
+ - [`5.mia_evaluation_dataset_best_practices.ipynb`](https://github.com/paname-lib/paname/tree/main/examples/cookbook/5.mia_evaluation_dataset_best_practices.ipynb) : bonnes pratiques pour construire un jeu de données d’évaluation MIA (régimes d’évaluation, biais, …).
350
+ - [`6.mia_w_label_only_hopskip.ipynb`](https://github.com/paname-lib/paname/tree/main/examples/cookbook/6.mia_w_label_only_hopskip.ipynb) : inférence d’appartenance *label-only* avec l’attaque HopSkipJump.
351
+ - [`7.reconstruction_diffusion_carlini2023.ipynb`](https://github.com/paname-lib/paname/tree/main/examples/cookbook/7.reconstruction_diffusion_carlini2023.ipynb) : extrait des images d'entraînement d'un modèle de diffusion texte-vers-image (technique de Carlini et al., 2023) en générant de nombreux candidats par prompt puis en filtrant ceux qui forment des groupes de quasi-doublons ; les reconstructions sont évaluées contre les images mémorisées (nécessite `--extra diffusion`).
352
+ - [`8.discoverable_extraction.ipynb`](https://github.com/paname-lib/paname/tree/main/examples/cookbook/8.discoverable_extraction.ipynb) : génère les courbes d’extraction découvrable `(n, p)` pour un modèle Hugging Face local.
353
+ Quelques scripts et notebooks supplémentaires non listés ci-dessus se trouvent dans [`examples/others/`](https://github.com/paname-lib/paname/tree/main/examples/others/). Ils ne font pas partie de la série de didacticiels numérotés.
354
+
355
+ ## Cas d'usage enregistrés
356
+
357
+ Le dossier [`paname_use_cases`](https://github.com/paname-lib/paname/tree/main/paname_use_cases/) propose des exemples de ce qu’il faut implémenter pour exécuter des attaques par inférence d’appartenance sur un couple modèle cible et jeu de données, au format `PanameUseCase` défini dans le script `src/paname/use_case.py`.
358
+
359
+ > [!warning]
360
+ > ⚠️ Les modèles et jeux de données référencés par les cas d'usage de `paname_use_cases` ne sont pas redistribués avec PANAME ; ils sont téléchargés depuis leurs sources d'origine à l'exécution. Ils restent soumis à leurs propres conditions de licence, détenues par leurs ayants droit respectifs, qui priment sur la licence MIT du dépôt. Vérifiez leur licence d'origine avant toute utilisation.
361
+
362
+ Pour exécuter l'attaque MIA `Loss` sur le cas d'usage pré-enregistré `SKLEARN_CLASSIFIER_SYNTHETIC`, exécutez :
363
+
364
+ ```bash
365
+ uv run paname mia run --use-case-name SKLEARN_CLASSIFIER_SYNTHETIC --mias Loss
366
+ ```
367
+
368
+ Vous pouvez personnaliser les paramètres constructeurs des techniques extraites au travers
369
+ d’une clause `--configs.<groupe>.*` (voir `uv run paname <technique> run --help`) :
370
+
371
+ ```bash
372
+ uv run paname mia run --use-case-name GPT2_WIKITEXT --mias Min-k-prob Perplexity \
373
+ --configs.min-k-prob.k 5
374
+ ```
375
+
376
+ > [!note]
377
+ > Une MIA peut nécessiter plus que le dataset d'audit et le modèle cible. Par exemple un dataset de calibration, ou des modèles proxy supplémentaires. La compatibilité MIA-PanameUseCase est pour l'instant laissée à la charge de l'utilisateur.
378
+
379
+ > [!note]
380
+ > La CLI est organisée par technique d'extraction — `mia`, `discoverable-extraction` et
381
+ > `reconstruction` — chacune disposant de sous-commandes `list`, `run` et `use-cases`.
382
+ > Utilisez `uv run paname --help` pour les découvrir (les anciennes commandes
383
+ > `run-mia` / `list-mias` / `list-use-cases` restent disponibles).
384
+
385
+ # Consortium
386
+
387
+ PANAME est un projet conjoint de l'ANSSI, la CNIL, l'INRIA et du PEReN.
388
+
389
+ # Remerciements
390
+
391
+ Ce travail a bénéficié d'une aide de l'État gérée par l'Agence Nationale de la Recherche au titre de France 2030 portant la référence ANR-25-APEV-0001
392
+
393
+ # Licence
394
+
395
+ Ce projet est sous licence MIT. Une copie intégrale du texte
396
+ de la licence se trouve dans le fichier [MIT.txt](https://github.com/paname-lib/paname/tree/main/LICENSES/MIT.txt).
@@ -16,10 +16,6 @@
16
16
 
17
17
  <p align="right"><strong><a href="README_FR.md">Lire en français</a></strong></p>
18
18
 
19
- <h2>Table of contents</h2>
20
-
21
- [[_TOC_]]
22
-
23
19
  # Overview
24
20
 
25
21
  PANAME aims to facilitate the assessment of AI models' compliance with the GDPR by aggregating and standardizing the implementation of extraction techniques used to evaluate the memorization of personal data.
@@ -58,7 +54,7 @@ An introductory note on the theory of extraction testing is available in the [do
58
54
  Clone the repository and access the project:
59
55
 
60
56
  ```bash
61
- git clone https://code.peren.gouv.fr/peren/2025-paname/paname.git
57
+ git clone https://github.com/paname-lib/paname.git
62
58
  cd paname
63
59
  ```
64
60
 
@@ -16,10 +16,6 @@
16
16
 
17
17
  <p align="right"><strong><a href="README.md">Read in English</a></strong></p>
18
18
 
19
- <h2>Sommaire</h2>
20
-
21
- [[_TOC_]]
22
-
23
19
  # Présentation
24
20
 
25
21
  PANAME vise à faciliter l'évaluation de la conformité des modèles d'IA au RGPD, en agrégeant et en standardisant la mise en œuvre des techniques d'extraction pour évaluer la mémorisation de données personnelles.
@@ -58,7 +54,7 @@ Une note d'introduction à la théorie des tests d'extraction est disponible dan
58
54
  Cloner le dépôt et accéder au projet :
59
55
 
60
56
  ```bash
61
- git clone https://code.peren.gouv.fr/peren/2025-paname/paname.git
57
+ git clone https://github.com/paname-lib/paname.git
62
58
  cd paname
63
59
  ```
64
60
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  [project]
6
6
  name = "paname"
7
- version = "0.0.1-dev"
7
+ version = "0.0.1-dev2"
8
8
  description = "Assess self-conformity of ML models by running extraction techniques."
9
9
  authors = [
10
10
  { name = "ANSSI" },
@@ -14,7 +14,8 @@ authors = [
14
14
  ]
15
15
  license = "MIT"
16
16
  license-files = ["LICENSES/*"]
17
- readme = "README.md"
17
+ #readme = "README.md"
18
+ dynamic = ["readme"]
18
19
  requires-python = ">=3.11"
19
20
 
20
21
  dependencies = [
@@ -136,7 +137,7 @@ conflicts = [
136
137
  paname = "paname.scripts:main"
137
138
 
138
139
  [build-system]
139
- requires = ["hatchling"]
140
+ requires = ["hatchling", "hatch-fancy-pypi-readme"]
140
141
  build-backend = "hatchling.build"
141
142
 
142
143
  [tool.hatch.build.targets.wheel]
@@ -157,6 +158,28 @@ only-include = [
157
158
  "LICENSES/",
158
159
  ]
159
160
 
161
+ [tool.hatch.metadata.hooks.fancy-pypi-readme]
162
+ content-type = "text/markdown"
163
+
164
+ [[tool.hatch.metadata.hooks.fancy-pypi-readme.substitutions]]
165
+ # Literal TOML strings (single quotes) need no escaping of backslashes.
166
+ pattern = '\[(.+?)\]\(((?!https?://)\S+?)\)'
167
+ replacement = '[\1](https://github.com/paname-lib/paname/tree/main/\g<2>)'
168
+
169
+ [[tool.hatch.metadata.hooks.fancy-pypi-readme.substitutions]]
170
+ # image assets from relative to absolute paths
171
+ pattern = '(srcset|src)="((?!https?://)\S+?)"'
172
+ replacement = '\1="https://github.com/paname-lib/paname/tree/main/\g<2>"'
173
+
174
+ [[tool.hatch.metadata.hooks.fancy-pypi-readme.fragments]]
175
+ path = "README.md"
176
+
177
+ [[tool.hatch.metadata.hooks.fancy-pypi-readme.fragments]]
178
+ text = "\n<hr>\n"
179
+
180
+ [[tool.hatch.metadata.hooks.fancy-pypi-readme.fragments]]
181
+ path = "README_FR.md"
182
+
160
183
  [tool.poe.tasks]
161
184
  # Single source of truth for dev commands: `uv run poe <task>` (`uv run poe` lists them).
162
185
  # Extra arguments are forwarded, e.g. `uv run poe test-fast -k lira`.
@@ -1,226 +0,0 @@
1
- Metadata-Version: 2.5
2
- Name: paname
3
- Version: 0.0.1-dev
4
- Summary: Assess self-conformity of ML models by running extraction techniques.
5
- Author: ANSSI, CNIL, Inria
6
- Author-email: "Pôle d'Expertise de la Régulation Numérique (PEReN)" <contact@peren.gouv.fr>
7
- License-Expression: MIT
8
- License-File: LICENSES/CC0-1.0.txt
9
- License-File: LICENSES/MIT.txt
10
- Requires-Python: >=3.11
11
- Requires-Dist: accelerate>=1.12.0
12
- Requires-Dist: certifi>=2026.10.19
13
- Requires-Dist: datasets>=4.4.1
14
- Requires-Dist: matplotlib>=3.10.7
15
- Requires-Dist: networkx>=3.0
16
- Requires-Dist: numpy>=2.0.2
17
- Requires-Dist: openai>=2.29.0
18
- Requires-Dist: pandas>=2.3.3
19
- Requires-Dist: platformdirs>=4.9.6
20
- Requires-Dist: protobuf>=6.33.5
21
- Requires-Dist: pydantic-settings>=2.12.0
22
- Requires-Dist: pydantic>=2.12.5
23
- Requires-Dist: rapidfuzz>=3.0.0
24
- Requires-Dist: requests>=2.33.1
25
- Requires-Dist: scikit-learn>=1.7.2
26
- Requires-Dist: seaborn>=0.13.2
27
- Requires-Dist: sentencepiece>=0.2.1
28
- Requires-Dist: torch>=2.10.0
29
- Requires-Dist: torchvision>=0.25
30
- Requires-Dist: transformers>=4.45.0
31
- Requires-Dist: tyro>=1.0.11
32
- Provides-Extra: diffusion
33
- Requires-Dist: diffusers>=0.40.0; extra == 'diffusion'
34
- Provides-Extra: gguf-llm
35
- Requires-Dist: llama-cpp-python<0.3.26,>=0.3.18; extra == 'gguf-llm'
36
- Provides-Extra: onnx-cpu
37
- Requires-Dist: onnx2pytorch>=0.5.3; extra == 'onnx-cpu'
38
- Requires-Dist: onnx>=1.15.0; extra == 'onnx-cpu'
39
- Requires-Dist: onnxruntime>=1.15.0; extra == 'onnx-cpu'
40
- Requires-Dist: onnxscript>=0.7.0; extra == 'onnx-cpu'
41
- Provides-Extra: onnx-gpu
42
- Requires-Dist: onnx2pytorch>=0.5.3; extra == 'onnx-gpu'
43
- Requires-Dist: onnx>=1.15.0; extra == 'onnx-gpu'
44
- Requires-Dist: onnxruntime-gpu>=1.15.0; (sys_platform != 'darwin') and extra == 'onnx-gpu'
45
- Requires-Dist: onnxscript>=0.7.0; extra == 'onnx-gpu'
46
- Provides-Extra: vllm-llm
47
- Requires-Dist: vllm>=0.18.0; (sys_platform != 'darwin') and extra == 'vllm-llm'
48
- Description-Content-Type: text/markdown
49
-
50
- <!--
51
- # SPDX-FileCopyrightText: 2026 PANAME Consortium (ANSSI, CNIL, Inria and PEReN)
52
- #
53
- # SPDX-License-Identifier: MIT
54
- -->
55
-
56
- <p align="center">
57
- <picture>
58
- <source media="(prefers-color-scheme: dark)" srcset="assets/logo/Paname_baseline_rvb_dark.svg">
59
- <img src="assets/logo/Paname_baseline_rvb.svg" alt="PANAME Logo" width="600">
60
- </picture>
61
- </p>
62
-
63
- <h1 align="center">PANAME : Privacy Auditing of AI Models</h1>
64
-
65
-
66
- <p align="right"><strong><a href="README_FR.md">Lire en français</a></strong></p>
67
-
68
- <h2>Table of contents</h2>
69
-
70
- [[_TOC_]]
71
-
72
- # Overview
73
-
74
- PANAME aims to facilitate the assessment of AI models' compliance with the GDPR by aggregating and standardizing the implementation of extraction techniques used to evaluate the memorization of personal data.
75
-
76
- To this end, the library is designed to:
77
-
78
- - define and implement abstractions that factor out the implementation of the various extraction techniques;
79
- - make it easier and cheaper to run extraction techniques on production AI models;
80
- - enable the contribution and standardization of new extraction techniques from the academic community.
81
-
82
- In practice, extraction techniques fall into 3 categories:
83
-
84
- - **Membership Inference Attacks (MIA)**: guess whether a sample was present in the training data (binary classification).
85
- - **Attribute Inference Attacks (AIA)**: infer information about a potentially sensitive data column (*not yet implemented*).
86
- - **Reconstruction Attacks (RA)**: reconstruct training samples.
87
-
88
- These extraction techniques require varying degrees of prior knowledge (*priors*) and of access to the training data and the AI model, which is referred to as the **Threat Model**.
89
- The performance of extraction techniques can vary depending on the Threat Model, which can help guide mitigation mechanisms in AI systems.
90
-
91
- An introductory note on the theory of extraction testing is available in the [documentation](docs/source/theory.rst).
92
-
93
- ## Context
94
-
95
- **According to [EDPB Opinion 28/2024 of 17/12/2024](https://www.edpb.europa.eu/our-work-tools/our-documents/opinion-board-art-64/opinion-282024-certain-data-protection-aspects_en) and [the CNIL's practical guidance sheets](https://www.cnil.fr/fr/ia-analyser-le-statut-dun-modele-dia-au-regard-du-rgpd):**
96
-
97
- * AI models trained on personal data cannot, in all cases, be considered anonymous.
98
- * In most cases, an assessment must be carried out if the controller wishes to conclude that its model is anonymous.
99
- * In practice, this assessment must take into account the means reasonably likely to be used to re-identify personal data, which may include extraction techniques such as:
100
- * Membership Inference Attacks;
101
- * Attribute Inference Attacks;
102
- * Reconstruction Attacks.
103
- * The level of testing to consider may depend on the context in which the AI model is developed and deployed.
104
-
105
- # Installation
106
-
107
- Clone the repository and access the project:
108
-
109
- ```bash
110
- git clone https://code.peren.gouv.fr/peren/2025-paname/paname.git
111
- cd paname
112
- ```
113
-
114
- To install the project's dependencies with the `uv` package and project manager (v0.13.4):
115
-
116
- ```bash
117
- uv sync
118
- ```
119
-
120
- To install the dependencies needed for contributing (linting, documentation generation, etc.), add: `--dev --group docs`
121
-
122
- ## Special case for ONNX models
123
-
124
- To run the use cases relying on ONNX, install the appropriate extra:
125
- - `uv sync --extra onnx-cpu` (for CPU inference)
126
- - `uv sync --extra onnx-gpu` (for GPU inference with CUDA, ⚠️ **unavailable** on macOS)
127
-
128
- ## Special case for diffusion attacks
129
-
130
- To work with the diffusion use cases, you need to sync and run the tests with the `--extra diffusion` option:
131
-
132
- ```bash
133
- uv sync --extra diffusion
134
- ```
135
-
136
- ## Special case for LLM inference engines
137
-
138
- There are 4 implementations for LLM inference in PANAME:
139
-
140
- - `transformers` (built on `torch`), installed by default;
141
- - "OpenAI-compatible" APIs, also installed by default;
142
- - GGUF models via llama.cpp: must be installed manually with `--extra gguf-llm` (to install a GPU-enabled build of llama.cpp, use the build flag `CMAKE_ARGS="-DGGML_CUDA=ON"`);
143
- - models instantiated via vLLM in "offline inference" mode (not as an API, ⚠️ **unavailable** on macOS and on CPU): this also requires installing with `--extra vllm-llm`.
144
-
145
- ## Development environment with a container
146
-
147
- A Dockerfile is provided to reproduce the development environment (Python 3.11, uv 0.13.4) :
148
-
149
- ```bash
150
- docker build -t paname . # or podman
151
- docker container run -it --rm paname:latest
152
- ```
153
-
154
- # Tests
155
-
156
- The test suite is documented in [`CONTRIBUTING.md`](CONTRIBUTING.md). For a quick
157
- verification of an end-user install:
158
-
159
- ```bash
160
- uv run poe test-fast # tests that do not call Hugging Face; suitable for CPU configurations
161
- uv run poe test-all # all tests, which is only possible with CUDA because of the dependencies
162
- ```
163
-
164
- # Usage examples
165
-
166
- ## Notebooks
167
-
168
- Notebooks to get started with the library are available in the `examples/cookbook/` folder.
169
-
170
- These notebooks aim to give developers a first idea of what can be done with **PANAME**. They are progressive tutorials for mastering the library and its abstractions.
171
-
172
- The following notebooks explain how to build use cases, adapters (wrappers) and run extractions with PANAME:
173
- - [`1.mia_getting_started.ipynb`](examples/cookbook/1.mia_getting_started.ipynb): getting started with MIAs — loading data, training models and running a basic membership inference audit.
174
- - [`2.mia_CLM_w_precomputed_workflow.ipynb`](examples/cookbook/2.mia_CLM_w_precomputed_workflow.ipynb): runs MIAs on an overfitted GPT-2 model using a precomputed reference signal.
175
- - [`2bis.mia_w_various_CLM_wrappers.ipynb`](examples/cookbook/2bis.mia_w_various_CLM_wrappers.ipynb): applies the same MIA to an LLM served through different back-ends — a Hugging Face model, an OpenAI-compatible API via vLLM, a GGUF model via llama.cpp and vLLM offline — showing that only the wrapper changes while the rest of the pipeline stays identical.
176
- - [`3.mia_torchclassifier_w_shadow_models.ipynb`](examples/cookbook/3.mia_torchclassifier_w_shadow_models.ipynb): runs a shadow-model attack on a torch-based image classifier.
177
- - [`4.mia_w_custom_wrapper.ipynb`](examples/cookbook/4.mia_w_custom_wrapper.ipynb): shows how to build a custom wrapper to connect a model's signals to compatible attacks.
178
- - [`5.mia_evaluation_dataset_best_practices.ipynb`](examples/cookbook/5.mia_evaluation_dataset_best_practices.ipynb): best practices for building an MIA evaluation dataset (evaluation regimes, biases, …).
179
- - [`6.mia_w_label_only_hopskip.ipynb`](examples/cookbook/6.mia_w_label_only_hopskip.ipynb): label-only membership inference with the HopSkipJump attack.
180
- - [`7.reconstruction_diffusion_carlini2023.ipynb`](examples/cookbook/7.reconstruction_diffusion_carlini2023.ipynb): extracts training images from a text-to-image diffusion model (Carlini et al., 2023) by generating many candidates per prompt and keeping those that form clusters of near-duplicates; the reconstructions are evaluated against the memorized images (requires `--extra diffusion`).
181
- - [`8.discoverable_extraction.ipynb`](examples/cookbook/8.discoverable_extraction.ipynb): generates `(n, p)`-discoverable extraction curves for a local Hugging Face model.
182
-
183
- A few extra, unlisted scripts and notebooks live in [`examples/others/`](examples/others/). They are not part of the numbered tutorial series.
184
-
185
- ## Registered use cases
186
-
187
- The [`paname_use_cases`](paname_use_cases/) folder offers examples of what needs to be implemented to run membership inference attacks on a given target model + dataset pair, in the `PanameUseCase` format defined in the script `src/paname/use_case.py`.
188
-
189
- > [!warning]
190
- > ⚠️ The models and datasets referenced by the `paname_use_cases` use cases are not redistributed with PANAME; they are downloaded from their original sources at run time. They remain subject to their own licensing terms, held by their respective rights holders, which take precedence over the repository's MIT license. Check their original license before use.
191
-
192
- To run the `Loss` MIA on the pre-registered `SKLEARN_CLASSIFIER_SYNTHETIC` use case, run:
193
-
194
- ```bash
195
- uv run paname mia run --use-case-name SKLEARN_CLASSIFIER_SYNTHETIC --mias Loss
196
- ```
197
-
198
- You can override the constructor parameters of the extracted techniques through a
199
- `--configs.<group>.*` clause (see `uv run paname <technique> run --help`):
200
-
201
- ```bash
202
- uv run paname mia run --use-case-name GPT2_WIKITEXT --mias Min-k-prob Perplexity \
203
- --configs.min-k-prob.k 5
204
- ```
205
-
206
- > [!note]
207
- > A MIA may require more than the audit dataset and the target model. For example a calibration dataset, or additional proxy models. MIA-PanameUseCase compatibility is currently left to the user.
208
-
209
- > [!note]
210
- > The CLI is organized by extraction technique — `mia`, `discoverable-extraction` and
211
- > `reconstruction` — each exposing `list`, `run` and `use-cases` subcommands.
212
- > Use `uv run paname --help` to explore them (the historical `run-mia` / `list-mias` /
213
- > `list-use-cases` commands remain available).
214
-
215
- # Consortium
216
-
217
- PANAME is a joint project of ANSSI, CNIL, INRIA and PEReN.
218
-
219
- # Acknowledgment
220
-
221
- This work was (partially) funded by the National Research Agency under the France 2030 program, with the reference ANR-25-APEV-0001.
222
-
223
- # License
224
-
225
- This project is licensed under MIT. A full copy of the license
226
- text can be found in the file [MIT.txt](LICENSES/MIT.txt).
File without changes
File without changes
File without changes