L egal V iz: Legal Text Visualization by Text To Diagram Generation (2025)

Abstract: Legal documents including judgments and court orders require highly sophisticated legal knowledge for understanding. To disclose expert knowledge for non-experts, we explore the problem of visualizing legal texts with easy-to-understand diagrams and propose a novel dataset of LegalViz with 23 languages and 7,010 cases of legal document and visualization pairs, using the DOT graph description language of Graphviz. LegalViz provides a simple diagram from a complicated legal corpus identifying legal entities, transactions, legal sources, and statements at a glance, that are essential in each judgment. In addition, we provide new evaluation metrics for the legal diagram visualization by considering graph structures, textual similarities, and legal contents. We conducted empirical studies on few-shot and finetuning large language models for generating legal diagrams and evaluated them with these metrics, including legal content-based evaluation within 23 languages. Models trained with LegalViz outperform existing models including GPTs, confirming the effectiveness of our dataset.

## introduction driven by the rapid advancements in large language model (llm) performance @xcite , adaptation to specialized domains in natural language processing (nlp) receives increasing attention in many fields @xcite @xcite . specifically, the application of llms to the legal field holds the potential to automate significant tasks and support roles traditionally occupied by lawyers and judges @xcite . the understanding of legal documents poses unique challenges for nlp applications, as legal reasoning requires not only interpreting the surface utterance but also implicit rules often omitted from the legal documents. it also requires following legal syllogisms, understanding the implications of the special depreciation allowances and tax-free reserves pursuant to paragraph 3 of the zrfg are incompatible with the common market. ## evaluation we compare the reference and hypothesis graphs to assess the quality of the generated. one straightforward way to achieve this is to directly compare two images visualized by graphviz. however, this approach clearly ignores the textual structure of the legal documents. one other approach is directly comparing the dot language codes in textual manner, ignoring numerous minor differences of the visualization codes that can result in different graphs. therefore we propose an approach to first compose graphs, align the graph components, and then compare each component of graphs using textual metrics as described in this section. ## experiments we evaluate the ability to visualize graphs from legal sentences with legalviz. overall, our finetuned models overperformed fewshot gpt models. ## conclusion we have proposed legalviz, the first manually annotated dataset to visualize legal text with dot language graphviz and introduced a novel evaluation method taking into account both diagram visualization quality and sentences of not only graph nodes and relations but also legal contents. we empirically confirmed the effectiveness of our dataset with wide-range of experiments including comparisons of few-shot and finetuning models and demonstrated trained models outperform the closed models of gpts in all evaluation metrics.