LLMs for the Legal Domain: Instruction Fine-Tuning and Model Adaptation
Applied research project on the adaptation and evaluation of Large Language Models for government and legal contexts involving sensitive data.
ONGOINGLEGAL AIINSTRUCTION FINE-TUNINGKNOWLEDGE DISTILLATIONPRIVACY-PRESERVING AI
Project details
Role: Collaborating Researcher
Principal Investigator: Ricardo Marcacini
Institutions: Universidade de São Paulo (USP) / Procuradoria-Geral da Fazenda Nacional (PGFN), Brazil
Period: 2024–2026
Overview
The research covers privacy, teacher–student learning, knowledge distillation, efficient fine-tuning, LoRA, quantization, model evaluation, factuality, and the reduction of errors and hallucinations.
Research outputs
Development and evaluation of privacy-preserving strategies for specializing LLMs in sensitive domains.
Evaluation of models for the classification and analysis of legal documents.
Development of teacher–student strategies combined with distillation, LoRA and quantization.
Large Language Models (LLMs) have revolutionized natural language processing, but their reliance on extensive computational resources and proprietary APIs poses significant challenges for public sector applications. Government agencies often face legal constraints, such as GDPR and LGPD, preventing the use of external LLMs when handling sensitive data. Even when compliance is met, the financial burden of deploying large-scale models remains a major barrier. To address these challenges, we present LLM4Gov, a privacy-preserving computational tool designed to fine-tune distilled LLMs for government-related tasks while minimizing infrastructure costs. LLM4Gov follows a structured teacher-student learning pipeline, where a lightweight anonymization module first removes personally identifiable information (PII) before any interaction with an external LLM. A teacher LLM then generates task-specific instructions from the anonymized dataset, and a distilled student LLM is fine-tuned using Low-Rank Adaptation (LoRA) and quantization, enabling deployment on resource-constrained environments. Our experimental results show that LLM4Gov consistently outperforms competitive distilled LLMs, achieving higher accuracy while preserving privacy and interpretability.
@inproceedings{marcacini2025llm4gov,title={LLM4Gov: A Privacy-Preserving Approach to Teacher-Student Fine-Tuning of Distilled LLMs for the Public Sector},author={Marcacini, Ricardo and Valverde-Rebaza, Jorge and Turine, Marcelo and Santos, Brucce and Levcovitz, Silvio and Rezende, Solange},booktitle={Anais do XII Latin American Symposium on Digital Government (LASDiGov 2025)},pages={273--284},year={2025},publisher={SBC},address={Porto Alegre, RS, Brasil},issn={2763-8723},doi={10.5753/lasdigov.2025.9471},}