AI-Powered Intelligent Petition Generation System
This study proposes a Retrieval-Augmented Generation (RAG)-based artificial intelligence system capable of transforming legal problems expressed by citizens in natural language into formal petitions adhering to official writing conventions. While current large language models demonstrate significant linguistic proficiency in legal text generation, they exhibit limitations in contextual accuracy and the production of regulation-based references. The proposed system semantically indexes legal legislation texts, matching user queries with relevant regulations and generating text solely based on the retrieved context. This approach reduces the risk of hallucination, thereby increasing reliability in legal text production. The system analyzes user input to determine the type of event, selects appropriate legal grounds, and generates petition outputs in a formal format. This study highlights the importance of context-based generation architecture in the design of digital legal support systems and presents a viable model for citizen-centric artificial intelligence applications.
Drafting formal petitions in legal proceedings plays a critical role in individuals' access to justice mechanisms. However, a lack of familiarity with legal terminology, ignorance of formal writing formats, and the inability to accurately reference relevant legislation can hinder individuals from effectively exercising their rights. Particularly in situations directly affecting daily life, such as consumer complaints, rental disputes, and subscription cancellations, a formal or substantive deficiency in the petition can lead to delays in the process or rejection of the application. In this context, advancements in natural language processing offer new opportunities in legal text generation.
Large language models (LLMs) demonstrate high proficiency in generating and transforming complex texts. However, in legal text generation, systems based solely on generative models can produce statements that are disconnected from the context or unsupported by legislation, posing a risk to legal reliability. In the legal field, accuracy and substantiation are more critical requirements than mere linguistic fluency. Therefore, this study favors an architecture that constrains and supports the capabilities of the generative model with context.
The proposed system is based on the Retrieval-Augmented Generation approach. In this framework, relevant legislative texts, articles of law, and regulations are pre-processed, divided into semantic chunks, and stored in a vector database. The user's natural language problem statement is analyzed semantically, and the most relevant legislative excerpts are retrieved. The language model is then guided to generate the petition using only this retrieved legal context. Thus, the system generates text based on specific legal references rather than general knowledge.
The second important element in the system design is the standardization of the formal writing format. Petitions have a specific structure; the receiving institution, subject heading, explanation section, and request section must be clearly separated. The proposed system extracts the parties involved, the historical context, and the desired outcome from the user input and places this information into the formal writing format. In this process, the language model is guided to maintain both legal terminology and formal style. As a result, the generated text exhibits a coherent structure not only in terms of content but also in terms of form.
To enhance the system's reliability, restrictive instructions have been added to the generation process. The model is instructed to generate content only based on the provided legal context and to avoid unsubstantiated general statements. This approach reduces the hallucination rate and encourages the text to be based on legislation. Nevertheless, it is explicitly stated that the system outputs are for informational purposes only and do not constitute professional legal advice.
Evaluations have shown that the retrieval-augmented generation approach produces more consistent and legally contextualized texts compared to systems based solely on free generative models. Particularly in common scenarios such as consumer complaints and rent increases, the system was able to integrate relevant legal bases into the text and maintain the formal writing format. However, the system's success is directly related to the currency and scope of the legislation database. Outdated or incomplete data directly affects the quality of the output.
In conclusion, this study presents the design of a context-based and legislation-driven automated petition generation system aimed at facilitating citizens' access to justice. The Retrieval-Augmented Generation architecture enhances legal reliability, preserves formal writing standards, and transforms natural language inputs into structured formal texts. The proposed system offers a scalable and applicable model for digital legal support applications, representing a significant example of the socially beneficial use of artificial intelligence.