跳到正文
DEV Community· RuleReddy·· 3 小時前AI 評分71

EU AI Act 第 50(2) 條:如何在 12 月 2 日前標記及檢測 LLM 生成文字

EU AI Act Article 50(2) for LLM text: marking and detecting AI-generated text before 2 December

AI 導讀

文章解讀 EU AI Act 第 50(2) 條對供應商向歐盟用戶提供的 LLM 生成文字所設的機器可讀標記及可檢測要求。2026 年 8 月 2 日前已投放市場的系統,須於 2026 年 12 月 2 日前採取必要措施遵守規定。

正文

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 covered images with C2PA. Text is harder, because plain text has nowhere to hide a manifest.

This 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.

The text of Article 50(2)

From the AI Act Service Desk's consolidated text of Article 50 (Regulation (EU) 2024/1689 on EUR-Lex):

"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."

And the exceptions:

"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."

What the Commission's guidelines add for text

The Commission Guidelines on Article 50 (C(2026) 5054 final, 20 July 2026, non-binding) are where the developer-relevant detail lives:

  • Marking and detection are two separate requirements. Marking alone, without a way to detect it, "will not suffice" (para. 70). Detection results should be human-readable (para. 75).
  • Any technique, or a mix. Recital 133 lists watermarks, metadata, cryptographic provenance, logging and fingerprints, and providers may combine them (paras. 72-73).
  • "Technically feasible" means "capable of being implemented ... using currently available technology, methods, and engineering practices", and providers aren't obliged to use a solution "that is not yet developed or available on the market" (para. 81). It's an objective test, not one based on your team's resources.
  • "State of the art" doesn't mean experimental research, but you "must continuously adapt" as it evolves (para. 83).
  • Out of scope (para. 68): short sequences such as single words, captions, alt-text and UI labels; source code, including SQL, YAML and JSON config; and machine-to-machine output that no human sees. Agent reasoning steps and web requests aren't covered either, but text an agent produces for people is (para. 63).
  • Standard editing vs. substantive change. The guidelines' examples of exempt editing include grammar correction, minor stylistic polishing and "AI-generated translations of text". On the other side, "AI-generated summaries of text" and rewriting "that changes style, structure and meaning" require marking.
  • Narrow B2B carve-out (para. 87): no marking only if output is strictly technical, seen by a limited set of professionals inside provider and deployer, and not meant to leave the company. Most SaaS writing features won't qualify.

Two duties, two owners

Article 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. Your marking doesn't satisfy your customers' labeling duty, and vice versa.

The date

Article 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) added Article 111(4): those providers "shall take the necessary steps in order to comply with Article 50(2) by 2 December 2026." The Commission FAQ confirms this is the only grace period. That's eight days from today.

The voluntary Code of Practice on Transparency of 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.

A layered design for LLM text

No single technique survives everything. Copy-paste strips metadata, any edit breaks a hash, and paraphrasing weakens statistical watermarks. So layer them.

Layer 1: provenance in the API response

This Express middleware (TypeScript) adds a signed provenance block and headers to any response with output_text, logs it, and exposes a detection function:

// provenance.ts
import { createHash, generateKeyPairSync, sign, verify, randomUUID } from "node:crypto";
import { appendFileSync } from "node:fs";
import type { Request, Response, NextFunction } from "express";

// In production, load the key from your KMS/secret store instead.
const { privateKey, publicKey } = generateKeyPairSync("ed25519");

export interface Provenance {
  id: string; ai_generated: true; generator: string; model: string;
  created_at: string; sha256: string; sig: string; verify_url: string;
}

const sha256 = (s: string) => createHash("sha256").update(s.normalize("NFC")).digest("hex");
const index = new Map<string, Provenance>(); // use a real table in production

export function makeProvenance(text: string, model: string): Provenance {
  const id = `prv_${randomUUID()}`;
  const core = { id, ai_generated: true as const, generator: "acme-writer/3.2.0",
                 model, created_at: new Date().toISOString(), sha256: sha256(text) };
  const sig = sign(null, Buffer.from(JSON.stringify(core)), privateKey).toString("base64url");
  const p = { ...core, sig, verify_url: `https://acme.example/verify/${id}` };
  index.set(p.sha256, p);
  appendFileSync("evidence/art50-2.jsonl", JSON.stringify({
    ts: p.created_at, event: "marked", id, model, sha256: p.sha256,
    channels: ["json", "header"] }) + "\n");
  return p;
}

export function markAiText(model: string) {
  return (_req: Request, res: Response, next: NextFunction) => {
    const json = res.json.bind(res);
    res.json = (body: any) => {
      if (typeof body?.output_text === "string") {
        const p = makeProvenance(body.output_text, model);
        res.setHeader("X-AI-Generated", "true");
        res.setHeader("X-AI-Provenance-Id", p.id);
        body = { ...body, provenance: p };
      }
      return json(body);
    };
    next();
  };
}

// Detection with a human-readable answer.
export function detect(text: string) {
  const p = index.get(sha256(text));
  if (!p) return { result: "no_match",
    message: "No exact match. The text may be human-written, edited, or from another system." };
  const { sig, verify_url, ...core } = p;
  const ok = verify(null, Buffer.from(JSON.stringify(core)), publicKey, Buffer.from(sig, "base64url"));
  return ok
    ? { result: "ai_generated", message: `Generated by ${p.generator} (${p.model}) on ${p.created_at}.` }
    : { result: "invalid_signature", message: "A record exists but its signature does not verify." };
}
// server.ts
app.post("/v1/generate", markAiText("example-llm-2026-09"), async (req, res) => {
  res.json({ output_text: await callLlm(req.body.prompt) });
});
app.post("/verify", (req, res) => res.json(detect(String(req.body.text ?? ""))));

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.

Layer 2: metadata in exported documents

If users download a .docx or PDF, put the mark in the file:

import json
from docx import Document          # python-docx
from pypdf import PdfReader, PdfWriter

PROV = {"ai_generated": True, "generator": "acme-writer/3.2.0",
        "provenance_id": "prv_01J9Z6", "verify": "https://acme.example/verify/prv_01J9Z6"}

def mark_docx(src, dst):
    doc = Document(src)
    doc.core_properties.keywords = "AI-generated"
    doc.core_properties.comments = json.dumps(PROV)
    doc.save(dst)

def mark_pdf(src, dst):
    writer = PdfWriter(clone_from=PdfReader(src))
    writer.add_metadata({"/Keywords": "AI-generated", "/AIProvenance": json.dumps(PROV)})
    with open(dst, "wb") as f:
        writer.write(f)

For signed, interoperable provenance on PDFs and media, look at C2PA. For plain chat text, metadata only lives as long as the container does.

Layer 3: statistical watermarking, if you control decoding

If 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):

from transformers import WatermarkingConfig, WatermarkDetector

cfg = WatermarkingConfig(bias=2.5, context_width=2, seeding_scheme="selfhash")
out = model.generate(input_ids, watermarking_config=cfg, max_length=200)
detector = WatermarkDetector(model_config=model.config, device="cpu", watermarking_config=cfg)
print(detector(out))  # array([ True]) when the watermark is detected

Be 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.

Layer 4: evidence

Every marked output adds a line to evidence/art50-2.jsonl:

{"ts":"2026-11-24T14:39:17.498Z","event":"marked","id":"prv_1e86...","model":"example-llm-2026-09","sha256":"5c12...21af","channels":["json","header"]}
{"ts":"2026-11-24T14:41:02.113Z","event":"exempt","route":"/v1/autocomplete","reason":"short sequence (guidelines para. 68)"}

Log your exemptions too. "We didn't mark autocomplete because outputs are single words" is a defensible, dated decision. Silence isn't.

Checklist before 2 December

  • List every route that returns generated text to humans: chat, drafts, summaries, agent output, exports.
  • Tag each route as marked, exempt (with the guideline paragraph), or standard editing.
  • Ship Layer 1 on all marked routes, plus a public /verify.
  • Add document metadata on exports.
  • Ask your model vendor in writing what watermarking they apply.
  • Keep the JSONL log, and review it against the Code of Practice.

Not sure which Article 50 paragraphs apply to your product? RuleReddy has a free Article 50 check at rulereddy.com.

Not legal advice. This is general technical guidance based on the official texts linked above. Talk to counsel about your specific product.

來源:DEV Community · dev.to