Skip to main content

05 - GDPR and the AI Act: Privacy by Design for AI Systems

Where the GDPR and the AI Act meet: Article 25, automated decisions, impact assessments, logs and pseudonymisation measured with k-anonymity.

What do you think about this article?

05 - GDPR and the AI Act: Privacy by Design for AI Systems
AI Policy EUPhoto:Tara WinsteadPexels

At a Glance

Where the GDPR and the AI Act meet: Article 25, automated decisions, impact assessments, logs and pseudonymisation measured with k-anonymity.

Complying with the AI Act is not enough when the data is personal: where the two regulations meet

The GDPR and the AI Act have different objects. The first regulates the processing of personal data, regardless of the technology; the second regulates AI systems and models, regardless of whether they process personal data. A credit-scoring, CV-screening or triage system triggers both, and neither absorbs the other: the AI Act says so expressly, repeatedly, referring back to the GDPR, and at the points where the rules seem to be in tension (for example on the retention of logs) it defers to data protection law. The developer's job is to know where they overlap, because there a design choice serves two obligations.

This article starts from the obligation of data protection by design (Article 25 GDPR), lines up the points of contact with the AI Act, and shows with a runnable program what minimising means and how little pseudonymisation is enough. It is not legal advice: it says what the rules provide and where I read them. The general picture of the AI Act and its dates is in the first article; the previous article deals with the marking of generated content.

What Article 25 of the GDPR really asks

Article 25(1) requires the controller, both at the time of the determination of the means for processing and at the time of the processing itself, to implement appropriate technical and organisational measures, such as pseudonymisation, designed to implement data-protection principles, such as data minimisation, in an effective manner. Paragraph 2 adds protection "by default": by default only personal data which are necessary for each specific purpose of the processing are processed, and this applies to the amount of personal data collected, the extent of their processing, the period of their storage and their accessibility. The rule takes into account the state of the art, the cost of implementation, the nature, scope, context and purposes of processing and the risks for rights and freedoms.

The target is the principles of Article 5, and two matter more than the others for whoever works with models: purpose limitation (paragraph 1, point (b)) and data minimisation (point (c), data "adequate, relevant and limited to what is necessary"). Paragraph 2 of Article 5 adds accountability: the controller must be able to demonstrate compliance. There is no list of "six pillars" in the regulation: the measures are those you need to implement the principles, and how often and how deeply depends on the risk. An infringement of Article 25 falls in the tier of fines of up to EUR 10 000 000 or 2% of total worldwide annual turnover, whichever is higher (Article 83(4)); an infringement of the basic principles of Article 5 and of the data subjects' rights falls in the tier of up to EUR 20 000 000 or 4% (paragraph 5).

The five points where the GDPR and the AI Act touch

If you read the two texts in parallel, there are five points of contact. It is worth seeing them together, because at each one a design choice serves both regulations, or puts them in tension.

  • Training data. The AI Act, for high-risk systems, requires data governance practices that include the origin of the data and, for personal data, the original purpose of the data collection (Article 10(2), point (b)). The GDPR requires a legal basis (Article 6, and Article 9 for special categories) and compliance with purpose limitation and minimisation.
  • Sensitive data to correct bias. To detect and correct bias in high-risk systems, Article 4a of the AI Act (introduced by Regulation 2026/1744, which deleted the old Article 10(5)) allows providers to exceptionally process special categories of personal data, under the listed conditions.
  • Automated decisions. Article 22 of the GDPR gives the data subject the right not to be subject to a decision based solely on automated processing which produces legal effects concerning him or her or similarly significantly affects him or her; the AI Act requires human oversight (Article 14), informs the persons subject to decisions (Article 26(11)) and gives a right to explanation (Article 86).
  • Impact assessments. The data protection impact assessment (Article 35 GDPR) and the fundamental rights impact assessment of the AI Act (Article 27) are distinct, but Article 27(4) allows cross-references to the relevant sections of the DPIA, and Article 26(9) says that the deployer uses the information from the provider for the DPIA.
  • Log retention. The AI Act requires keeping logs for a period appropriate to the intended purpose, of at least six months, "unless provided otherwise in the applicable Union or national law, in particular in Union law on the protection of personal data" (Articles 19 and 26).

The useful reading is the direction of each point. In the first and the third the GDPR is the base and the AI Act adds obligations on the system; in the second the AI Act opens a door that the GDPR kept closed, under stringent conditions; in the fourth they are two documents to keep consistent; in the fifth the six-month minimum is subordinate to data protection, so a log full of personal data is not justified by that rule: the minimum duration does not cancel minimisation. None of the five gives you a duration or a numerical threshold beyond those cited.

Automated credit: Article 22 and the SCHUFA judgment

The most discussed case is credit. With its judgment of 7 December 2023 in Case C-634/21 (SCHUFA Holding), the Court of Justice held that the automated establishment, by a credit information agency, of a probability value concerning a person's ability to meet payment commitments in the future constitutes "automated individual decision-making" within the meaning of Article 22(1) where a third party, to which that probability value is transmitted, "draws strongly" on it to establish, implement or terminate a contractual relationship with that person. The consequence for whoever builds a scoring engine is that the score itself, not only the bank's final decision, can fall under Article 22.

Article 22 has exceptions (necessity for a contract, authorisation by law, explicit consent). In the contract and consent cases the controller must implement suitable measures, at least the right to obtain human intervention, to express one's point of view and to contest the decision (paragraph 3); in the case of law, the law itself must lay down suitable measures (paragraph 2, point (b)). This is exactly what the AI Act asks for in design form: an operator who can disregard, override or reverse the output (Article 14(4), point (d)) is the technical precondition of the right to human intervention. A "confirm" button that closes the case is not enough.

Minimising in practice: an example with synthetic data

Minimising means removing what the model must not see and generalising what it must see, without pretending that the data are anonymous. The following program works on eight invented rows. It applies three transformations: it replaces the tax code (the Italian codice fiscale) with a pseudonym computed with HMAC-SHA256 and a key kept apart, it reduces the age to a band and the postal code to its first three digits; then it measures k-anonymity with respect to the quasi-identifiers (age band and area).

"""Minimisation and pseudonymisation on synthetic data (Art. 25 GDPR).
No real data: the 8 rows are invented. 'tax_code' is an Italian codice fiscale (invented)."""
import hmac, hashlib
from collections import Counter

CHIAVE = b"key-kept-apart-from-the-data"   # in production: in a secrets manager, not in the code
RIGHE = [
    {"name": "Anna Rossi",  "tax_code": "RSSNNA85A41L219X", "age": 38, "postcode": "73100", "income": 31000, "outcome": 1},
    {"name": "Luca Bianchi", "tax_code": "BNCLCU90B12H501Y", "age": 34, "postcode": "73100", "income": 28000, "outcome": 0},
    {"name": "Sara Verdi",  "tax_code": "VRDSRA82C45F205Z", "age": 42, "postcode": "73100", "income": 45000, "outcome": 1},
    {"name": "Paolo Neri",  "tax_code": "NREPLA79D10L219W", "age": 45, "postcode": "73100", "income": 52000, "outcome": 1},
    {"name": "Gina Gialli", "tax_code": "GLLGNI95E50H501V", "age": 29, "postcode": "20121", "income": 22000, "outcome": 0},
    {"name": "Omar Blu",    "tax_code": "BLUMRO88F01F205U", "age": 36, "postcode": "20121", "income": 39000, "outcome": 1},
    {"name": "Rita Viola",  "tax_code": "VLIRTI70G41L219T", "age": 54, "postcode": "20121", "income": 61000, "outcome": 1},
    {"name": "Dino Grigi",  "tax_code": "GRGDNI93H10H501S", "age": 31, "postcode": "20121", "income": 26000, "outcome": 0},
]

def pseudonimo(valore):
    return hmac.new(CHIAVE, valore.encode(), hashlib.sha256).hexdigest()[:12]

def fascia_eta(eta):
    base = eta // 10 * 10
    return f"{base}-{base + 9}"

def minimizza(riga):
    return {
        "id": pseudonimo(riga["tax_code"]),     # linkable only with the key
        "age_band": fascia_eta(riga["age"]),    # no date of birth or exact age
        "area": riga["postcode"][:3],           # only the first three digits of the postcode
        "income": riga["income"],
        "outcome": riga["outcome"],
    }

def k_anonimato(righe, quasi_identificatori):
    gruppi = Counter(tuple(r[q] for q in quasi_identificatori) for r in righe)
    return min(gruppi.values()), gruppi

ridotte = [minimizza(r) for r in RIGHE]
print("fields before:", sorted(RIGHE[0]))
print("fields after :", sorted(ridotte[0]))
print("stable id    :", pseudonimo("RSSNNA85A41L219X") == ridotte[0]["id"])
k, gruppi = k_anonimato(ridotte, ["age_band", "area"])
print("k on the quasi-identifiers (age_band, area):", k)
for g, n in sorted(gruppi.items()):
    print("  ", g, n)

# Second generalisation: twenty-year bands and no area
def fascia_larga(eta):
    base = eta // 20 * 20
    return f"{base}-{base + 19}"

larghe = [{"age_band": fascia_larga(r["age"])} for r in RIGHE]
k2, gruppi2 = k_anonimato(larghe, ["age_band"])
print("k with twenty-year bands and no area:", k2)
for g, n in sorted(gruppi2.items()):
    print("  ", g, n)

# Output (python3 -I, Python 3.14.4):
# fields before: ['age', 'income', 'name', 'outcome', 'postcode', 'tax_code']
# fields after : ['age_band', 'area', 'id', 'income', 'outcome']
# stable id    : True
# k on the quasi-identifiers (age_band, area): 1
#    ('20-29', '201') 1
#    ('30-39', '201') 2
#    ('30-39', '731') 2
#    ('40-49', '731') 2
#    ('50-59', '201') 1
# k with twenty-year bands and no area: 3
#    ('20-39',) 5
#    ('40-59',) 3

The pseudonimo ("pseudonym") function is pseudonymisation in the sense of Article 4(5) of the GDPR: the data can no longer be attributed to a specific data subject without additional information (here, the key), which must be kept separately. Recital 26 specifies that pseudonymised data remain information on an identifiable person: the program shows it in its own way, because stable id: True says that whoever has the key links the row back to the tax code. The other half of the output is the reason why pseudonymisation is not anonymisation: with ten-year bands and three-digit postal codes, k is 1, meaning that two people are unique for that combination of attributes (the others are in groups of two). Only with twenty-year bands and no area do you reach k = 3, at the price of losing the geography.

The case is tiny and made on purpose: on eight rows it is easy to end up with groups of one, on millions of rows the problem moves to rare values. The practical meaning does not change. Before declaring "anonymous data" you have to measure the rarity of the combinations, and the boundary between anonymous and pseudonymous decides whether the GDPR applies. For models, the European Data Protection Board (Opinion 28/2024 of 18 December 2024) wrote that an AI model trained with personal data cannot, in all cases, be considered anonymous: case-by-case assessments are required, and for a model to be anonymous both the likelihood of direct (including probabilistic) extraction of personal data regarding the individuals whose data were used to develop the model, and the likelihood of obtaining such personal data from queries, must be insignificant, taking into account all the means reasonably likely to be used.

Legal basis for training: Opinion 28/2024

The same opinion addresses the legal basis. It recalls that there is no hierarchy between the legal bases of Article 6 and that it is for controllers to identify the appropriate one. For legitimate interest it recalls a three-step test: identify the interest pursued, assess the necessity of the processing for that interest, check that it is not overridden by the interests, rights and freedoms of the data subject (balancing). An interest may be regarded as legitimate if it is lawful, clearly and precisely articulated, and real and present (not speculative); the example is developing the service of a conversational agent to assist users. The opinion also examines three scenarios on the consequences of unlawful processing in the development of a model for its subsequent operation; I do not summarise them, because the answer depends on the case and on the supervisory authority.

Frequently asked questions

Can I train a model on public data from the Internet without worrying about the GDPR?

No: if the data concern identified or identifiable persons they are personal data, even if publicly accessible, and a legal basis is needed. Legitimate interest is one possible basis, to be assessed with the three-step test, not an automatism.

Does pseudonymisation take me out of the GDPR?

No. Article 4(5) defines it as a measure, and recital 26 says that pseudonymised data remain information on an identifiable person. It is a security and risk-reduction measure, explicitly cited by Article 25.

Do I need a data protection officer?

Article 37(1) provides for one in three cases: a public authority or body, core activities requiring regular and systematic monitoring of data subjects on a large scale, core activities consisting of large-scale processing of special categories of data or of data relating to criminal convictions and offences.

Does erasure (Article 17) oblige me to delete the trained model?

There is no uniform answer. It depends on the reason for erasure and on whether the model contains personal data: Opinion 28/2024 says that the anonymity of a model is assessed case by case. The opinion expects the controller to document anonymity; without that documentation the claim is hard to sustain.

Is the AI Act right to explanation the same as Article 22 of the GDPR?

No. Article 86 of the AI Act gives the right to obtain from the deployer clear and meaningful explanations of the role of the AI system in the decision-making procedure and the main elements of the decision taken, for Annex III systems (except point 2) and decisions with legal or similarly significant effects. Article 22 of the GDPR concerns the right not to be subject to solely automated decisions. They add up.

What you can do now

You know what Article 25 of the GDPR asks and why there is no list of pillars; you know the five points where the GDPR and the AI Act touch and in which direction; you know that a credit score can fall under Article 22 even when the final decision belongs to someone else; and you can measure with k-anonymity what remains identifiable after removing the direct fields. In the last article you put these checks into a runnable audit kit: the compliance toolkit. The theme of logs as evidence, mentioned in the second article, crosses with the minimisation described here.

Sources

The listing was run with Python 3.14.4, with identical output in two runs; it uses eight invented rows, no real data. Of Opinion 28/2024 the executive summary was read, not the full text; the GDPR text is the one published in 2016, not a later consolidated version.

Try These Tools

Free developer tools related to this topic.

Commenti

Caricamento commenti...

Sign in to comment

New articles and tools on Telegram too

The Telegram channel flags the site's new articles and tools.

Did you like this article?

Explore other content on the blog or discover my projects