Graph-based Keyword Planning for Legal Clause Generation from Topics (2022)

Abstract: Generating domain-specific content such as legal clauses based on minimal user-provided information can be of significant benefit in automating legal contract generation. In this paper, we propose a controllable graph-based mechanism that can generate legal clauses using only the topic or type of the legal clauses. Our pipeline consists of two stages involving a graph-based planner followed by a clause generator. The planner outlines the content of a legal clause as a sequence of keywords in the order of generic to more specific clause information based on the input topic using a controllable graph-based mechanism. The generation stage takes in a given plan and generates a clause. The pipeline consists of a graph-based planner followed by text generation. We illustrate the effectiveness of our proposed two-stage approach on a broad set of clause topics in contracts.

## introduction contracts are essential discourse units that frequent in several day-to-day business workflows, especially between companies and governmental organizations. the fundamental units of discourse in contracts consist of "clauses" that are paragraphs of text that outline the terms and conditions of various types or topics (e.g., severability, benefits) ( in case any provision herein or obligation hereunder or any note or other credit document shall be invalid, illegal, or unenforceable in any jurisdiction, the validity, legality and enforceability of the remaining provisions or obligations, or of such provision or obligation in any other jurisdiction, shall not in any way be affected or impaired thereby. there have been recent advances in transformerbased @xcite methods for text generation in varied flavors, such as prompt-based causal generation @xcite , conditional generation based on control codes @xcite , and retrieval-augmented generation based on queries @xcite . however, these methods are primarily studied in generic nlp domains, and legal text generation remains largely unexplored. the only previous work that addressed the task of legal text generation is clauserec @xcite , in which a transformerbased decoder is trained to generate missing legal clauses in a given contract document, conditioned on the clause topic and the content in the contract. however, @xcite noted that the clauses generated by clauserec suffer from low linguistic variations within topics, thus resulting in content that is thematically relevant but missing a few nuances. in general, we believe conditioning text generation on only the high-level clause topics or the contract content may not capture the subtleties present in legal clauses, hence call for an iterative approach to learn the clause-specific content in a top-down manner. we find inspiration in the content planning paradigm for story generation @xcite @xcite in which an intermediate plan (e.g., a set of keywords) is used to generate final stories. in this paper, we study legal text generation, and propose a two-staged pipeline (figure 1 ) to generate legal clauses from topics iteratively using keywords. specifically, the first module of our pipeline comprises of a graph-based planner that takes in a topic (and an optional set of keywords) and produces an ordered content plan consisting of keywords, with those more generic to the topic ranked higher, and those more specific to a clause ranked lower. note that unlike @xcite , which aimed to generate missing clauses given a contract, we focus on generating legal clauses only based on a given topic and an optional set of keywords. we approximate the generated content plan to the user intent, which will be translated into a legal clause. in the second stage, the plan is used as a control mechanism, and a transformer-based language model is trained to generate legal clauses conditioned on the topic and the plan. 1 following are the main contributions of this paper: (1) we propose a novel two-staged pipeline for legal clause generation, comprising a content planner that generates a keyword-based plan, and a content generator that generates legal clauses conditioned on the clause topics and keyword plans. our proposed content planner consists of a simple, lightweight graph-based mechanism that performs a graph walk using the input topic to generate a plan consisting of generic to specific keywords. the plan can be customized by specifying a few control keywords, bringing controllability to the generation. (2) we compare our approach with several conditional and causal text generation baselines, and illustrate strong empirical results for le-gal clause generation. (3) we also show that our approach can be generalized well to a diverse range of clause topics, thus indicating the extensibility of our approach for legal text generation. we believe our work takes one step further in the area of automatic clause generation for ai-aided drafting of legal documents. ## graph-based planning for clause generation our proposed approach aims to generate legal clauses to aid legal counsel in contract drafting. to do so, it takes as input a clause topic (e.g., data privacy) along with a few keywords for customization (personal, code, consent), and generates more keywords in order to obtain a customized content plan as illustrated in figure 1 . this keyword-based plan, which we consider an approximation to userspecified keywords per their preferences, is then used to generate a meaningful legal clause. ## analysis figure 4 : illustration of the robustness of pipeline to clause topics of various frequencies. ## conclusion we propose a plan-based approach for generating legal clauses inspired by content planning techniques in story generation. the pipeline involves customizable content plan generation based on the clause topic and optional control keywords using a simple, lightweight graph followed by clause generation. the content plan represents its corresponding clause as an ordered list of generic to specific keywords. our approach achieves promising results for clause generation across the broad range of clause topics in the dataset, indicating the extensibility of our approach. we also show the merit of our proposed order in generating clauses with lesser keyword information. while we discuss a use case for controllability in clause generation possible through our pipeline, the generation of clause content shows substantial changes for minor changes in the plan. future work can look at increasing the preciseness of control involved by changing only the content of a clause as necessitated by a change in the input plan. the customization of clause content can be further drilled down to inclusion of entity-specific and contract-specific information.