An Original Natural Language Processing Approach to Language Modeling in the Turkish Legal Corpus: Improving Model Performance with Domain Classification by Using Recurrent Neural Networks
Türkçe Hukuk Derleminde Dil Modellemesi Üzerine Özgün Bir Doğal Dil İşleme Yaklaşımı: Yinelemeli Sinir Ağları Kullanılarak Alana Ait Sınıflandırma (AAS) ile Model Başarımının İyileştirilmesi
Türkiye's first small language model for the legal domain trained from scratch.
Authors: C. Erdoğanyılmaz · B. Mengünoğul
Abstract
The study proposes the “Domain Classification” method to boost language-model performance in a field with its own terminology: the hypothesis that domain models trained on sub-corpora split by legal discipline outperform a single general model is tested experimentally. Four character-level GRU language models — commercial, labor, civil-procedure and constitutional law — were trained from scratch, coupled with a separate classifier RNN that detects the legal branch of the user's input and routes it to the matching language model, forming a hybrid natural language generation system.
Findings
- Domain models trained with the method improved test accuracy by 6.9%–13.6% over the general model, and all of them tracked below the general model in cross-entropy loss.
- A corpus of 577,748 sentences from 100 doctoral law theses, classified into 28 legal categories, was used for training.
- The legal-text classifier reached a macro F1 of 0.81 across five categories, peaking in commercial law (F1 = 0.86) and constitutional law (F1 = 0.82).
- The lightweight architecture, trainable even on low-end hardware, laid a foundation for legal text-generation scenarios such as drafting petitions, decisions and indictments.
Method details
The language models use Gated Recurrent Units (GRU): they avoid the vanishing/exploding-gradient issues of vanilla RNNs while training faster than LSTMs. A character-level representation was chosen for its effectiveness in morphologically rich, agglutinative languages such as Turkish (4 GRU layers, 512 units per layer, 256-character sequences, Log-Softmax activation, Adam optimizer). Beyond accuracy and cross-entropy loss, log-perplexity was computed as a language-model-specific criterion. The classifier is a word-level, 3-layer GRU (30,000-word vocabulary, 50-dimensional embedding layer) that routes inputs into five legal categories.