Under Settings → AI/LLM → LLM Extraction Templates you solve a core problem of productive LLM extraction: regression-safe prompt maintenance across very many data points.

The problem

Complex LLM data extractions can involve hundreds of data points per case, each queried via a prompt, returned as JSON, and mapped to placeholders. Users keep improving these prompts over time. The risk: an improvement in one place breaks something else — a classic regression that, without tests, often surfaces only much later.

The solution: tested extraction sets

An extraction template is a JSON-based set in which every data point is stored with its placeholder and its prompt. You also select test cases — real documents for which the expected values for each data point are known.

If you later change a prompt, you can check it with one click against dozens of test cases and see immediately: are the previous results still achieved — and, say, has an edge case now also been improved without breaking anything else? This lets you reach very high quality even for complex extraction tasks.

Template
Name des Templates
Beschreibung
opus-thinking  ✕ ▾ausPseudonymisieren
› Dokument Tag Filter  ·  Prompt Rolle: User
System Prompt (FEEL)
User Prompt Präfix
JSON Attribute (Datenpunkte)
gerichts_urteil_aktenzeichen
Key (Platzhalter)
gerichts_urteil_aktenzeichen
Vergleich
Exakt
Prompt · Regex Validator · Löschen
Testfall KonfigurationTestfälle
Fall + Dokument wählen, Soll-Wert hinterlegen, gegen die Vorlage prüfen.
Fall
▾
Dokument
▾
AusführenAlle testen
TestfallErgebnis
Urteil AG MusterOK
Urteil LG BeispielOK
Statistik: Laufzeit · Input-/Output-Token · Token/Sekunde

Prerequisite: tagged documents

An extraction template finds its documents exclusively through tags. A document without the matching tag is never read — and there is no error message for it: the result is simply empty or lacks the document content. The document must therefore be tagged before the template runs. In order of preference:

  1. Tag on arrival (preferred): through the tag of the upload component in the form (document upload, ZIP upload), in the inbox, or via _tags on the task that creates the document (e.g. NewLetter).
  2. A single incoming document without a tag (e.g. triggered by a catch event): first classify the text with PromptToLLM, then set the tag on exactly that document with SetCaseFileTag.
  3. Many documents at once: ClassifyCaseFiles is intended only for the initial bulk classification when a case is created — while the case file is still in its initial status and contains no outgoing letters. More under document classification.

If you are not sure the tag exists, check it in the workflow beforehand with HasDocumentTag.

Structure of the template

Field Meaning
Template name / Description Name and purpose of the template. The name should be unique and technical — ideally one word in UPPERCASE without special characters (A–Z, 0–9, _), e.g. PAYMENT_ORDER_DATA. This exact name is later used in the workflow as _templateName. Always fill in a short, concrete description, e.g. “Extracts case number and principal claim from the payment order”.
AI connector the language model the extraction runs through. Templates generated by the DEPLAW skill for Claude Code deliberately contain no connector — you select it yourself after the import.
Pseudonymize replaces the data of the participants before sending to the model, see Pseudonymization.
Document tag filter uses tags to restrict which documents the template applies to, see Document filter.
System prompt / User prompt prefix the overarching instructions; typically “Extract only explicitly stated facts” and “Respond only with valid JSON”. The system prompt may contain case variables via FEEL; the user prompt is plain text.
Prompt role swaps the roles of system and user prompt. Leave it on User.

Data points (JSON attributes)

Each data point is a JSON attribute with:

Component Meaning
Key the JSON key (labelled “Key (Platzhalter)” in the interface) under which the value appears in the result, e.g. gerichts_urteil_aktenzeichen. It only reaches the case file through an output mapping in the workflow onto an UPPERCASE placeholder.
Prompt the field-specific instruction, precisely stating what to return.
Comparison how the value is checked against the expected value in a test — exact or semantic (see below).
Regex validator an optional pattern for format-checking the extracted value.

For the prompt of each data point: describe precisely what is wanted, where it appears, what it must not be confused with, in which format it should come back — and what happens if nothing is found (“Return nothing if you find none.”). This prevents invented values.

Data points or a free prompt

A template can work in two ways:

With JSON attributes — extracting data points. Each attribute is a data point (key + prompt), and the response format is JSON. A prompt suffix must then also be set: it closes the attribute list and leads over to the document text — Documents: has proven itself. Without a suffix, the answer can come back incomplete or the document text “sticks” to the attribute list. The prompt is assembled like this:

System:  <system prompt>
User:    <user prompt prefix>
         <list of JSON attributes: key + prompt>
         <prompt suffix, e.g. "Documents: ">
         <text of all documents matching the tag filter>

Without JSON attributes — running a prompt. The attribute list stays empty; the template simply runs the prompt and returns the result — either as JSON or as text (response format). Typical for summaries or assessments, e.g. “Summarise the objection to the payment order in at most five sentences”. Comparison type and regex are then set directly on the template instead of per attribute.

Case variables in the system prompt

In the system prompt you can use FEEL to include values from the case, such as the participants’ names. The system prompt then starts with = and is a FEEL text: text parts in "…", joined with +, line breaks as \n.

="The client is called: " + (if MANDANT_VORNAME != null then MANDANT_VORNAME else "") + " " + (if MANDANT_NACHNAME_FIRMA != null then MANDANT_NACHNAME_FIRMA else "not available") + "\n\nExtract only facts that are explicitly stated in the text."

Besides standard FEEL, the DEPLAW-specific FEEL functions are available here, e.g. (if FORDERUNG_OFFEN != null then euro(bigDecimal(FORDERUNG_OFFEN)) else "unknown") — the != null check always comes first. Do not use double quotation marks inside the running text of the prompt (use ' or typographic quotes instead). The names of the placeholders must match exactly.

Pseudonymization

With Pseudonymize switched on, the following happens:

  1. Shortly before sending the prompt, the data of the participants in the case file is replaced by fictitious data.
  2. The language model works only with the fictitious data.
  3. The answer is de-pseudonymized again — so the real names are back in the result.

You do not need to change anything in the prompt for this. Personal data of other people who are not listed as participants in the case file is not replaced. Whether the option should be on is a data-protection decision — decide it deliberately rather than just accepting a default. Basics in the chapter Pseudonymization.

Document filter

The document tag filter determines which documents go into the prompt. It consists of one condition whose parts are linked with AND / OR — each part checks one tag:

  • OR — documents with one of the tags, e.g. different names for the same type of document (“payment order” or “PO”).
  • AND — only documents that carry all the tags, e.g. “objection” and “opposing party”.

For a pure OR chain or a pure AND chain, set the same operator on all parts. Mixed conditions are evaluated one after another from left to right, like a condition without brackets — there is no “AND before OR”: 1. OR 2. AND 3. means (1. OR 2.) AND 3.. Choose the order accordingly; “objection AND (opposing party OR court)” is built as “opposing party”, “court” (OR), “objection” (AND). Logic such as “(A AND B) OR (C AND D)” cannot be expressed in a single filter.

Write the tags exactly as they appear on the documents. The filter checks whether a tag is contained; filtering by date is currently not possible in extraction templates.

Testing for regressions

On the right side of the editor, you maintain individual test cases under Test case configuration (case + document + known expected value); under Test cases you see the saved collection. Run tests the current case, Test all checks the template against all test cases at once. The statistics (runtime, tokens, tokens/second) also help you keep an eye on cost and speed. The test cases live in the platform and are not part of an export of the template.

Semantic result comparison (semantic-compare)

For free-text data points, an LLM rarely produces the exact same wording twice — but the content should stay the same. The AI connector with the reserved name semantic-compare compares the output by meaning rather than character-for-character. Selected as the comparison for an attribute, a free-text result is then considered correct even if it’s worded differently but matches the expected value in content.

Which comparison fits, and when to use a regex

  • Texts (court name, summary, description) → semantic.
  • Numbers, amounts, dates, case numbers and fixed values (Yes/No) → exact. Comparing free text exactly produces failing tests for results that are correct in content.
  • Regex validator only for values that are always built the same way (e.g. a date ^\d{2}\.\d{2}\.\d{4}$) — and only if you explicitly want it. The regex applies not only in the test but also at runtime: if an extracted value does not match the pattern, LlmExtractionTemplateRun aborts with the error regex-validation-error (see below).

Using it directly in a workflow

A finished, tested template is also a workflow step: the service task LlmExtractionTemplateRun runs it via its _templateName — an incoming document is thereby read out fully automatically and used in subsequent steps (filling placeholders, gateways, further actions).

<bpmn:serviceTask id="Activity_0k4x9wd" name="Extract payment order data">
  <bpmn:extensionElements>
    <zeebe:taskDefinition retries="2" type="LlmExtractionTemplateRun"/>
    <zeebe:taskHeaders>
      <zeebe:header key="_templateName" value="PAYMENT_ORDER_DATA"/>
    </zeebe:taskHeaders>
    <zeebe:ioMapping>
      <zeebe:output source="=_extractionJson.mb_geschaeftsnummer" target="wf_mb_geschaeftsnummer"/>
    </zeebe:ioMapping>
  </bpmn:extensionElements>
</bpmn:serviceTask>
  • _templateName must match the template name character for character, otherwise the task does not find the template.
  • Response format JSON → the result is in _extractionJson as one object; read the fields directly with _extractionJson.<key> (no parseToJson needed). Response format text → the result is in _extraction as text.
  • The values do not end up in the case file automatically. What should go into the case file you map with an output mapping to an UPPERCASE placeholder; what is only needed inside the workflow goes into a wf_ variable.
  • Possible errors: json-invalid, prompt-error and regex-validation-error. All three can be caught in the model with an error boundary event on the task (see Incidents); if the template has a regex, you should always catch regex-validation-error.

Common errors

Symptom Likely cause Fix
Result empty or obviously without document content The documents do not carry the tag from the filter, or the tag is misspelt Tag documents beforehand (prerequisite), copy the tag character for character
Task fails or does not find the template _templateName differs from the template name Compare both spellings character for character
Prompt fails on some case files Case variable in the system prompt without a != null check Guard every variable with if X != null then X else ""
Value never shows up in the case file No output mapping, or target not in uppercase Add a mapping to an UPPERCASE placeholder
JSON answer incomplete, document text “sticks” to the attribute list Prompt suffix missing although JSON attributes are active Set a suffix, e.g. Documents:
Workflow ends in an incident with regex-validation-error Error not caught, or regex set too strictly Catch the error with a boundary event; use a regex only for fixed formats
Tests fail on texts that are correct in content Exact comparison used for free text Choose the semantic comparison for texts

Generating templates from a text prompt

The DEPLAW skill for Claude Code also generates extraction templates as an import-ready file: you describe which data points you need from which documents, and the skill sets name, prompts, suffix, comparison types and document filter according to the rules on this page. You select the AI connector yourself after the import; you create the test cases in the interface.