Generating Legal Commentaries from Case Databases via Retrieval, Clustering, and Generation

Max Prior, Niklas Wais, Matthias Grabmair · 2026

Read Generating Legal Commentaries from Case Databases via Retrieval, Clustering, and Generation by Max Prior, Niklas Wais, Matthias Grabmair (2026) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2605-24534.txt.

Introduction

Max Prior, Niklas Wais, and Matthias Grabmair automate a laborious legal task: turning large court-decision collections into commentaries on statutes. From 4,555 German Federal Court of Justice decisions citing four Civil Code sections, they extract reasoning chunks, summarize them, and cluster the results. Language models then draft headings and citation-rich sections, merged into coherent commentaries. Expert and model judges rated the output on five dimensions, finding refreshable reports feasible but limited by narrow sources and legal normativity, published in 2026.

Catalog record

CREATORMax Prior, Niklas Wais, Matthias Grabmair
YEAR2026
COLLECTIONPAPERS
FORMATTXT
FILE SIZE30079
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2605.24534

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

Generating Legal Commentaries from Case Databases via Retrieval, Clustering, and Generation Max Prior, Niklas Wais, Matthias Grabmair Abstract We present a fully automated pipeline that transforms large collections of court decisions into legal commentaries for statutes — without providing any handcrafted doctrinal framework. Using 4.555 decisions of the German Federal Court of Justice that cite §§ 242, 280, 812 and 823 of the German Civil Code (BGB), we extract paragraph-level chunks, summarize their reasoning, and derive keywords, which are embedded and clustered. For each cluster, an LLM generates headings and synthesizes citation-rich sections, which are then merged into coherent commentaries by four state-of-the-art LLMs. We evaluate along five dimensions – topical relevance, heading-match, citation faithfulness, cluster distinction and logical ordering – using both a human expert and an “LLM-judge”. Our results show that commentary-like argument mining from court decisions to generate reports that can be refreshed within minutes at minimal cost is feasible, yet they highlight limitations arising from restricted sources and the normativity of legal reasoning. 1 [orcid=0009-0005-7066-996X, [email protected], ] [orcid=0009-0008-6459-721X, [email protected], ] [orcid=0000-0001-6586-2486, [email protected], url=https://www.cs.cit.tum.de/lt/tum-legal-tech-working-group/, ] keywords Argument Mining,Legal Commentaries ,Generative NLP † † copyrightyear: 2025 † † copyright: Copyright for this paper by its authors. Use permitted under Creative Commons License Attribution 4.0 International (CC BY 4.0). † † venue: Proceedings of the First Argument Mining and Empirical Legal Research Workshop (AMELR 2025), June 20, 2025, Chicago, United States † † address: Technical University of Munich, Boltzmannstraße 3, 85748 Garching near Munich 1 Introduction Common and Civil Law systems are often contrasted by the claim that the former relies on precedent, while the latter centers on statutes. While Civil Law judges are not formally bound by case law and begin with statutes, the notion of judges as mere bouche de la loi (”mouth of the law”; for a critical assessment of Montesquieu’s actual position, see 10 ) has long been proven to be a deliberate misrepresentation invented by the self-proclaimed anti-formalist movements of the early 20th century 9 . Judicial decision-making necessarily involves interpretation, and prior rulings — although generally not binding — inform the consistent application of statutes. Legal commentaries systematize this practice: they collect and analyze the application of statutes by the courts as well as proposals regarding their application from papers, books, and other commentaries. In other words, they mine arguments from court decisions and the legal literature. 1.1 Structure of Legal Commentaries Commentaries typically focus on one statute book, e.g., the German Civil Code (BGB), and are following its structure. In the case of a BGB commentary, there is one ”chapter” per legal provision of the BGB (§ 1 to § 2385). After repeating the wording of the respective legal provision, each chapter is structured around questions arising from the application (i.e., interpretation) of the provision. For example, when faced with a case potentially involving liability for injury under § 823 (1) BGB, a judge might question whether witnessing a traumatic event can constitute a violation of ”Gesundheit” (health) as intended by the provision. Since the statutory wording itself leaves room for interpretation, the judge will seek arguments supporting or rejecting the view that psychological trauma from witnessing an event should qualify as a health violation within the meaning of § 823 (1) BGB. This involves identifying definitions proposed by legal scholars or established by court rulings concerning the concept of ”Gesundheit” (health) under § 823 (1) BGB. It also involves reviewing prior court decisions addressing similar circumstances. Regarding the question, both pro and contra arguments are collected and systematized in the § 823 BGB chapter of a commentary. 1.2 Computer-Generated Commentaries Legal Commentaries are massive books written by multiple authors. Their creation is a complicated and costly process. Given the recent advances in Natural Language Processing brought about by LLMs, researchers have started to investigate the automated generation of such commentaries based on collections of court rulings. Engel and Kruse present a prototype of an automated pipeline that lets GPT-4 draft a commentary on Article 8 of the German Constitution. Python code fetches 125 rulings of the German Constitutional Court, extracts passages mentioning Article 8, and feeds them – with an elaborate prompt that entails constitutional law doctrine – to GPT-4, which classifies, summarizes and groups every citation under typical headings. Compared to five leading hand-written commentaries, the machine-generated version cites far more decisions, provides pinpoint references and can refresh in hours at a cost of approximately $33, yet it still misclusters some material, and misses doctrinal shifts. It was created with heavily engineered prompts that provide the doctrinal framework of German constitutional law to the model, which structures the generation into a form comparable to human-written commentaries. The authors present it as a complement, not a substitute 3 . They also use a similar approach with rulings from the European Court of Human Rights (ECtHR) 4 . Santosh et al. developed the ”LexGenie” model, which is not explicitly positioned as a legal commentary, but an interactive tool to generate structured reports from ECtHR rulings based on keywords provided by the user. Offline, they index at the paragraph level via Mistral-7B key-phrase embeddings and store them in a FAISS database. Online, they retrieve passages via Maximum Marginal Relevance (MMR) to the keywords and organize them using BERTopic and HDBSCAN. Afterwards, GPT-4o-mini refines headings and incrementally drafts citation-rich texts to build multi-case legal guides. Limitations include occasional misclustering and sparse cross-section links 8 . Similar functionality is now being explored by systems like OpenAI’s Deep Research, which provide grounded and multi-document syntheses to support advanced academic workflows 7 . Like 8 , they do not rely on hard-coded legal knowledge when generating legal reports and do not follow the structure of a legal commentary. A key difference compared to 8 is that they first generate a structured plan and then retrieve documents, rather than generating a structure from retrieved documents. 1.3 Our Contribution We combine the approaches of 8 and 3 by generating commentary-like reports for legal provisions (not keywords like 8 ) without providing doctrinal context (unlike 3 ). Instead, we rely solely on the texts of court rulings and statutes. This generalization makes our approach easily extendable to any number of legal provisions. For demonstration purposes, we focus on the German Civil Code (BGB), which codifies central aspects of private law and consists of more than two thousand provisions. When compared to the German Constitution or the ECHR, it is of high practical importance and particularly challenging due to the amount of court rulings that refer to it. We also compare the performance of multiple state-of-the-art models for the task at hand, introduce a sophisticated pipeline and provide quantitative as well as qualitative evaluation. Lastly, we contribute to the legal theory discussion on the benefits and limitations of computer-generated commentaries. 2 Data and Methods Figure 1: Our pipeline. In the clustering step (6), green circles represent the chunks used to generate headlines, while brown circles represent the broader cluster of chunks that is used to generate the section text for every headline. Red circles are regarded as noise. Figure 1 illustrates the steps from downloading the court decision up to generating the final commentary. In step 1, we select a set

Read the complete text