{"slug": "eu-ai-act-article-50-2-for-llm-text-marking-and-detecting-ai-generated-text-2", "title": "EU AI Act Article 50(2) for LLM text: marking and detecting AI-generated text before 2 December", "summary": "A developer published a layered compliance design for EU AI Act Article 50(2), which requires providers of AI systems generating synthetic text to mark outputs in a machine-readable, detectable format. The approach combines signed provenance blocks and headers in API responses, metadata in exported documents, a detection endpoint, and an evidence log, since copy-paste strips metadata, edits break hashes, and paraphrasing weakens statistical watermarks. The post notes Article 50 has applied since 2 August 2026, with pre-existing systems given until 2 December 2026 under Article 111(4) of the Digital Omnibus on AI.", "body_md": "If your product returns LLM-generated text to people in the EU (chat answers, drafted emails, summaries, generated reports), Article 50(2) of the EU AI Act asks you, the provider, to make that text machine-readably marked and detectable. Our [October post](https://dev.to/rulereddy/eu-ai-act-article-502-marking-ai-generated-images-with-c2pa-before-the-2-december-deadline-1opc) covered images with C2PA. Text is harder, because plain text has nowhere to hide a manifest.\n\nThis post covers what the law and the Commission's guidelines actually say about text, then a layered design you can ship this week: provenance in API responses, metadata in exported documents, a detection endpoint, and an evidence log. It's readiness support for developers, not legal advice, and it was AI-assisted and then edited.\n\nFrom the [AI Act Service Desk's consolidated text of Article 50](https://ai-act-service-desk.ec.europa.eu/en/ai-act/article-50) ([Regulation (EU) 2024/1689 on EUR-Lex](https://eur-lex.europa.eu/eli/reg/2024/1689/oj/eng)):\n\n\"Providers of AI systems, including general-purpose AI systems, generating synthetic audio, image, video or text content, shall ensure that the outputs of the AI system are marked in a machine-readable format and detectable as artificially generated or manipulated. Providers shall ensure their technical solutions are effective, interoperable, robust and reliable as far as this is technically feasible, taking into account the specificities and limitations of various types of content, the costs of implementation and the generally acknowledged state of the art, as may be reflected in relevant technical standards.\"\n\nAnd the exceptions:\n\n\"This obligation shall not apply to the extent the AI systems perform an assistive function for standard editing or do not substantially alter the input data provided by the deployer or the semantics thereof, or where authorised by law to detect, prevent, investigate or prosecute criminal offences.\"\n\nThe [Commission Guidelines on Article 50](https://digital-strategy.ec.europa.eu/en/policies/guidelines-ai-transparency-obligations) (C(2026) 5054 final, 20 July 2026, non-binding) are where the developer-relevant detail lives:\n\nArticle 50(2) is the provider's machine-readable mark. Article 50(4) is a separate **deployer** duty: a visible label on AI text \"published with the purpose of informing the public on matters of public interest\", unless it went through human review or editorial control. We covered 50(4) [here](https://dev.to/rulereddy/eu-ai-act-article-504-building-deepfake-and-ai-text-labels-your-customers-can-actually-ship-2ae8). Your marking doesn't satisfy your customers' labeling duty, and vice versa.\n\nArticle 50 has applied since 2 August 2026. For systems placed on the market before that date, the Digital Omnibus on AI ([Regulation (EU) 2026/1744](https://eur-lex.europa.eu/eli/reg/2026/1744/oj/eng)) added [Article 111(4)](https://ai-act-service-desk.ec.europa.eu/en/ai-act/article-111): those providers \"shall take the necessary steps in order to comply with Article 50(2) by 2 December 2026.\" The [Commission FAQ](https://digital-strategy.ec.europa.eu/en/faqs/transparency-obligations-under-article-50-ai-act) confirms this is the only grace period. That's eight days from today.\n\nThe voluntary [Code of Practice on Transparency of AI-generated Content](https://digital-strategy.ec.europa.eu/en/policies/code-practice-ai-generated-content), published 10 June 2026, has a Section 1 for providers on marking and detection, and the Commission and AI Board have confirmed it as an adequate tool to demonstrate compliance. If you don't sign it, you must show your own measures are adequate.\n\nNo single technique survives everything. Copy-paste strips metadata, any edit breaks a hash, and paraphrasing weakens statistical watermarks. So layer them.\n\nThis Express middleware (TypeScript) adds a signed provenance block and headers to any response with `output_text`, logs it, and exposes a detection function:\n\n``` js\n// provenance.ts\nimport { createHash, generateKeyPairSync, sign, verify, randomUUID } from \"node:crypto\";\nimport { appendFileSync } from \"node:fs\";\nimport type { Request, Response, NextFunction } from \"express\";\n\n// In production, load the key from your KMS/secret store instead.\nconst { privateKey, publicKey } = generateKeyPairSync(\"ed25519\");\n\nexport interface Provenance {\n  id: string; ai_generated: true; generator: string; model: string;\n  created_at: string; sha256: string; sig: string; verify_url: string;\n}\n\nconst sha256 = (s: string) => createHash(\"sha256\").update(s.normalize(\"NFC\")).digest(\"hex\");\nconst index = new Map<string, Provenance>(); // use a real table in production\n\nexport function makeProvenance(text: string, model: string): Provenance {\n  const id = `prv_${randomUUID()}`;\n  const core = { id, ai_generated: true as const, generator: \"acme-writer/3.2.0\",\n                 model, created_at: new Date().toISOString(), sha256: sha256(text) };\n  const sig = sign(null, Buffer.from(JSON.stringify(core)), privateKey).toString(\"base64url\");\n  const p = { ...core, sig, verify_url: `https://acme.example/verify/${id}` };\n  index.set(p.sha256, p);\n  appendFileSync(\"evidence/art50-2.jsonl\", JSON.stringify({\n    ts: p.created_at, event: \"marked\", id, model, sha256: p.sha256,\n    channels: [\"json\", \"header\"] }) + \"\\n\");\n  return p;\n}\n\nexport function markAiText(model: string) {\n  return (_req: Request, res: Response, next: NextFunction) => {\n    const json = res.json.bind(res);\n    res.json = (body: any) => {\n      if (typeof body?.output_text === \"string\") {\n        const p = makeProvenance(body.output_text, model);\n        res.setHeader(\"X-AI-Generated\", \"true\");\n        res.setHeader(\"X-AI-Provenance-Id\", p.id);\n        body = { ...body, provenance: p };\n      }\n      return json(body);\n    };\n    next();\n  };\n}\n\n// Detection with a human-readable answer.\nexport function detect(text: string) {\n  const p = index.get(sha256(text));\n  if (!p) return { result: \"no_match\",\n    message: \"No exact match. The text may be human-written, edited, or from another system.\" };\n  const { sig, verify_url, ...core } = p;\n  const ok = verify(null, Buffer.from(JSON.stringify(core)), publicKey, Buffer.from(sig, \"base64url\"));\n  return ok\n    ? { result: \"ai_generated\", message: `Generated by ${p.generator} (${p.model}) on ${p.created_at}.` }\n    : { result: \"invalid_signature\", message: \"A record exists but its signature does not verify.\" };\n}\n// server.ts\napp.post(\"/v1/generate\", markAiText(\"example-llm-2026-09\"), async (req, res) => {\n  res.json({ output_text: await callLlm(req.body.prompt) });\n});\napp.post(\"/verify\", (req, res) => res.json(detect(String(req.body.text ?? \"\"))));\n```\n\n`X-AI-Generated` is a convention we made up, not a standard. There's no registered header for this yet, so document it in your API reference. Store hashes, not the text, in the lookup table if outputs contain personal data.\n\nIf users download a .docx or PDF, put the mark in the file:\n\n``` python\nimport json\nfrom docx import Document          # python-docx\nfrom pypdf import PdfReader, PdfWriter\n\nPROV = {\"ai_generated\": True, \"generator\": \"acme-writer/3.2.0\",\n        \"provenance_id\": \"prv_01J9Z6\", \"verify\": \"https://acme.example/verify/prv_01J9Z6\"}\n\ndef mark_docx(src, dst):\n    doc = Document(src)\n    doc.core_properties.keywords = \"AI-generated\"\n    doc.core_properties.comments = json.dumps(PROV)\n    doc.save(dst)\n\ndef mark_pdf(src, dst):\n    writer = PdfWriter(clone_from=PdfReader(src))\n    writer.add_metadata({\"/Keywords\": \"AI-generated\", \"/AIProvenance\": json.dumps(PROV)})\n    with open(dst, \"wb\") as f:\n        writer.write(f)\n```\n\nFor signed, interoperable provenance on PDFs and media, look at [C2PA](https://c2pa.org/). For plain chat text, metadata only lives as long as the container does.\n\nIf you run the model yourself, a token-level watermark survives copy-paste. Hugging Face Transformers ships a green-list `WatermarkingConfig` with a `WatermarkDetector`, plus SynthID Text support ([docs](https://huggingface.co/docs/transformers/main/en/internal/generation_utils)):\n\n``` python\nfrom transformers import WatermarkingConfig, WatermarkDetector\n\ncfg = WatermarkingConfig(bias=2.5, context_width=2, seeding_scheme=\"selfhash\")\nout = model.generate(input_ids, watermarking_config=cfg, max_length=200)\ndetector = WatermarkDetector(model_config=model.config, device=\"cpu\", watermarking_config=cfg)\nprint(detector(out))  # array([ True]) when the watermark is detected\n```\n\nBe honest about the limits. Detection needs enough tokens, so short replies are weak. Paraphrasing or translation degrades it. The docs warn that a high `bias` can hurt output quality, and say to replace the default hashing key with a private one. If you call a hosted model API, you usually can't add this yourself, so ask your model provider what marking they apply. The guidelines (para. 74) allow you to rely on an upstream solution, but the responsibility to demonstrate compliance stays with you.\n\nEvery marked output adds a line to `evidence/art50-2.jsonl`:\n\n```\n{\"ts\":\"2026-11-24T14:39:17.498Z\",\"event\":\"marked\",\"id\":\"prv_1e86...\",\"model\":\"example-llm-2026-09\",\"sha256\":\"5c12...21af\",\"channels\":[\"json\",\"header\"]}\n{\"ts\":\"2026-11-24T14:41:02.113Z\",\"event\":\"exempt\",\"route\":\"/v1/autocomplete\",\"reason\":\"short sequence (guidelines para. 68)\"}\n```\n\nLog your exemptions too. \"We didn't mark autocomplete because outputs are single words\" is a defensible, dated decision. Silence isn't.\n\n`/verify`.\nNot sure which Article 50 paragraphs apply to your product? RuleReddy has a free [Article 50 check](https://www.rulereddy.com/?utm_source=devto&utm_medium=article&utm_campaign=art50-2-text) at rulereddy.com.\n\n*Not legal advice. This is general technical guidance based on the official texts linked above. Talk to counsel about your specific product.*", "url": "https://wpnews.pro/news/eu-ai-act-article-50-2-for-llm-text-marking-and-detecting-ai-generated-text-2", "canonical_source": "https://dev.to/rulereddy/eu-ai-act-article-502-for-llm-text-marking-and-detecting-ai-generated-text-before-2-december-202c", "published_at": "2026-11-24 14:40:11+00:00", "updated_at": "2026-11-24 14:47:33.665588+00:00", "lang": "en", "topics": ["ai-policy", "large-language-models", "ai-safety", "generative-ai", "developer-tools"], "entities": ["European Commission", "EU AI Act", "Digital Omnibus on AI", "AI Act Service Desk", "Code of Practice on Transparency of AI-generated Content"], "also_reported_by": [], "takeaway": null, "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/eu-ai-act-article-50-2-for-llm-text-marking-and-detecting-ai-generated-text-2", "markdown": "https://wpnews.pro/news/eu-ai-act-article-50-2-for-llm-text-marking-and-detecting-ai-generated-text-2.md", "text": "https://wpnews.pro/news/eu-ai-act-article-50-2-for-llm-text-marking-and-detecting-ai-generated-text-2.txt", "jsonld": "https://wpnews.pro/news/eu-ai-act-article-50-2-for-llm-text-marking-and-detecting-ai-generated-text-2.jsonld"}}