law to markdown

converting legal documents for AI processing

TL;DR

When your AI opens this URL:

https://law.xemantic.com/de/federal/gg/22

it will get the Grundgesetz (Basic Law), article 22:

## Art 22

(1) Die Hauptstadt der Bundesrepublik Deutschland ist Berlin. Die Repräsentation des Gesamtstaates in der Hauptstadt ist Aufgabe des Bundes. Das Nähere wird durch Bundesgesetz geregelt.

(2) Die Bundesflagge ist schwarz-rot-gold.

The purpose of this service

The law to markdown service provides legislative documents in Markdown format, so that they can be easily digested by LLMs and agentic AI systems.

This service forwards requests to the official database of German law (Gesetze im Internet), ensuring you always get the most recent documents and updates.

Note: only German federal documents are supported at the moment.

Why Markdown instead of XML?

The German law is published on the Gesetze im Internet service. Documents are provided in multiple formats, including human-readable HTML and PDF, and machine processable source of these documents published as XML documents with associated specialized XML schema.

The XML format, well-suited for algorithmic processing, falls short with the probabilistic nature of an LLM. Expressing structured natural language as Markdown proved to be an optimal LLM input for conveying meanings to the machine.

Autonomous and contextual law retrieval

Frontier AI models are trained on a large corpus of documents, including German law, therefore they can already provide paralegal expertise. There are still certain challenges to be addressed:

  • recalling exact phrasing during LLM inference is error-prone
  • results are subject to hallucinations, leading to nonfactual statements
  • regulations may have been updated since the model's knowledge cutoff

For these reasons, it is desirable to always provide the actual copy of the processed law in the LLM's context window. Even better results can be achieved when an LLM can autonomously retrieve the precise documents needed in the context of a task.

About law to markdown

This service has been developed by Rulemapping Group in collaboration with Xemantic.

Using law to markdown with an LLM or AI agent

You might add the following system prompt:

You can obtain German law documents in multiple formats:

Markdown format (full document):
https://law.xemantic.com/de/federal/document_id

Markdown format (individual first-level sections):
https://law.xemantic.com/de/federal/document_id/section

Original XML format (full document only):
https://law.xemantic.com/de/federal/document_id.xml

Where document_id is a standard identifier used on https://www.gesetze-im-internet.de/
First-level sections (e.g., German "Paragraph" or "Article") are available only in Markdown format.

For example calling:

https://law.xemantic.com/de/federal/gg/22

Will return:

```markdown
## Art 22

(1) Die Hauptstadt der Bundesrepublik Deutschland ist Berlin. Die Repräsentation des Gesamtstaates in der Hauptstadt ist Aufgabe des Bundes. Das Nähere wird durch Bundesgesetz geregelt.

(2) Die Bundesflagge ist schwarz-rot-gold.
```
Note: your LLM or AI agent must have web access capabilities to fetch content from URLs.