paperless-AI prompt: intra-scan correspondent dedup + better fuzzy match for short-brand forms #4
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Bundled follow-ups surfaced by hermes during #3.
(a) Intra-scan correspondent dedup
Observed: paperless-AI processed a single multi-doc scan and created three separate aliases for the same sender (
Praxis-Irlecluster). Each doc in the same scan batch triggered a fresh "new correspondent" creation because the AI sees each doc independently — there's no state-sharing across the batch.Fix: prompt rule along the lines of "Bevor du einen neuen Correspondent anlegst, pruefe ob du in dieser Sitzung bereits einen Correspondent mit aehnlichem Namen angelegt hast — verwende dann den existierenden." The paperless-AI worker doesn't natively pass batch context, so this is best-effort, but adding the rule + reinforcing the fuzzy-match catalogue should catch most cases.
(b) Short-brand fuzzy match
Observed: existing correspondent
Hogan Lovells International LLPwas not matched when a new doc came in from "Hogan Lovells" — AI createdHogan Lovellsas a separate correspondent.Fix: extend the fuzzy-match rule in SYSTEM_PROMPT to explicitly cover the case where the OCR form is a strict prefix of the existing correspondent (and vice-versa), or where the brand-token overlaps. Concretely add to the existing fuzzy-match-criteria block: "Beim Vergleich gilt: Ist der OCR-Name ein striktes Praefix eines existierenden Correspondents (oder umgekehrt), und stimmen die ersten 2 Brand-Tokens ueberein, verwende den existierenden Correspondent."
Approach
Both fixes are prompt-only — no paperless-AI code changes. Update
infra/paperless/SYSTEM_PROMPT.txt(single source of truth now, per #3), push to live viainfra/paperless/push_system_prompt.py, restart container, verify with a fresh test doc.Test plan
Hogan Lovells International LLP, doesn't create a new correspondent.Out of scope
Context
Role: gitster.
Done — beide Prompt-Regeln deployed
Beide Fixes als reine Prompt-Aenderung in
infra/paperless/SYSTEM_PROMPT.txtumgesetzt (keine paperless-AI Code-Aenderung). Viapush_system_prompt.py --applyauf den Live-Container gepusht, Container restartet (healthy).(a) Intra-Scan Dedup — neue Regel 4 in Correspondents-Sektion
Direkt nach der Fuzzy-Match-Vorbereitung eingefuegt:
Plus konkretes Beispiel im Examples-Block:
Caveat (auch im commit message und memory festgehalten): paperless-AI gibt der LLM bei jedem Dokument nur den initial gefetchten Correspondents-Snapshot — es gibt keinen nativen Batch-Kontext zwischen Docs. Die Regel ist also best-effort durch das Modell: bei einem strict-stateless Aufruf weiss das LLM nicht, was es eine Anfrage vorher entschieden hat. Die Regel hilft am ehesten, wenn das LLM aus dem Doc-Kontext selbst erschliessen kann, dass es ein Multi-Doc-Batch vom gleichen Sender ist (Format, Layout, Briefkopf). Eine echte deterministische Loesung braeuchte einen Upstream-Patch in paperless-AI (Stateful Batch-Cache).
(b) Short-Brand Prefix Match — Erweiterung der Fuzzy-Regel
Neuer Absatz direkt nach dem Fuzzy-Regel-Block:
Plus konkretes Beispiel:
Verification
Backup vom alten
.envliegt im Container unter/app/data/.env.bak.20260521T092606. 79 Correspondents im Snapshot (Siebels-Namen wie immer gefiltert).End-to-End Test Plan
Die eigentliche Wirksamkeit zeigt sich erst im Live-Betrieb mit neuen Scans:
Wenn (1) sich als nicht ausreichend erweist, separates Issue fuer Upstream-Patch in paperless-AI aufmachen (Batch-Kontext-Cache im Worker).
Commit:
a2fa76a41aBranch:
mai/hermes/issue-4-paperless-ai