gwoe-antragspruefer/adr/0001-llm-citation-binding/index.html

1059 lines
29 KiB
HTML
Raw Normal View History

<!doctype html>
<html lang="de" class="no-js">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="canonical" href="https://docs.gwoe.toppyr.de/adr/0001-llm-citation-binding/">
<link rel="prev" href="../">
<link rel="next" href="../0002-adapter-architecture/">
<link rel="icon" href="../../assets/images/favicon.png">
<meta name="generator" content="mkdocs-1.6.1, mkdocs-material-9.7.6">
<title>0001 LLM-Citation-Binding - GWÖ-Antragsprüfer Docs</title>
<link rel="stylesheet" href="../../assets/stylesheets/main.484c7ddc.min.css">
<link rel="stylesheet" href="../../assets/stylesheets/palette.ab4e12ef.min.css">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CRoboto+Mono:400,400i,700,700i&display=fallback">
<style>:root{--md-text-font:"Roboto";--md-code-font:"Roboto Mono"}</style>
<script>__md_scope=new URL("../..",location),__md_hash=e=>[...e].reduce(((e,_)=>(e<<5)-e+_.charCodeAt(0)),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script>
</head>
<body dir="ltr" data-md-color-scheme="default" data-md-color-primary="teal" data-md-color-accent="light-green">
<input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
<input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
<label class="md-overlay" for="__drawer"></label>
<div data-md-component="skip">
<a href="#0001-llm-citations-server-seitig-binden-statt-prompt-seitig" class="md-skip">
Zum Inhalt
</a>
</div>
<div data-md-component="announce">
</div>
<header class="md-header md-header--shadow" data-md-component="header">
<nav class="md-header__inner md-grid" aria-label="Kopfzeile">
<a href="../.." title="GWÖ-Antragsprüfer Docs" class="md-header__button md-logo" aria-label="GWÖ-Antragsprüfer Docs" data-md-component="logo">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 8a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54"/></svg>
</a>
<label class="md-header__button md-icon" for="__drawer">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 6h18v2H3zm0 5h18v2H3zm0 5h18v2H3z"/></svg>
</label>
<div class="md-header__title" data-md-component="header-title">
<div class="md-header__ellipsis">
<div class="md-header__topic">
<span class="md-ellipsis">
GWÖ-Antragsprüfer Docs
</span>
</div>
<div class="md-header__topic" data-md-component="header-topic">
<span class="md-ellipsis">
0001 LLM-Citation-Binding
</span>
</div>
</div>
</div>
<label class="md-header__button md-icon" for="__search">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5"/></svg>
</label>
<div class="md-search" data-md-component="search" role="dialog">
<label class="md-search__overlay" for="__search"></label>
<div class="md-search__inner" role="search">
<form class="md-search__form" name="search">
<input type="text" class="md-search__input" name="query" aria-label="Suche" placeholder="Suche" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="search-query" required>
<label class="md-search__icon md-icon" for="__search">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5"/></svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11z"/></svg>
</label>
<nav class="md-search__options" aria-label="Suche">
<button type="reset" class="md-search__icon md-icon" title="Zurücksetzen" aria-label="Zurücksetzen" tabindex="-1">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>
</button>
</nav>
</form>
<div class="md-search__output">
<div class="md-search__scrollwrap" tabindex="0" data-md-scrollfix>
<div class="md-search-result" data-md-component="search-result">
<div class="md-search-result__meta">
Suche wird initialisiert
</div>
<ol class="md-search-result__list" role="presentation"></ol>
</div>
</div>
</div>
</div>
</div>
<div class="md-header__source">
<a href="https://repo.toppyr.de/tobias/gwoe-antragspruefer" title="Zum Repository" class="md-source" data-md-component="source">
<div class="md-source__icon md-icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 7.1.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2025 Fonticons, Inc.--><path d="M439.6 236.1 244 40.5c-5.4-5.5-12.8-8.5-20.4-8.5s-15 3-20.4 8.4L162.5 81l51.5 51.5c27.1-9.1 52.7 16.8 43.4 43.7l49.7 49.7c34.2-11.8 61.2 31 35.5 56.7-26.5 26.5-70.2-2.9-56-37.3L240.3 199v121.9c25.3 12.5 22.3 41.8 9.1 55-6.4 6.4-15.2 10.1-24.3 10.1s-17.8-3.6-24.3-10.1c-17.6-17.6-11.1-46.9 11.2-56v-123c-20.8-8.5-24.6-30.7-18.6-45L142.6 101 8.5 235.1C3 240.6 0 247.9 0 255.5s3 15 8.5 20.4l195.6 195.7c5.4 5.4 12.7 8.4 20.4 8.4s15-3 20.4-8.4l194.7-194.7c5.4-5.4 8.4-12.8 8.4-20.4s-3-15-8.4-20.4"/></svg>
</div>
<div class="md-source__repository">
tobias/gwoe-antragspruefer
</div>
</a>
</div>
</nav>
</header>
<div class="md-container" data-md-component="container">
<main class="md-main" data-md-component="main">
<div class="md-main__inner md-grid">
<div class="md-sidebar md-sidebar--primary" data-md-component="sidebar" data-md-type="navigation" >
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
<nav class="md-nav md-nav--primary" aria-label="Navigation" data-md-level="0">
<label class="md-nav__title" for="__drawer">
<a href="../.." title="GWÖ-Antragsprüfer Docs" class="md-nav__button md-logo" aria-label="GWÖ-Antragsprüfer Docs" data-md-component="logo">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 8a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54"/></svg>
</a>
GWÖ-Antragsprüfer Docs
</label>
<div class="md-nav__source">
<a href="https://repo.toppyr.de/tobias/gwoe-antragspruefer" title="Zum Repository" class="md-source" data-md-component="source">
<div class="md-source__icon md-icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 7.1.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2025 Fonticons, Inc.--><path d="M439.6 236.1 244 40.5c-5.4-5.5-12.8-8.5-20.4-8.5s-15 3-20.4 8.4L162.5 81l51.5 51.5c27.1-9.1 52.7 16.8 43.4 43.7l49.7 49.7c34.2-11.8 61.2 31 35.5 56.7-26.5 26.5-70.2-2.9-56-37.3L240.3 199v121.9c25.3 12.5 22.3 41.8 9.1 55-6.4 6.4-15.2 10.1-24.3 10.1s-17.8-3.6-24.3-10.1c-17.6-17.6-11.1-46.9 11.2-56v-123c-20.8-8.5-24.6-30.7-18.6-45L142.6 101 8.5 235.1C3 240.6 0 247.9 0 255.5s3 15 8.5 20.4l195.6 195.7c5.4 5.4 12.7 8.4 20.4 8.4s15-3 20.4-8.4l194.7-194.7c5.4-5.4 8.4-12.8 8.4-20.4s-3-15-8.4-20.4"/></svg>
</div>
<div class="md-source__repository">
tobias/gwoe-antragspruefer
</div>
</a>
</div>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../.." class="md-nav__link">
<span class="md-ellipsis">
Start
</span>
</a>
</li>
<li class="md-nav__item md-nav__item--active md-nav__item--section md-nav__item--nested">
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_2" checked>
<label class="md-nav__link" for="__nav_2" id="__nav_2_label" tabindex="">
<span class="md-ellipsis">
Architecture Decision Records
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_2_label" aria-expanded="true">
<label class="md-nav__title" for="__nav_2">
<span class="md-nav__icon md-icon"></span>
Architecture Decision Records
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../" class="md-nav__link">
<span class="md-ellipsis">
Übersicht
</span>
</a>
</li>
<li class="md-nav__item md-nav__item--active">
<input class="md-nav__toggle md-toggle" type="checkbox" id="__toc">
<label class="md-nav__link md-nav__link--active" for="__toc">
<span class="md-ellipsis">
0001 LLM-Citation-Binding
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<a href="./" class="md-nav__link md-nav__link--active">
<span class="md-ellipsis">
0001 LLM-Citation-Binding
</span>
</a>
<nav class="md-nav md-nav--secondary" aria-label="Inhaltsverzeichnis">
<label class="md-nav__title" for="__toc">
<span class="md-nav__icon md-icon"></span>
Inhaltsverzeichnis
</label>
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
<li class="md-nav__item">
<a href="#kontext" class="md-nav__link">
<span class="md-ellipsis">
Kontext
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#optionen" class="md-nav__link">
<span class="md-ellipsis">
Optionen
</span>
</a>
<nav class="md-nav" aria-label="Optionen">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#option-a-scharferer-prompt" class="md-nav__link">
<span class="md-ellipsis">
Option A — Schärferer Prompt
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#option-b-server-seitige-quellen-rekonstruktion" class="md-nav__link">
<span class="md-ellipsis">
Option B — Server-seitige Quellen-Rekonstruktion
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#option-c-schema-anderung-mit-quote_id-feld" class="md-nav__link">
<span class="md-ellipsis">
Option C — Schema-Änderung mit quote_id-Feld
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#entscheidung" class="md-nav__link">
<span class="md-ellipsis">
Entscheidung
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#konsequenzen" class="md-nav__link">
<span class="md-ellipsis">
Konsequenzen
</span>
</a>
<nav class="md-nav" aria-label="Konsequenzen">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#positiv" class="md-nav__link">
<span class="md-ellipsis">
Positiv
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#negativ" class="md-nav__link">
<span class="md-ellipsis">
Negativ
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#folgen-fur-andere-adrs" class="md-nav__link">
<span class="md-ellipsis">
Folgen für andere ADRs
</span>
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="../0002-adapter-architecture/" class="md-nav__link">
<span class="md-ellipsis">
0002 Adapter-Architektur
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../0003-citation-property-tests/" class="md-nav__link">
<span class="md-ellipsis">
0003 Citation-Property-Tests
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../0004-deployment-workflow/" class="md-nav__link">
<span class="md-ellipsis">
0004 Deployment-Workflow
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--section md-nav__item--nested">
<input class="md-nav__toggle md-toggle md-toggle--indeterminate" type="checkbox" id="__nav_3" >
<label class="md-nav__link" for="__nav_3" id="__nav_3_label" tabindex="">
<span class="md-ellipsis">
Archiv
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_3_label" aria-expanded="false">
<label class="md-nav__title" for="__nav_3">
<span class="md-nav__icon md-icon"></span>
Archiv
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../archive/" class="md-nav__link">
<span class="md-ellipsis">
Übersicht
</span>
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="md-sidebar md-sidebar--secondary" data-md-component="sidebar" data-md-type="toc" >
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
<nav class="md-nav md-nav--secondary" aria-label="Inhaltsverzeichnis">
<label class="md-nav__title" for="__toc">
<span class="md-nav__icon md-icon"></span>
Inhaltsverzeichnis
</label>
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
<li class="md-nav__item">
<a href="#kontext" class="md-nav__link">
<span class="md-ellipsis">
Kontext
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#optionen" class="md-nav__link">
<span class="md-ellipsis">
Optionen
</span>
</a>
<nav class="md-nav" aria-label="Optionen">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#option-a-scharferer-prompt" class="md-nav__link">
<span class="md-ellipsis">
Option A — Schärferer Prompt
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#option-b-server-seitige-quellen-rekonstruktion" class="md-nav__link">
<span class="md-ellipsis">
Option B — Server-seitige Quellen-Rekonstruktion
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#option-c-schema-anderung-mit-quote_id-feld" class="md-nav__link">
<span class="md-ellipsis">
Option C — Schema-Änderung mit quote_id-Feld
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#entscheidung" class="md-nav__link">
<span class="md-ellipsis">
Entscheidung
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#konsequenzen" class="md-nav__link">
<span class="md-ellipsis">
Konsequenzen
</span>
</a>
<nav class="md-nav" aria-label="Konsequenzen">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#positiv" class="md-nav__link">
<span class="md-ellipsis">
Positiv
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#negativ" class="md-nav__link">
<span class="md-ellipsis">
Negativ
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#folgen-fur-andere-adrs" class="md-nav__link">
<span class="md-ellipsis">
Folgen für andere ADRs
</span>
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="md-content" data-md-component="content">
<article class="md-content__inner md-typeset">
<h1 id="0001-llm-citations-server-seitig-binden-statt-prompt-seitig">0001 — LLM-Citations server-seitig binden statt prompt-seitig<a class="headerlink" href="#0001-llm-citations-server-seitig-binden-statt-prompt-seitig" title="Permanent link">&para;</a></h1>
<table>
<thead>
<tr>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>Status</strong></td>
<td>accepted</td>
</tr>
<tr>
<td><strong>Datum</strong></td>
<td>2026-04-10</td>
</tr>
<tr>
<td><strong>Refs</strong></td>
<td>Issue #60, Commits eb045d0/ed64399/db3ada9/6ced7ae, Sub-D Tests</td>
</tr>
</tbody>
</table>
<h2 id="kontext">Kontext<a class="headerlink" href="#kontext" title="Permanent link">&para;</a></h2>
<p>Der GWÖ-Antragsprüfer lässt ein LLM (Qwen Plus via DashScope) parlamentarische
Anträge bewerten. Pro Antrag werden via Embedding-Retrieval relevante Chunks
aus den Wahl- und Grundsatzprogrammen der involvierten Parteien zugespielt.
Das LLM gibt im JSON-Output <code>wahlprogramm_scores[*].wahlprogramm.zitate[*]</code>
mit jeweils <code>text</code>, <code>quelle</code> (Source-Label, z.B. "GRÜNE NRW Wahlprogramm
2022, S. 58") und <code>url</code> zurück.</p>
<p>Beim ersten Live-Lauf des Sub-D Citation-Property-Tests (siehe ADR 0003)
gegen die Prod-DB wurden drei Halluzinations-Cases gefunden: das LLM hatte
Snippets erfunden und unter realen Source-Labels zitiert. Issue #60 wurde
geöffnet.</p>
<h2 id="optionen">Optionen<a class="headerlink" href="#optionen" title="Permanent link">&para;</a></h2>
<p>Drei strukturell unterschiedliche Wege, das LLM zu binden:</p>
<h3 id="option-a-scharferer-prompt">Option A — Schärferer Prompt<a class="headerlink" href="#option-a-scharferer-prompt" title="Permanent link">&para;</a></h3>
<p>Die ZITATEREGEL im User-Prompt wird verschärft. Konkret:</p>
<ol>
<li>Jeder retrievte Chunk wird mit einer ENUM-ID <code>[Q1]</code>, <code>[Q2]</code>, … getaggt.</li>
<li>Das LLM wird angewiesen, jedes Zitat per <code>[Qn]</code>-Tag an einen Chunk zu
binden, den <code>text</code> wörtlich aus diesem Chunk zu kopieren und das
Source-Label exakt zu übernehmen.</li>
<li>Top-K wird von 2 → 5 erhöht, damit die "richtige" Seite häufiger im
Retrieval-Window landet.</li>
</ol>
<p><strong>Vorteile:</strong> prompt-only, kleiner Diff, keine Server-Pipeline-Änderung.</p>
<p><strong>Nachteile:</strong> ENUM-Anker im Prompt ist ein <strong>weicher</strong> Hint. Das LLM darf
zwar den Snippet aus Chunk Qn nehmen, aber es gibt nichts, was es daran
hindert, die Seite aus Chunk Qm in <code>quelle</code> zu schreiben. Cross-Mix bleibt
möglich.</p>
<h3 id="option-b-server-seitige-quellen-rekonstruktion">Option B — Server-seitige Quellen-Rekonstruktion<a class="headerlink" href="#option-b-server-seitige-quellen-rekonstruktion" title="Permanent link">&para;</a></h3>
<p>Nach dem LLM-Call werden die emittierten Zitate Server-seitig nachgearbeitet:</p>
<ol>
<li>Für jedes Zitat im Output-JSON wird der <code>text</code> per Substring oder
5-Wort-Anker gegen <strong>alle</strong> retrievten Chunks gematcht.</li>
<li>Bei Match: <code>quelle</code> und <code>url</code> werden aus dem matchenden Chunk <strong>konstruiert</strong>
und der LLM-Output für diese Felder verworfen.</li>
<li>Bei kein-Match: das ganze Zitat wird verworfen.</li>
</ol>
<p><strong>Vorteile:</strong> strukturell — der LLM hat keine Möglichkeit mehr, eine falsche
Quelle anzugeben. Die einzigen zwei Outcomes sind "korrekt zitiert" oder
"verworfen".</p>
<p><strong>Nachteile:</strong> zusätzlicher Server-seitiger Schritt nach <code>json.loads</code> und
vor Pydantic-Validation. Match-Logik muss konsistent mit Sub-D bleiben.</p>
<h3 id="option-c-schema-anderung-mit-quote_id-feld">Option C — Schema-Änderung mit <code>quote_id</code>-Feld<a class="headerlink" href="#option-c-schema-anderung-mit-quote_id-feld" title="Permanent link">&para;</a></h3>
<p>Statt <code>quelle</code> direkt zu emittieren, soll das LLM ein neues Feld <code>quote_id</code>
(z.B. <code>"Q3"</code>) liefern, aus dem der Server <code>quelle</code>/<code>url</code> rekonstruiert.</p>
<p><strong>Vorteile:</strong> explizit schema-modelliert, keine Heuristik.</p>
<p><strong>Nachteile:</strong> invasiv (Pydantic-Modell, JSON-Schema, Frontend, DB-Migration);
verlässt sich darauf, dass das LLM die ID korrekt setzt — wenn es lügt,
ist die Bindung futsch.</p>
<h2 id="entscheidung">Entscheidung<a class="headerlink" href="#entscheidung" title="Permanent link">&para;</a></h2>
<p><strong>A + B kombiniert.</strong> Option A liefert die Vorab-Härtung im Prompt — sie
fängt den Großteil der Cases (etwa 80%). Option B ist die strukturelle
Backstop, die die restlichen 20% (echter Snippet aus Qn, falsche Seite
aus Qm) verlässlich abdeckt. Option C wurde verworfen, weil der Schema-
Eingriff den Aufwand nicht rechtfertigt, solange B die LLM-Eingabe ohnehin
ignoriert.</p>
<p>Konkret in dieser Reihenfolge implementiert:</p>
<ol>
<li><strong><code>db3ada9</code></strong> — Option A: ENUM-Anker <code>[Q1]/[Q2]/…</code> im Prompt + Top-K 2→5.
Live-Verifikation der drei Original-Cases aus #60: 13/13 ok.</li>
<li><strong>Sub-D Live-Run gegen Prod-DB</strong>: 45/46 grün, ein neuer Case (BB 8/673)
gefunden mit "echter Snippet, falsche Seite". Beweis dass A allein nicht
reicht.</li>
<li><strong><code>6ced7ae</code></strong> — Option B: <code>embeddings.reconstruct_zitate(data, semantic_quotes)</code>
nach <code>json.loads</code> und vor Pydantic-Validation. Helpers <code>find_chunk_for_text</code>
und <code>_normalize_for_match</code> mit identischer Logik wie Sub-D. Bei Match wird
<code>_chunk_source_label</code> und <code>_chunk_pdf_url</code> angewendet, bei No-Match wird
das Zitat gedroppt.</li>
<li>Sub-D Re-Run nach B: <strong>52/52 grün</strong> über NRW/LSA/BE/MV/BB/BUND.</li>
</ol>
<h2 id="konsequenzen">Konsequenzen<a class="headerlink" href="#konsequenzen" title="Permanent link">&para;</a></h2>
<h3 id="positiv">Positiv<a class="headerlink" href="#positiv" title="Permanent link">&para;</a></h3>
<ul>
<li><strong>Strukturelle Garantie</strong>: nach <code>reconstruct_zitate</code> kann ein im DB
gespeichertes Zitat nur noch eines von zwei Dingen sein: korrekt zitiert
aus einem real retrievten Chunk, oder gar nicht da.</li>
<li><strong>Sub-D als CI-Gate</strong>: das Property-Test-Pattern fängt jede künftige
Regression dieser Bug-Klasse.</li>
<li><strong>Server vertraut LLM nicht mehr</strong> für <code>quelle</code>/<code>url</code>. Künftige Modell-
Wechsel oder Prompt-Drift können die Quellen-Korrektheit nicht mehr brechen.</li>
</ul>
<h3 id="negativ">Negativ<a class="headerlink" href="#negativ" title="Permanent link">&para;</a></h3>
<ul>
<li><strong>Fehlende Match-Heuristik = stilles Verschwinden</strong>: Wenn der LLM einen
echten Chunk leicht paraphrasiert (z.B. Komma anders gesetzt), verwirft
Option B das Zitat. Die 5-Wort-Anker-Fallback fängt das in den meisten
Fällen, aber Edge-Cases bleiben. Mitigation: doctest-style Sub-D-Run pro
Deploy + Monitor der <code>wahlprogramm_scores[*].zitate</code>-Counts pro Assessment.</li>
<li><strong>Code-Pfad-Komplexität</strong>: drei Schichten (Prompt-ENUM, Server-Postprocess,
Sub-D-Test) statt einer. Dafür ist jede Schicht isoliert testbar.</li>
<li><strong><code>embeddings.py</code> hat jetzt mehr Verantwortung</strong> als nur Embedding-Retrieval
— auch Match-Helpers und Source-Label-Konstruktion. Akzeptabel solange das
Modul thematisch geschlossen bleibt; bei weiterem Wachstum als
<code>citations.py</code> extrahieren.</li>
</ul>
<h3 id="folgen-fur-andere-adrs">Folgen für andere ADRs<a class="headerlink" href="#folgen-fur-andere-adrs" title="Permanent link">&para;</a></h3>
<ul>
<li><strong>ADR 0003</strong> (Sub-D Citation-Property-Tests) ist die Test-Säule dieser
Entscheidung — wenn 0003 jemals supersedet wird, bricht 0001 ohne den
Test-Backstop möglicherweise still.</li>
<li>Neue Adapter (zukünftige Bundesländer) müssen sich nicht extra um
Citation-Korrektheit kümmern; der Server-Postprocess ist adapter-agnostisch.</li>
</ul>
</article>
</div>
<script>var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))</script>
</div>
</main>
<footer class="md-footer">
<div class="md-footer-meta md-typeset">
<div class="md-footer-meta__inner md-grid">
<div class="md-copyright">
Made with
<a href="https://squidfunk.github.io/mkdocs-material/" target="_blank" rel="noopener">
Material for MkDocs
</a>
</div>
</div>
</div>
</footer>
</div>
<div class="md-dialog" data-md-component="dialog">
<div class="md-dialog__inner md-typeset"></div>
</div>
<script id="__config" type="application/json">{"annotate": null, "base": "../..", "features": ["navigation.sections", "navigation.expand", "search.highlight"], "search": "../../assets/javascripts/workers/search.2c215733.min.js", "tags": null, "translations": {"clipboard.copied": "In Zwischenablage kopiert", "clipboard.copy": "In Zwischenablage kopieren", "search.result.more.one": "1 weiteres Suchergebnis auf dieser Seite", "search.result.more.other": "# weitere Suchergebnisse auf dieser Seite", "search.result.none": "Keine Suchergebnisse", "search.result.one": "1 Suchergebnis", "search.result.other": "# Suchergebnisse", "search.result.placeholder": "Suchbegriff eingeben", "search.result.term.missing": "Es fehlt", "select.version": "Version ausw\u00e4hlen"}, "version": null}</script>
<script src="../../assets/javascripts/bundle.79ae519e.min.js"></script>
</body>
</html>